From c362daec7ddcd55960029af45874810fce9666fc Mon Sep 17 00:00:00 2001 From: sabonerune <102559104+sabonerune@users.noreply.github.com> Date: Mon, 21 Oct 2024 18:21:05 +0900 Subject: [PATCH 1/5] BLD: Declarative config Move most of the configuration from setup.py to pyproject.toml. --- .github/workflows/ci.yaml | 1 + MANIFEST.in | 7 ++- pyproject.toml | 77 ++++++++++++++++++++++++- release.sh | 2 +- setup.cfg | 1 - setup.py | 118 ++------------------------------------ 6 files changed, 86 insertions(+), 120 deletions(-) delete mode 100644 setup.cfg diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index ac4b963..b46d59b 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -32,6 +32,7 @@ jobs: steps: - uses: actions/checkout@v4 with: + fetch-depth: 0 submodules: true - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 diff --git a/MANIFEST.in b/MANIFEST.in index d7063f2..f82558f 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,7 @@ -include README.md LICENSE.md -recursive-include pyopenjtalk *.cpp *.pxd *.md *.pyx +include pyopenjtalk/version.py +exclude .gitignore .gitmodules .travis.yml release.sh tox.ini +prune .github/* +prune docs/** recursive-include lib *.cpp *.c *.h README LICENSE COPYING CMakeLists.txt *.in exclude lib/open_jtalk/src/mecab/src/config.h +prune lib/open_jtalk/src/build/** diff --git a/pyproject.toml b/pyproject.toml index ce01636..ec208df 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,8 +1,7 @@ [build-system] requires = [ - "setuptools>=66.1.0; python_version>='3.12'", - "setuptools>=60.0.0; sys.platform=='win32'", - "setuptools=61.0.0", + "setuptools_scm<9", "cython>=0.28.0", "cmake", "numpy>=1.25.0; python_version>='3.9'", @@ -10,6 +9,78 @@ requires = [ ] build-backend = "setuptools.build_meta" +[project] +name = "pyopenjtalk" +dynamic = ["version"] +description = "A python wrapper for OpenJTalk" +readme = "README.md" +requires-python = ">=3.7" +license.file = "LICENSE.md" +authors = [{ name = "Ryuichi Yamamoto", email = "zryuichi@gmail.com" }] +keywords = ["OpenJTalk", "Research"] +classifiers = [ + "Operating System :: POSIX", + "Operating System :: Unix", + "Operating System :: MacOS", + "Operating System :: Microsoft :: Windows", + "Programming Language :: Cython", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "License :: OSI Approved :: MIT License", + "Topic :: Scientific/Engineering", + "Topic :: Software Development", + "Intended Audience :: Science/Research", + "Intended Audience :: Developers", +] +urls.Homepage = "https://github.com/r9y9/pyopenjtalk" +dependencies = [ + "importlib_resources; python_version<'3.9'", + "numpy>=1.20.0", + "tqdm", +] + +[project.optional-dependencies] +docs = [ + "sphinx_rtd_theme", + "nbsphinx>=0.8.6", + "Jinja2>=3.0.1", + "pandoc", + "ipython", + "jupyter", +] +dev = [ + "cython>=0.28.0", + "pysen", + "types-setuptools", + "mypy<=0.910", + "black>=19.19b0,<=20.8", + "click<8.1.0", + "flake8>=3.7,<4", + "flake8-bugbear", + "isort>=4.3,<5.2.0", + "types-decorator", + "importlib-metadata<5.0", +] +test = ["pytest", "scipy"] +marine = ["marine>=0.0.5"] + +[tool.setuptools.packages] +find.namespaces = false + +[tool.setuptools.exclude-package-data] +"*" = ["*.pyx", "*.pxd"] + +[tool.setuptools_scm] +# NOTE: write_to is deprecated, but version_file is not supported in Python 3.7. +write_to = "pyopenjtalk/version.py" +write_to_template = ''' +__version__ = "{version}" +''' + [tool.pysen] version = "0.10.2" diff --git a/release.sh b/release.sh index 3dabccc..ea2ac58 100755 --- a/release.sh +++ b/release.sh @@ -14,7 +14,7 @@ TAG=$(git describe --exact-match --tags HEAD) VERSION=${TAG/v/} -PYOPENJTALK_BUILD_VERSION=$VERSION python setup.py develop sdist +python -m build --sdist echo "*** Ready to release! pyopenjtalk $TAG ***" echo "Please make sure that release verion is correct." cat pyopenjtalk/version.py diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index af57bc0..0000000 --- a/setup.cfg +++ /dev/null @@ -1 +0,0 @@ -[bdist_wheel] diff --git a/setup.py b/setup.py index c232c71..dfac91e 100644 --- a/setup.py +++ b/setup.py @@ -4,18 +4,13 @@ from glob import glob from itertools import chain from os.path import exists, join -from subprocess import run import numpy as np import setuptools.command.build_ext -import setuptools.command.build_py -import setuptools.command.develop -from setuptools import Extension, find_packages, setup +from setuptools import Extension, setup platform_is_windows = sys.platform == "win32" -version = "0.3.5-dev" - msvc_extra_compile_args_config = [ "/source-charset:utf-8", "/execution-charset:utf-8", @@ -93,7 +88,9 @@ def check_cmake_in_path(): # NOTE: The wrapped OpenJTalk does not depend on HTS_Engine, # but since HTSEngine is included in CMake's dependencies, it refers to a dummy path. - r = run(["cmake", "..", "-DHTS_ENGINE_INCLUDE_DIR=.", "-DHTS_ENGINE_LIB=dummy"]) + r = subprocess.run( + ["cmake", "..", "-DHTS_ENGINE_INCLUDE_DIR=.", "-DHTS_ENGINE_LIB=dummy"] + ) r.check_returncode() os.chdir(cwd) @@ -155,109 +152,4 @@ def check_cmake_in_path(): ) ] -# Adapted from https://github.com/pytorch/pytorch -cwd = os.path.dirname(os.path.abspath(__file__)) -if os.getenv("PYOPENJTALK_BUILD_VERSION"): - version = os.getenv("PYOPENJTALK_BUILD_VERSION") -else: - try: - sha = ( - subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=cwd) - .decode("ascii") - .strip() - ) - version += "+" + sha[:7] - except subprocess.CalledProcessError: - pass - except IOError: # FileNotFoundError for python 3 - pass - - -class build_py(setuptools.command.build_py.build_py): - def run(self): - self.create_version_file() - setuptools.command.build_py.build_py.run(self) - - @staticmethod - def create_version_file(): - global version, cwd - print("-- Building version " + version) - version_path = os.path.join(cwd, "pyopenjtalk", "version.py") - with open(version_path, "w") as f: - f.write("__version__ = '{}'\n".format(version)) - - -class develop(setuptools.command.develop.develop): - def run(self): - build_py.create_version_file() - setuptools.command.develop.develop.run(self) - - -with open("README.md", "r", encoding="utf8") as fd: - long_description = fd.read() - -setup( - name="pyopenjtalk", - version=version, - description="A python wrapper for OpenJTalk", - long_description=long_description, - long_description_content_type="text/markdown", - author="Ryuichi Yamamoto", - author_email="zryuichi@gmail.com", - url="https://github.com/r9y9/pyopenjtalk", - license="MIT", - packages=find_packages(), - package_data={"": ["htsvoice/*"]}, - ext_modules=ext_modules, - cmdclass={"build_ext": custom_build_ext, "build_py": build_py, "develop": develop}, - install_requires=[ - "importlib_resources; python_version<'3.9'", - "numpy >= 1.20.0", - "tqdm", - ], - tests_require=["nose", "coverage"], - extras_require={ - "docs": [ - "sphinx_rtd_theme", - "nbsphinx>=0.8.6", - "Jinja2>=3.0.1", - "pandoc", - "ipython", - "jupyter", - ], - "dev": [ - "cython>=0.28.0", - "pysen", - "types-setuptools", - "mypy<=0.910", - "black>=19.19b0,<=20.8", - "click<8.1.0", - "flake8>=3.7,<4", - "flake8-bugbear", - "isort>=4.3,<5.2.0", - "types-decorator", - "importlib-metadata<5.0", - ], - "test": ["pytest", "scipy"], - "marine": ["marine>=0.0.5"], - }, - classifiers=[ - "Operating System :: POSIX", - "Operating System :: Unix", - "Operating System :: MacOS", - "Operating System :: Microsoft :: Windows", - "Programming Language :: Cython", - "Programming Language :: Python", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "License :: OSI Approved :: MIT License", - "Topic :: Scientific/Engineering", - "Topic :: Software Development", - "Intended Audience :: Science/Research", - "Intended Audience :: Developers", - ], - keywords=["OpenJTalk", "Research"], -) +setup(ext_modules=ext_modules, cmdclass={"build_ext": custom_build_ext}) From 5f07318e5fce99ec422ab82e1a692933d8928175 Mon Sep 17 00:00:00 2001 From: sabonerune <102559104+sabonerune@users.noreply.github.com> Date: Wed, 11 Dec 2024 18:59:31 +0900 Subject: [PATCH 2/5] Update pyproject.toml Drop py37. --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index ec208df..c7902dd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,7 +14,7 @@ name = "pyopenjtalk" dynamic = ["version"] description = "A python wrapper for OpenJTalk" readme = "README.md" -requires-python = ">=3.7" +requires-python = ">=3.8" license.file = "LICENSE.md" authors = [{ name = "Ryuichi Yamamoto", email = "zryuichi@gmail.com" }] keywords = ["OpenJTalk", "Research"] From 341b3371f5de7b27f76689d9fe7e273ab3ae4143 Mon Sep 17 00:00:00 2001 From: sabonerune <102559104+sabonerune@users.noreply.github.com> Date: Wed, 11 Dec 2024 18:59:50 +0900 Subject: [PATCH 3/5] Update pyproject.toml Drop py37. Co-authored-by: Ryuichi Yamamoto --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index c7902dd..74885c9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,7 +26,6 @@ classifiers = [ "Programming Language :: Cython", "Programming Language :: Python", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", From dfb2451fcd3ee97cc0ce66f4b531ef21a10e6a91 Mon Sep 17 00:00:00 2001 From: sabonerune <102559104+sabonerune@users.noreply.github.com> Date: Wed, 11 Dec 2024 19:00:12 +0900 Subject: [PATCH 4/5] Update pyproject.toml Drop py37. --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 74885c9..e9c2b40 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [build-system] requires = [ - "setuptools>=61.0.0", - "setuptools_scm<9", + "setuptools>=64", + "setuptools_scm>=8", "cython>=0.28.0", "cmake", "numpy>=1.25.0; python_version>='3.9'", From a8140bf9d0c248bb6c97587f4cea55846991ce39 Mon Sep 17 00:00:00 2001 From: sabonerune <102559104+sabonerune@users.noreply.github.com> Date: Wed, 11 Dec 2024 19:00:28 +0900 Subject: [PATCH 5/5] Update pyproject.toml Drop py37. --- pyproject.toml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index e9c2b40..fe0e1fe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -74,9 +74,8 @@ find.namespaces = false "*" = ["*.pyx", "*.pxd"] [tool.setuptools_scm] -# NOTE: write_to is deprecated, but version_file is not supported in Python 3.7. -write_to = "pyopenjtalk/version.py" -write_to_template = ''' +version_file = "pyopenjtalk/version.py" +version_file_template = ''' __version__ = "{version}" '''