From 71f220f554ab52ac4fdde1b9c9736f77b463f8cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Fri, 5 Jan 2024 08:51:41 -0500 Subject: [PATCH] Migrate setuptools configuration inside pyproject.toml (#198) * Migrate setuptools configuration inside pyproject.toml * Remove mention of setup.py commands which are to be avoided * Use version of setuptools and setuptools_scm recommended by setuptools_scm * setuptools_scm 8.0.0 dropped support for EOL Python 3.7. Use latest from setuptools_scm 7 release * Use `python -m build` in tox commands for packaging * Use only `python -m build` As recommended in https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/ * Use only `python -m build` for Travis configuration --- .github/workflows/publish.yml | 2 +- .travis.yml | 4 +-- pyproject.toml | 61 ++++++++++++++++++++++++++++------- setup.cfg | 36 --------------------- setup.py | 7 ---- tox.ini | 10 +++--- 6 files changed, 57 insertions(+), 63 deletions(-) delete mode 100644 setup.cfg diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 9efb3101..095df55d 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -23,7 +23,7 @@ jobs: run: python -m pip install build --user - name: Build a binary wheel and a source tarball - run: python -m build --sdist --wheel --outdir dist/ . + run: python -m build - name: Publish distribution to GitHub uses: softprops/action-gh-release@v1 diff --git a/.travis.yml b/.travis.yml index d56849bf..83493e5b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,9 +29,9 @@ jobs: - stage: publish to test.pypi.org install: - - pip install --upgrade setuptools wheel twine + - pip install --upgrade build twine script: - - python setup.py sdist bdist_wheel + - python -m build - python -m twine upload --repository-url https://test.pypi.org/legacy/ dist/* - stage: verify diff --git a/pyproject.toml b/pyproject.toml index e7b5d4b0..2a73729b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,17 +1,56 @@ [build-system] -requires = [ - "setuptools>=44", - "wheel", - "setuptools_scm[toml]>=3.4.3" -] +requires = ["setuptools>=64", "setuptools_scm>=7.1"] build-backend = "setuptools.build_meta" +[project] +name = "ctypesgen" +description = "Python wrapper generator for ctypes" +license = { text = "BSD-2-Clause" } +classifiers = [ + "License :: OSI Approved :: BSD License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3 :: Only", + "Development Status :: 4 - Beta", + "Operating System :: OS Independent", + "Intended Audience :: Developers", + "Topic :: Software Development :: Code Generators", + "Topic :: Software Development :: Pre-processors", + "Topic :: Software Development :: Build Tools", + "Environment :: Console", +] +dynamic = ["readme", "version"] +requires-python = ">=3.7" + +[project.urls] +Homepage = "https://github.com/ctypesgen/ctypesgen" +Repository = "https://github.com/ctypesgen/ctypesgen.git" +Issues = "https://github.com/ctypesgen/ctypesgen/issues" +Changelog = "https://github.com/ctypesgen/ctypesgen/blob/master/CHANGELOG.md" + +[project.scripts] +ctypesgen = "ctypesgen.__main__:main" + +[tool.setuptools] +package-dir = {} +include-package-data = true + +[tool.setuptools.packages.find] +exclude = ["tests*"] +namespaces = false + +[tool.setuptools.dynamic.readme] +file = ["README.md", "LICENSE", "CHANGELOG.md"] +content-type = "text/markdown" + [tool.setuptools_scm] - write_to = "ctypesgen/VERSION" - write_to_template = "{version}" +write_to = "ctypesgen/VERSION" +write_to_template = "{version}" [tool.black] - line-length = 100 - exclude='.*tab.py|ctypesgen/parser/cgrammar.py|ctypesgen/parser/lex.py|ctypesgen/parser/yacc.py' - target-version = [ "py37", "py38", "py39"] - +line-length = 100 +exclude = '.*tab.py|ctypesgen/parser/cgrammar.py|ctypesgen/parser/lex.py|ctypesgen/parser/yacc.py' +target-version = ["py37", "py38", "py39"] diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index d69bb9b3..00000000 --- a/setup.cfg +++ /dev/null @@ -1,36 +0,0 @@ -[metadata] -name = ctypesgen -license = BSD-2-Clause -description = Python wrapper generator for ctypes -url = https://github.com/ctypesgen/ctypesgen -long_description = file: README.md, LICENSE, CHANGELOG.md -long_description_content_type = text/markdown -classifiers = - License :: OSI Approved :: BSD License - Programming Language :: Python :: 3 - Programming Language :: Python :: 3.7 - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 - Programming Language :: Python :: 3.10 - Programming Language :: Python :: 3 :: Only - Development Status :: 4 - Beta - Operating System :: OS Independent - Intended Audience :: Developers - Topic :: Software Development :: Code Generators - Topic :: Software Development :: Pre-processors - Topic :: Software Development :: Build Tools - Environment :: Console - -[options] -packages = find: -package_dir = -include_package_data = True -setup_requires = setuptools>=44; wheel; toml; setuptools_scm>=3.4.3 -python_requires = >=3.7 - -[options.packages.find] -exclude = - tests* - -[options.entry_points] -console_scripts = ctypesgen = ctypesgen.__main__:main diff --git a/setup.py b/setup.py index 339b15f4..6012477f 100755 --- a/setup.py +++ b/setup.py @@ -1,12 +1,5 @@ #!/usr/bin/env python3 -"""Examples: - - setup.py sdist - setup.py bdist_wininst - -""" - from setuptools import setup if __name__ == "__main__": diff --git a/tox.ini b/tox.ini index fd6105ba..61dfcda5 100644 --- a/tox.ini +++ b/tox.ini @@ -19,20 +19,18 @@ commands = [testenv:package] deps = - six + build twine - wheel basepython = python3.7 commands = - python setup.py bdist_wheel --universal + python -m build twine check dist/*.whl [testenv:upload] deps = - six + build twine - wheel basepython = python3.7 commands = - python setup.py bdist_wheel --universal + python -m build twine upload dist/*.whl