Skip to content

Commit

Permalink
BLD: Declarative config
Browse files Browse the repository at this point in the history
Move most of the configuration from setup.py to pyproject.toml.
  • Loading branch information
sabonerune committed Oct 21, 2024
1 parent a3e2115 commit c362dae
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 120 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -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/**
77 changes: 74 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,86 @@
[build-system]
requires = [
"setuptools>=66.1.0; python_version>='3.12'",
"setuptools>=60.0.0; sys.platform=='win32'",
"setuptools<v60.0; python_version<'3.12' and sys.platform!='win32'",
"setuptools>=61.0.0",
"setuptools_scm<9",
"cython>=0.28.0",
"cmake",
"numpy>=1.25.0; python_version>='3.9'",
"oldest-supported-numpy; python_version<'3.9'",
]
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 = "[email protected]" }]
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"

Expand Down
2 changes: 1 addition & 1 deletion release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion setup.cfg

This file was deleted.

118 changes: 5 additions & 113 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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="[email protected]",
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})

0 comments on commit c362dae

Please sign in to comment.