Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

switch to PEP 621 #2860

Merged
merged 15 commits into from
Nov 4, 2023
1 change: 0 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
branch=True
source=trio
omit=
setup.py
agronholm marked this conversation as resolved.
Show resolved Hide resolved
# These are run in subprocesses, but still don't work. We follow
# coverage's documentation to no avail.
*/trio/_core/_tests/test_multierror_scripts/*
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/autodeps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
# The new dependencies may contain a new black version.
# Commit any changes immediately.
python -m pip install -r test-requirements.txt
black setup.py trio
black trio
- name: Commit changes and create automerge PR
env:
GH_TOKEN: ${{ github.token }}
Expand Down
68 changes: 1 addition & 67 deletions setup.py → LONG_DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
from setuptools import find_packages, setup

__version__ = "0.0.0" # Overwritten from _version.py below, needed for linter to identify that this variable is defined.

with open("trio/_version.py", encoding="utf-8") as version_code:
exec(version_code.read())

LONG_DESC = """\
.. image:: https://raw.githubusercontent.com/python-trio/trio/9b0bec646a31e0d0f67b8b6ecc6939726faf3e17/logo/logo-with-background.svg
:width: 200px
:align: right
Expand Down Expand Up @@ -47,7 +39,7 @@
Vital statistics:

* Supported environments: Linux, macOS, or Windows running some kind of Python
3.8-or-better (either CPython or PyPy3 is fine). \\*BSD and illumos likely
3.8-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
Expand All @@ -71,61 +63,3 @@
conduct
<https://trio.readthedocs.io/en/latest/code-of-conduct.html>`_
in all project spaces.
"""

setup(
name="trio",
version=__version__,
description="A friendly Python library for async concurrency and I/O",
long_description=LONG_DESC,
long_description_content_type="text/x-rst",
author="Nathaniel J. Smith",
author_email="[email protected]",
url="https://github.com/python-trio/trio",
license="MIT OR Apache-2.0",
packages=find_packages(),
install_requires=[
# attrs 19.2.0 adds `eq` option to decorators
# attrs 20.1.0 adds @frozen
"attrs >= 20.1.0",
"sortedcontainers",
"idna",
"outcome",
"sniffio >= 1.3.0",
# 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.8",
keywords=["async", "io", "networking", "trio"],
classifiers=[
"Development Status :: 3 - Alpha",
"Framework :: Trio",
"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.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: System :: Networking",
"Typing :: Typed",
],
project_urls={
"Documentation": "https://trio.readthedocs.io/",
"Changelog": "https://trio.readthedocs.io/en/latest/history.html",
},
)
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
include LICENSE LICENSE.MIT LICENSE.APACHE2
include README.rst
include LONG_DESCRIPTION.rst
include CODE_OF_CONDUCT.md CONTRIBUTING.md
include test-requirements.txt
include trio/py.typed
Expand Down
8 changes: 4 additions & 4 deletions check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ echo "::endgroup::"
# autoflake --recursive --in-place .
# pyupgrade --py3-plus $(find . -name "*.py")
echo "::group::Black"
if ! black --check setup.py trio; then
if ! black --check trio; then
echo "* Black found issues" >> "$GITHUB_STEP_SUMMARY"
EXIT_STATUS=1
black --diff setup.py trio
black --diff trio
echo "::endgroup::"
echo "::error:: Black found issues"
else
Expand Down Expand Up @@ -118,8 +118,8 @@ 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
isort setup.py trio
black trio
isort trio
./check.sh

in your local checkout.
Expand Down
6 changes: 3 additions & 3 deletions ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ python -c "import sys, struct, ssl; print('python:', sys.version); print('versio
echo "::endgroup::"

echo "::group::Install dependencies"
python -m pip install -U pip setuptools wheel
python -m pip install -U pip build
python -m pip --version

python setup.py sdist --formats=zip
python -m pip install dist/*.zip
python -m build
python -m pip install dist/*.whl

if [ "$CHECK_FORMATTING" = "1" ]; then
python -m pip install -r test-requirements.txt
Expand Down
4 changes: 2 additions & 2 deletions docs/source/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -316,7 +316,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.)
Expand Down
2 changes: 1 addition & 1 deletion docs/source/releasing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,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
twine upload dist/*

* update version number in the same pull request
Expand Down
1 change: 1 addition & 0 deletions newsfragments/2860.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Moved the metadata into :pep:`621`-compliant :file:`pyproject.toml`.
73 changes: 73 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,76 @@
[build-system]
requires = ["setuptools >= 64"]
build-backend = "setuptools.build_meta"

[project]
name = "trio"
description = "A friendly Python library for async concurrency and I/O"
authors = [{name = "Nathaniel J. Smith", email = "[email protected]"}]
agronholm marked this conversation as resolved.
Show resolved Hide resolved
license = {text = "MIT OR Apache-2.0"}
keywords = [
"async",
"io",
"networking",
"trio",
]
classifiers = [
"Development Status :: 3 - Alpha",
agronholm marked this conversation as resolved.
Show resolved Hide resolved
"Framework :: Trio",
"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.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: System :: Networking",
"Typing :: Typed",
]
requires-python = ">=3.8"
dependencies = [
# attrs 19.2.0 adds `eq` option to decorators
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need to keep this comment about some older version boundary?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments were in the original setup.py so I maintained them in the pyproject.toml

# attrs 20.1.0 adds @frozen
"attrs >= 20.1.0",
"sortedcontainers",
"idna",
"outcome",
"sniffio >= 1.3.0",
# cffi 1.12 adds from_buffer(require_writable=True) and ffi.release()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same: the older version comment is probably unnecessary.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments were in the original setup.py so I maintained them in the pyproject.toml

# 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'",
agronholm marked this conversation as resolved.
Show resolved Hide resolved
]
dynamic = ["version"]

[project.readme]
file = "LONG_DESCRIPTION.rst"
content-type = "text/x-rst"

[project.urls]
Homepage = "https://github.com/python-trio/trio"
Documentation = "https://trio.readthedocs.io/"
Changelog = "https://trio.readthedocs.io/en/latest/history.html"

[tool.setuptools]
# 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

[tool.setuptools.packages]
find = {namespaces = false}

[tool.setuptools.dynamic]
version = {attr = "trio._version.__version__"}
agronholm marked this conversation as resolved.
Show resolved Hide resolved

[tool.black]
target-version = ['py38']
force-exclude = '''
Expand Down
3 changes: 2 additions & 1 deletion trio/_core/_tests/test_multierror_scripts/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# 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 setuptools' find = {namespaces = false} into
# actually installing the things.
2 changes: 1 addition & 1 deletion trio/_version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# This file is imported from __init__.py and exec'd from setup.py
# This file is imported from __init__.py and parsed by setuptools

__version__ = "0.23.1+dev"