From 2b7390234254c2e5488d9cf676803a58eec1508b Mon Sep 17 00:00:00 2001 From: KOLANICH Date: Tue, 18 Oct 2022 20:42:48 +0300 Subject: [PATCH 1/3] Moved the metadata into machine-readable `setup.cfg`. --- .readthedocs.yml | 2 + check.sh | 6 +- ci.sh | 6 +- docs-requirements.in | 1 + docs-requirements.txt | 2 + docs/source/.conf.py.kate-swp | Bin 0 -> 127 bytes docs/source/contributing.rst | 6 +- docs/source/releasing.rst | 8 +- pyproject.toml | 4 + setup.cfg | 49 +++++++ setup.py | 135 +++--------------- .../tests/test_multierror_scripts/__init__.py | 2 +- 12 files changed, 92 insertions(+), 129 deletions(-) create mode 100644 docs/source/.conf.py.kate-swp create mode 100644 setup.cfg diff --git a/.readthedocs.yml b/.readthedocs.yml index 2a32d6c9b5..7720da4241 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -8,6 +8,8 @@ formats: python: version: 3.7 install: + - method: pip + path: . - requirements: docs-requirements.txt sphinx: diff --git a/check.sh b/check.sh index 57f1e2db40..da37097b78 100755 --- a/check.sh +++ b/check.sh @@ -13,9 +13,9 @@ python ./trio/_tools/gen_exports.py --test \ # see https://forum.bors.tech/t/pre-test-and-pre-merge-hooks/322) # autoflake --recursive --in-place . # pyupgrade --py3-plus $(find . -name "*.py") -if ! black --check setup.py trio; then +if ! black --check trio; then EXIT_STATUS=1 - black --diff setup.py trio + black --diff trio fi # Run flake8 without pycodestyle and import-related errors @@ -38,7 +38,7 @@ Problems were found by static analysis (listed above). To fix formatting and see remaining errors, run pip install -r test-requirements.txt - black setup.py trio + black trio ./check.sh in your local checkout. diff --git a/ci.sh b/ci.sh index d4f9df3a94..7ea015d77c 100755 --- a/ci.sh +++ b/ci.sh @@ -66,11 +66,11 @@ fi python -c "import sys, struct, ssl; print('#' * 70); print('python:', sys.version); print('version_info:', sys.version_info); print('bits:', struct.calcsize('P') * 8); print('openssl:', ssl.OPENSSL_VERSION, ssl.OPENSSL_VERSION_INFO); print('#' * 70)" -python -m pip install -U pip setuptools wheel +python -m pip install -U pip setuptools setuptools_scm wheel build python -m pip --version -python setup.py sdist --formats=zip -python -m pip install dist/*.zip +python -m build -nsx . +python -m pip install dist/*.tar.gz if [ "$CHECK_FORMATTING" = "1" ]; then python -m pip install -r test-requirements.txt diff --git a/docs-requirements.in b/docs-requirements.in index 7d6abc0033..8b1f1181d9 100644 --- a/docs-requirements.in +++ b/docs-requirements.in @@ -6,6 +6,7 @@ jinja2 < 3.1 sphinx_rtd_theme sphinxcontrib-trio towncrier +setuptools-scm # Trio's own dependencies cffi; os_name == "nt" diff --git a/docs-requirements.txt b/docs-requirements.txt index 6bdd2c3051..5d92b8c835 100644 --- a/docs-requirements.txt +++ b/docs-requirements.txt @@ -59,6 +59,8 @@ pytz==2022.4 # via babel requests==2.28.1 # via sphinx +setuptools-scm==7.0.5 + # via setuptools-scm sniffio==1.3.0 # via -r docs-requirements.in snowballstemmer==2.2.0 diff --git a/docs/source/.conf.py.kate-swp b/docs/source/.conf.py.kate-swp new file mode 100644 index 0000000000000000000000000000000000000000..95ba7e19030dee1f07e5ad7046c927ce31fd7957 GIT binary patch literal 127 zcmZQzU=Z?7EJ;-eE>A2_aLdd|RWQ;sU|?VnsffHgPx4-X-`T3P_eYs8JBP4L_YV#S l%BTP_rzen51!53j;^cG<4gxaZ0?4wAXp)SsU{k;+m6q^75 literal 0 HcmV?d00001 diff --git a/docs/source/contributing.rst b/docs/source/contributing.rst index 1a97dc9f44..78e5a27f18 100644 --- a/docs/source/contributing.rst +++ b/docs/source/contributing.rst @@ -133,7 +133,7 @@ in separate sections below: adding a test to make sure it stays fixed. * :ref:`pull-request-formatting`: If you changed Python code, then did - you run ``black setup.py trio``? (Or for other packages, replace + you run ``black trio``? (Or for other packages, replace ``trio`` with the package name.) * :ref:`pull-request-release-notes`: If your change affects @@ -292,7 +292,7 @@ sloppy as you like about whitespace; and then before you commit, just run:: pip install -U black - black setup.py trio + black trio to fix it up. (And don't worry if you forget – when you submit a pull request then we'll automatically check and remind you.) Hopefully this @@ -305,7 +305,7 @@ you can can add ``# fmt: off`` and ``# fmt: on`` comments. If you want to see what changes black will make, you can use:: - black --diff setup.py trio + black --diff trio (``--diff`` displays a diff, versus the default mode which fixes files in-place.) diff --git a/docs/source/releasing.rst b/docs/source/releasing.rst index 27cee864c0..32192402f5 100644 --- a/docs/source/releasing.rst +++ b/docs/source/releasing.rst @@ -21,7 +21,11 @@ Things to do for releasing: + bump version number - - increment as per Semantic Versioning rules + - increment as per Semantic Versioning rules in + + - in the metadata file (``setup.cfg``) + + - in ``trio/_version.py`` - remove ``+dev`` tag from version number @@ -44,7 +48,7 @@ Things to do for releasing: * push to PyPI:: git clean -xdf # maybe run 'git clean -xdn' first to see what it will delete - python3 setup.py sdist bdist_wheel + python3 -m build -ws twine upload dist/* * update version number in the same pull request diff --git a/pyproject.toml b/pyproject.toml index 944440661f..e2f0c7a38f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,7 @@ +[build-system] +requires = ["setuptools>=42.2",] +build-backend = "setuptools.build_meta" + [tool.black] target-version = ['py37'] diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000000..a3012a8f27 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,49 @@ +[metadata] +name = trio +version = 0.22.0 +author = Nathaniel J. Smith +author_email = njs@pobox.com +license = MIT OR Apache-2.0 +description = A friendly Python library for async concurrency and I/O +keywords = async, io, networking, trio +url = https://github.com/python-trio/trio +long_description = file: README.rst +classifiers = + Development Status :: 3 - Alpha + Intended Audience :: Developers + License :: OSI Approved :: MIT License + License :: OSI Approved :: Apache Software License + Operating System :: POSIX :: Linux + Operating System :: MacOS :: MacOS X + Operating System :: POSIX :: BSD + Operating System :: Microsoft :: Windows + Programming Language :: Python :: Implementation :: CPython + Programming Language :: Python :: Implementation :: PyPy + Programming Language :: Python :: 3 :: Only + Programming Language :: Python :: 3.7 + Programming Language :: Python :: 3.8 + Programming Language :: Python :: 3.9 + Programming Language :: Python :: 3.10 + Programming Language :: Python :: 3.11 + Topic :: System :: Networking + Framework :: Trio + +[options] +packages = find: +install_requires = + attrs >= 19.2.0 + sortedcontainers + async_generator >= 1.9 + idna + outcome + sniffio + # cffi 1.12 adds from_buffer(require_writable=True) and ffi.release() + # cffi 1.14 fixes memory leak inside ffi.getwinerror() + # cffi is required on Windows, except on PyPy where it is built-in + cffi>=1.14; os_name == 'nt' and implementation_name != 'pypy' + exceptiongroup >= 1.0.0rc9; python_version < '3.11' +setup_requires = + setuptools>=42.2 + setuptools_scm[toml]>=3.4.3 +include_package_data = True +python_requires = >=3.7 diff --git a/setup.py b/setup.py index 00ba270764..3fd4c3f2de 100644 --- a/setup.py +++ b/setup.py @@ -1,119 +1,20 @@ -from setuptools import setup, find_packages - -exec(open("trio/_version.py", encoding="utf-8").read()) - -LONG_DESC = """\ -.. image:: https://raw.githubusercontent.com/python-trio/trio/9b0bec646a31e0d0f67b8b6ecc6939726faf3e17/logo/logo-with-background.svg - :width: 200px - :align: right - -The Trio project's goal is to produce a production-quality, `permissively -licensed `__, -async/await-native I/O library for Python. Like all async libraries, -its main purpose is to help you write programs that do **multiple -things at the same time** with **parallelized I/O**. A web spider that -wants to fetch lots of pages in parallel, a web server that needs to -juggle lots of downloads and websocket connections at the same time, a -process supervisor monitoring multiple subprocesses... that sort of -thing. Compared to other libraries, Trio attempts to distinguish -itself with an obsessive focus on **usability** and -**correctness**. Concurrency is complicated; we try to make it *easy* -to get things *right*. - -Trio was built from the ground up to take advantage of the `latest -Python features `__, and -draws inspiration from `many sources -`__, in -particular Dave Beazley's `Curio `__. -The resulting design is radically simpler than older competitors like -`asyncio `__ and -`Twisted `__, yet just as capable. Trio is -the Python I/O library I always wanted; I find it makes building -I/O-oriented programs easier, less error-prone, and just plain more -fun. `Perhaps you'll find the same -`__. - -This project is young and still somewhat experimental: the overall -design is solid and the existing features are fully tested and -documented, but you may encounter missing functionality or rough -edges. We *do* encourage you do use it, but you should `read and -subscribe to issue #1 -`__ to get warning and a -chance to give feedback about any compatibility-breaking changes. - -Vital statistics: - -* Supported environments: Linux, macOS, or Windows running some kind of Python - 3.7-or-better (either CPython or PyPy3 is fine). \\*BSD and illumos likely - work too, but are not tested. - -* Install: ``python3 -m pip install -U trio`` (or on Windows, maybe - ``py -3 -m pip install -U trio``). No compiler needed. - -* Tutorial and reference manual: https://trio.readthedocs.io - -* Bug tracker and source code: https://github.com/python-trio/trio - -* Real-time chat: https://gitter.im/python-trio/general - -* Discussion forum: https://trio.discourse.group - -* License: MIT or Apache 2, your choice - -* Contributor guide: https://trio.readthedocs.io/en/latest/contributing.html - -* Code of conduct: Contributors are requested to follow our `code of - conduct - `_ - in all project spaces. +import inspect +import sys +from warnings import warn + +from setuptools import setup + +if len(inspect.stack()) == 1: + warn( + """ +======================================== +Unsupported building/installation method +======================================== +This version of trio has dropped support for using `python setup.py ...`. +`setup.py` will be removed in future. +Please use `python -m build` (or any other PEP 517 build backend) and then install the built wheel with `pip` instead. """ + ) -setup( - name="trio", - version=__version__, - description="A friendly Python library for async concurrency and I/O", - long_description=LONG_DESC, - author="Nathaniel J. Smith", - author_email="njs@pobox.com", - url="https://github.com/python-trio/trio", - license="MIT OR Apache-2.0", - packages=find_packages(), - install_requires=[ - "attrs >= 19.2.0", # for eq - "sortedcontainers", - "async_generator >= 1.9", - "idna", - "outcome", - "sniffio", - # cffi 1.12 adds from_buffer(require_writable=True) and ffi.release() - # cffi 1.14 fixes memory leak inside ffi.getwinerror() - # cffi is required on Windows, except on PyPy where it is built-in - "cffi>=1.14; os_name == 'nt' and implementation_name != 'pypy'", - "exceptiongroup >= 1.0.0rc9; python_version < '3.11'", - ], - # This means, just install *everything* you see under trio/, even if it - # doesn't look like a source file, so long as it appears in MANIFEST.in: - include_package_data=True, - python_requires=">=3.7", - keywords=["async", "io", "networking", "trio"], - classifiers=[ - "Development Status :: 3 - Alpha", - "Intended Audience :: Developers", - "License :: OSI Approved :: MIT License", - "License :: OSI Approved :: Apache Software License", - "Operating System :: POSIX :: Linux", - "Operating System :: MacOS :: MacOS X", - "Operating System :: POSIX :: BSD", - "Operating System :: Microsoft :: Windows", - "Programming Language :: Python :: Implementation :: CPython", - "Programming Language :: Python :: Implementation :: PyPy", - "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Topic :: System :: Networking", - "Framework :: Trio", - ], -) +if __name__ == "__main__": + setup() diff --git a/trio/_core/tests/test_multierror_scripts/__init__.py b/trio/_core/tests/test_multierror_scripts/__init__.py index a1f6cb598d..0314a2545b 100644 --- a/trio/_core/tests/test_multierror_scripts/__init__.py +++ b/trio/_core/tests/test_multierror_scripts/__init__.py @@ -1,2 +1,2 @@ # This isn't really a package, everything in here is a standalone script. This -# __init__.py is just to fool setup.py into actually installing the things. +# __init__.py is just to fool the build backend used into actually installing the things. From 7d9f2b8176eba0e98f56d154fff7ff8fa5bd0cdf Mon Sep 17 00:00:00 2001 From: KOLANICH Date: Tue, 18 Oct 2022 20:55:40 +0300 Subject: [PATCH 2/3] Moved the metadata from `setup.cfg` into `PEP 621`-compliant `pyproject.toml`. --- newsfragments/2449.feature.rst | 1 + pyproject.toml | 52 +++++++++++++++++++++++++++++++++- setup.cfg | 49 -------------------------------- 3 files changed, 52 insertions(+), 50 deletions(-) create mode 100644 newsfragments/2449.feature.rst delete mode 100644 setup.cfg diff --git a/newsfragments/2449.feature.rst b/newsfragments/2449.feature.rst new file mode 100644 index 0000000000..508e13b355 --- /dev/null +++ b/newsfragments/2449.feature.rst @@ -0,0 +1 @@ +Moved the metadata into ``PEP 621``-compliant ``pyproject.toml``. diff --git a/pyproject.toml b/pyproject.toml index e2f0c7a38f..c29b8ac8ac 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,57 @@ [build-system] -requires = ["setuptools>=42.2",] +requires = ["setuptools>=61.2"] build-backend = "setuptools.build_meta" +[project] +name = "trio" +version = "0.22.0" +authors = [{name = "Nathaniel J. Smith", email = "njs@pobox.com"}] +license = {text = "MIT OR Apache-2.0"} +description = "A friendly Python library for async concurrency and I/O" +readme = "README.rst" +keywords = ["async", "io", "networking", "trio"] +classifiers = [ + "Development Status :: 3 - Alpha", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "License :: OSI Approved :: Apache Software License", + "Operating System :: POSIX :: Linux", + "Operating System :: MacOS :: MacOS X", + "Operating System :: POSIX :: BSD", + "Operating System :: Microsoft :: Windows", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Topic :: System :: Networking", + "Framework :: Trio", +] +urls = {Homepage = "https://github.com/python-trio/trio"} +requires-python = ">=3.7" +dependencies = [ + "attrs >= 19.2.0", + "sortedcontainers", + "async_generator >= 1.9", + "idna", + "outcome", + "sniffio", + # cffi 1.12 adds from_buffer(require_writable=True) and ffi.release() + # cffi 1.14 fixes memory leak inside ffi.getwinerror() + # cffi is required on Windows, except on PyPy where it is built-in + "cffi>=1.14; os_name == 'nt' and implementation_name != 'pypy'", + "exceptiongroup >= 1.0.0rc9; python_version < '3.11'", +] + +[tool.setuptools] +include-package-data = true + +[tool.setuptools.packages] +find = {namespaces = false} + [tool.black] target-version = ['py37'] diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index a3012a8f27..0000000000 --- a/setup.cfg +++ /dev/null @@ -1,49 +0,0 @@ -[metadata] -name = trio -version = 0.22.0 -author = Nathaniel J. Smith -author_email = njs@pobox.com -license = MIT OR Apache-2.0 -description = A friendly Python library for async concurrency and I/O -keywords = async, io, networking, trio -url = https://github.com/python-trio/trio -long_description = file: README.rst -classifiers = - Development Status :: 3 - Alpha - Intended Audience :: Developers - License :: OSI Approved :: MIT License - License :: OSI Approved :: Apache Software License - Operating System :: POSIX :: Linux - Operating System :: MacOS :: MacOS X - Operating System :: POSIX :: BSD - Operating System :: Microsoft :: Windows - Programming Language :: Python :: Implementation :: CPython - Programming Language :: Python :: Implementation :: PyPy - Programming Language :: Python :: 3 :: Only - Programming Language :: Python :: 3.7 - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 - Programming Language :: Python :: 3.10 - Programming Language :: Python :: 3.11 - Topic :: System :: Networking - Framework :: Trio - -[options] -packages = find: -install_requires = - attrs >= 19.2.0 - sortedcontainers - async_generator >= 1.9 - idna - outcome - sniffio - # cffi 1.12 adds from_buffer(require_writable=True) and ffi.release() - # cffi 1.14 fixes memory leak inside ffi.getwinerror() - # cffi is required on Windows, except on PyPy where it is built-in - cffi>=1.14; os_name == 'nt' and implementation_name != 'pypy' - exceptiongroup >= 1.0.0rc9; python_version < '3.11' -setup_requires = - setuptools>=42.2 - setuptools_scm[toml]>=3.4.3 -include_package_data = True -python_requires = >=3.7 From c9a634302786896d4ade5d388e0e23bf38f2fc00 Mon Sep 17 00:00:00 2001 From: KOLANICH Date: Tue, 25 Oct 2022 12:09:54 +0300 Subject: [PATCH 3/3] Changed the build backend to `hatchling`. Ones who want to use `setuptools` can change `build-system` section of `pyproject.toml`, the specific config for it was kept. --- ci.sh | 2 +- pyproject.toml | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/ci.sh b/ci.sh index 7ea015d77c..ba54df80ca 100755 --- a/ci.sh +++ b/ci.sh @@ -66,7 +66,7 @@ fi python -c "import sys, struct, ssl; print('#' * 70); print('python:', sys.version); print('version_info:', sys.version_info); print('bits:', struct.calcsize('P') * 8); print('openssl:', ssl.OPENSSL_VERSION, ssl.OPENSSL_VERSION_INFO); print('#' * 70)" -python -m pip install -U pip setuptools setuptools_scm wheel build +python -m pip install -U pip hatchling build python -m pip --version python -m build -nsx . diff --git a/pyproject.toml b/pyproject.toml index c29b8ac8ac..be345ee9f1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,11 @@ [build-system] -requires = ["setuptools>=61.2"] -build-backend = "setuptools.build_meta" +requires = ["hatchling>=1.8.0"] +build-backend = "hatchling.build" +#requires = ["setuptools>=61.2", "setuptools_scm[toml]>=3.4.3"] +#build-backend = "setuptools.build_meta" [project] name = "trio" -version = "0.22.0" authors = [{name = "Nathaniel J. Smith", email = "njs@pobox.com"}] license = {text = "MIT OR Apache-2.0"} description = "A friendly Python library for async concurrency and I/O" @@ -45,6 +46,10 @@ dependencies = [ "cffi>=1.14; os_name == 'nt' and implementation_name != 'pypy'", "exceptiongroup >= 1.0.0rc9; python_version < '3.11'", ] +dynamic = ["version"] + +[tool.hatch.version] +path = "trio/_version.py" [tool.setuptools] include-package-data = true @@ -52,6 +57,10 @@ include-package-data = true [tool.setuptools.packages] find = {namespaces = false} +[tool.setuptools_scm] +write_to = "trio/_version.py" +write_to_template = "__version__ = \"{version}\"\n" + [tool.black] target-version = ['py37']