From 02272e5cd928926ec0b50dfdbcdbe58ea648f81e Mon Sep 17 00:00:00 2001 From: Ofek Lev Date: Sat, 10 Sep 2022 22:03:26 -0400 Subject: [PATCH 1/7] Update package metadata --- .github/workflows/test.yaml | 4 +- .readthedocs.yml | 2 +- MANIFEST.in | 93 ---------- admin/twisted.spec | 14 +- docs/conf.py | 2 +- docs/development/coding-standard.rst | 15 +- docs/installation/howto/optional.rst | 8 +- pyproject.toml | 221 +++++++++++++++++++++++- setup.cfg | 160 ----------------- setup.py | 25 --- src/twisted/newsfragments/11655.removal | 1 + tox.ini | 26 ++- 12 files changed, 250 insertions(+), 321 deletions(-) delete mode 100644 MANIFEST.in delete mode 100755 setup.py create mode 100644 src/twisted/newsfragments/11655.removal diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index d2bef0046c3..13242933702 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -164,7 +164,7 @@ jobs: - python-version: '3.7' tox-env: 'alldeps-gtk-withcov-posix' trial-target: 'twisted.internet.test' - platform-deps: 'gtk_platform' + platform-deps: 'gtk-platform' tox-wrapper: 'xvfb-run -a' job-name: 'gtk-tests' @@ -210,7 +210,7 @@ jobs: # Make sure the matrix is defined in such a way that this is triggered # only on Linux. - name: Install GTK system deps - if: matrix.platform-deps == 'gtk_platform' + if: matrix.platform-deps == 'gtk-platform' run: | # *-dev dependencies are for pygobject # https://gitlab.gnome.org/GNOME/pygobject/-/blob/3.42.0/setup.py#L129-L134 diff --git a/.readthedocs.yml b/.readthedocs.yml index 2fb134bb1e9..1db818e369e 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -26,4 +26,4 @@ python: - method: pip path: . extra_requirements: - - dev_release + - dev-release diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 99702ad3d3f..00000000000 --- a/MANIFEST.in +++ /dev/null @@ -1,93 +0,0 @@ -# This file dictates what goes into a sdist tarball. -# As a release tarball, we want to include: -# - All of the library code. -# - All the useful documentation (but not the super historic stuff) -# - All of the test files, so that the tests can be run on an installed copy. -# We do not want to include: -# - Release management files (e.g. topfiles) -# - Things only useful when running from a source checkout - -# Do not include the old topfiles, or news fragments -recursive-exclude src/twisted *.misc *.bugfix *.doc *.feature *.removal -recursive-exclude src/twisted NEWS README newsfragments -exclude src/twisted/topfiles/CREDITS src/twisted/topfiles/ChangeLog.Old - -# Include NEWS, READMEs, etc -recursive-include docs README -include NEWS.rst README.rst INSTALL.rst CONTRIBUTING.md LICENSE code_of_conduct.md - -# Exclude admin scripts and things only useful when running from a source checkout -exclude codecov.yml -exclude .coveralls.yml -exclude .git-blame-ignore-revs -exclude .readthedocs.yml -exclude .pre-commit-config.yaml -recursive-exclude .circleci * -exclude azure-pipelines -recursive-exclude azure-pipelines * -prune bin -prune admin -prune .github -prune docs/_build - - -# Include marker indicating that we ship type annotations (PEP 561) -include src/twisted/py.typed - -# Include test-running utilities for downstream packagers -include mypy.ini tox.ini .coveragerc - -# Include our docs templates -recursive-include src/twisted/python/_pydoctortemplates *.html - -# Include all modules, even on a Python we're not installing for -recursive-include src/twisted *.py - -# Some tests stuff -recursive-include src/twisted *.pem -recursive-include src/twisted/test *.pem.* -include src/twisted/internet/test/fake_CAs/* -include src/twisted/mail/test/rfc822.message - -# Some extras -recursive-include src/twisted *.glade *.pxi *.h *.c *.bat *.g *.pyx *.zsh *.txt - -# Docs -include docs/fun/lightbulb -recursive-include docs/historic/Quotes * -recursive-include docs *.1 -recursive-include docs *.Quotes -recursive-include docs *.bat -recursive-include docs *.bmp -recursive-include docs *.com -recursive-include docs *.conf -recursive-include docs *.css -recursive-include docs *.dia -recursive-include docs *.gif -recursive-include docs *.glade -recursive-include docs *.html -recursive-include docs *.ico -recursive-include docs *.nib -recursive-include docs *.pem -recursive-include docs *.placeholder -recursive-include docs *.png -recursive-include docs *.py -recursive-include docs *.rpy -recursive-include docs *.rst -recursive-include docs *.rtl -recursive-include docs *.service -recursive-include docs *.socket -recursive-include docs *.svg -recursive-include docs *.tac -recursive-include docs *.tidyrc -recursive-include docs *.tpl -recursive-include docs *.txt -recursive-include docs *.users -recursive-include docs *.xml -recursive-include docs Makefile -recursive-include docs/_static/js *.js -prune docs/_build - -# Don't have the real old historic docs -exclude docs/historic/2003 -recursive-exclude docs/historic/2003 * diff --git a/admin/twisted.spec b/admin/twisted.spec index ef0f21e9f89..9be64a849a1 100644 --- a/admin/twisted.spec +++ b/admin/twisted.spec @@ -14,12 +14,13 @@ Group: System/Libraries URL: http://www.twistedmatrix.com/ Requires: python >= %{py_libver} BuildRequires: python-devel +BuildRequires: pyproject-rpm-macros >= 1.2.0 BuildRoot: %{_tmppath}/%{name}-buildroot Prefix: %{_prefix} %description Twisted is an event-based framework for internet applications. It includes a -web server, a telnet server, a chat server, a news server, a generic client +web server, a telnet server, a chat server, a news server, a generic client and server for remote object access, and APIs for creating new protocols and services. Twisted supports integration of the Tk, GTK+, Qt or wxPython event loop with its main event loop. The Win32 event loop is also supported, as is @@ -37,15 +38,8 @@ Install Twisted-doc if you need the API documentation and example programs. %build %install -[ -n "$RPM_BUILD_ROOT" -a "$RPM_BUILD_ROOT" != / ] && rm -rf "$RPM_BUILD_ROOT" -mkdir -p "$RPM_BUILD_ROOT" - -python setup.py install --optimize=2 --record=installed-files \ - --root="$RPM_BUILD_ROOT" - -# install man pages -mkdir -p "$RPM_BUILD_ROOT"/%{_mandir}/man1/ -cp -a doc/man/*.1 "$RPM_BUILD_ROOT"/%{_mandir}/man1/ +%pyproject_install +%pyproject_save_files %{srcname} %clean [ -n "$RPM_BUILD_ROOT" -a "$RPM_BUILD_ROOT" != / ] && rm -rf "$RPM_BUILD_ROOT" diff --git a/docs/conf.py b/docs/conf.py index 8e7853e7936..7bd45ad3431 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -28,7 +28,7 @@ # -- General configuration ------------------------------------------------ -# See setup.cfg for the Sphinx version required to build the documentation. +# See pyproject.toml for the Sphinx version required to build the documentation. # needs_sphinx is not use to avoid duplication and getting these values # out of sync. diff --git a/docs/development/coding-standard.rst b/docs/development/coding-standard.rst index 75b0d51484e..69bf7cdfd61 100644 --- a/docs/development/coding-standard.rst +++ b/docs/development/coding-standard.rst @@ -393,15 +393,14 @@ This makes the script more portable but note that it is not a foolproof method. Always make sure that ``/usr/bin/env`` exists or use a softlink/symbolic link to point it to the correct path. Python's distutils will rewrite the shebang line upon installation so this policy only covers the source files in version control. -#. For core scripts, add an entry point to ``"console_scripts"`` in ``setup.cfg``: +#. For core scripts, add an entry point to ``[project.scripts]`` in ``pyproject.toml``: - .. code-block:: cfg + .. code-block:: toml - [options.entry_points] - console_scripts = - ... - twistd = twisted.scripts.twistd:run - yourmodule = twisted.scripts.yourmodule:run + [project.scripts] + ... + twistd = "twisted.scripts.twistd:run" + yourmodule = "twisted.scripts.yourmodule:run" #. And end with: @@ -416,7 +415,7 @@ Python's distutils will rewrite the shebang line upon installation so this polic This will ensure that your program will have a proper ``console_scripts`` entry point, which -``setup.py`` will use to generate a console script which will work correctly for users of +``pyproject.toml`` will use to generate a console script which will work correctly for users of Git, Windows releases and Debian packages. diff --git a/docs/installation/howto/optional.rst b/docs/installation/howto/optional.rst index cea47b9bb0a..1cb7e5ec0fe 100644 --- a/docs/installation/howto/optional.rst +++ b/docs/installation/howto/optional.rst @@ -36,17 +36,17 @@ The following optional dependencies are supported: * `pyasn1`_ * `cryptography`_ -* **conch_nacl** - **conch** options and `PyNaCl`_ to support Ed25519 keys on systems with OpenSSL < 1.1.1b. +* **conch-nacl** - **conch** options and `PyNaCl`_ to support Ed25519 keys on systems with OpenSSL < 1.1.1b. * **soap** - the `SOAPpy`_ package to work with SOAP. * **serial** - the `pyserial`_ package to work with serial data. -* **all_non_platform** - installs **tls**, **conch**, **soap**, and **serial** options. +* **all-non-platform** - installs **tls**, **conch**, **soap**, and **serial** options. -* **macos_platform** - **all_non_platform** options and `pyobjc`_ to work with Objective-C apis. +* **macos-platform** - **all-non-platform** options and `pyobjc`_ to work with Objective-C apis. -* **windows_platform** - **all_non_platform** options and `pywin32`_ to work with Windows's apis. +* **windows-platform** - **all-non-platform** options and `pywin32`_ to work with Windows's apis. * **http2** - packages needed for http2 support. diff --git a/pyproject.toml b/pyproject.toml index d81491953a8..4f3497179ea 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,225 @@ [build-system] requires = [ - "setuptools >= 35.0.2", - "wheel >= 0.29.0", + "hatchling", + "hatch-fancy-pypi-readme >= 22.5.0", "incremental >= 21.3.0", ] -build-backend = "setuptools.build_meta" +build-backend = "hatchling.build" + +[project] +name = "Twisted" +dynamic = [ + "version", + "readme", +] +description = "An asynchronous networking framework written in Python" +license = "MIT" +# When updating this value, make sure our CI matrix includes a matching minimum version. +requires-python = ">=3.7.1" +authors = [ + { name = "Twisted Matrix Laboratories", email = "twisted-python@twistedmatrix.com" }, +] +classifiers = [ + "Programming Language :: Python :: 3", + "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", +] +dependencies = [ + "zope.interface >= 4.4.2", + "constantly >= 15.1", + "incremental >= 21.3.0", + "Automat >= 0.8.0", + "hyperlink >= 17.1.1", + "attrs >= 19.2.0", + "typing_extensions >= 3.6.5", + "twisted-iocpsupport >= 1.0.2, <2; platform_system == 'Windows'", +] + +[project.optional-dependencies] +# This is list of minimum dependencies required to run the tests. +# The plan is to remove the `test` extra requirement and skip tests that +# depend on them +# To prevent trunk failures we should pin all dev dependencies to minor +# versions. +# We trust semantic versioning and auto-upgrading to a bugfix release +# should be OK. +test = [ + "cython-test-exception-raiser >= 1.0.2, <2", + "PyHamcrest >= 1.9.0", + "hypothesis ~= 6.0", +] + +# List of dependencies required to build the documentation and test the +# release scripts and process. +dev-release = [ + "towncrier ~= 22.8", + "pydoctor ~= 22.7.0", + "sphinx-rtd-theme ~= 0.5", + "readthedocs-sphinx-ext ~= 2.1", + "sphinx >= 4.1.2, <6", +] + +# All the extra tools used to help with the development process. +dev = [ + "twisted[dev-release]", + "pyflakes ~= 2.2", + # TODO: support python-subunit in py3.10 https://twistedmatrix.com/trac/ticket/10115 + "python-subunit ~= 1.4; python_version < '3.10'", + "twistedchecker ~= 0.7", + "coverage >= 6b1, <7", +] + +tls = [ + "pyopenssl >= 21.0.0", + # service_identity 18.1.0 added support for validating IP addresses in + # certificate subjectAltNames + "service_identity >= 18.1.0", + "idna >= 2.4", +] + +conch = [ + "pyasn1", + "cryptography >= 2.6", + "appdirs >= 1.4.0", + "bcrypt >= 3.0.0", +] + +conch-nacl = [ + "twisted[conch]", + # Used to support Ed25519 keys on systems with OpenSSL < 1.1.1b + "PyNaCl", +] + +serial = [ + "pyserial >= 3.0", + "pywin32 != 226; platform_system == 'Windows'", +] + +http2 = [ + "h2 >= 3.0, < 5.0", + "priority >= 1.1.0, < 2.0", +] + +contextvars = [ + "contextvars >= 2.4, < 3; python_version < '3.7'", +] + +all-non-platform = [ + "twisted[test,tls,conch,serial,http2,contextvars]", +] + +macos-platform = [ + "twisted[all-non-platform]", + "pyobjc-core", + "pyobjc-framework-CFNetwork", + "pyobjc-framework-Cocoa", +] + +windows-platform = [ + "twisted[all-non-platform]", + "pywin32 != 226", +] + +osx-platform = [ + "twisted[macos-platform]", +] + +gtk-platform = [ + "twisted[all-non-platform]", + "pygobject", +] + +mypy = [ + "twisted[dev,all-non-platform,conch-nacl]", + "mypy==0.930", + "mypy-zope==0.3.4", + "types-setuptools", + "types-pyOpenSSL", +] + +[project.scripts] +cftp = "twisted.conch.scripts.cftp:run" +ckeygen = "twisted.conch.scripts.ckeygen:run" +conch = "twisted.conch.scripts.conch:run" +mailmail = "twisted.mail.scripts.mailmail:run" +pyhtmlizer = "twisted.scripts.htmlizer:run" +tkconch = "twisted.conch.scripts.tkconch:run" +trial = "twisted.scripts.trial:run" +twist = "twisted.application.twist._twist:Twist.main" +twistd = "twisted.scripts.twistd:run" + +[project.urls] +Changelog = "https://github.com/twisted/twisted/blob/HEAD/NEWS.rst" +Documentation = "https://docs.twistedmatrix.com/" +Homepage = "https://twistedmatrix.com/" +Issues = "https://twistedmatrix.com/trac/report" +Source = "https://github.com/twisted/twisted" +Twitter = "https://twitter.com/twistedmatrix" + +[tool.hatch.version] +source = "code" +path = "src/twisted/__init__.py" +search-paths = ["src"] + +[tool.hatch.metadata.hooks.fancy-pypi-readme] +content-type = "text/x-rst" +fragments = [ + { path = "README.rst" }, +] + +[[tool.hatch.metadata.hooks.fancy-pypi-readme.substitutions]] +# Munge links of the form `NEWS `_ to point at the appropriate +# location on GitHub so that they function when the long description is +# displayed on PyPI. +pattern = '`([^`]+)\s+<(?!https?://)([^>]+)>`_' +replacement = '`\1 `_' +ignore-case = true + +[tool.hatch.build.targets.wheel] +packages = [ + "src/twisted", +] +exclude = [ + "*.c", + "*.h", + "*.pxi", + "*.pyx", + "build.bat", +] + +[tool.hatch.build.targets.sdist] +# This dictates what goes into a sdist tarball. +# As a release tarball, we want to include: +# - All of the library code. +# - All the useful documentation (but not the super historic stuff) +# - All of the test files, so that the tests can be run on an installed copy. +# We do not want to include: +# - Release management files (e.g. topfiles) +# - Things only useful when running from a source checkout +include = [ + # Documentation + "/docs", + + # Library code + "/src", + "/CONTRIBUTING.md", + "/INSTALL.rst", + "/NEWS.rst", + "/README.rst", + "/code_of_conduct.md", + + # Test-running utilities for downstream packagers + "/.coveragerc", + "/mypy.ini", + "/tox.ini", +] +exclude = [ + # Do not include the news fragments + "/src/twisted/newsfragments", +] [tool.towncrier] package = "twisted" diff --git a/setup.cfg b/setup.cfg index d85e6d4ed60..e544af5deb1 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,163 +1,3 @@ -[metadata] -name = Twisted -version = attr: twisted.__version__ -description = An asynchronous networking framework written in Python -author = Twisted Matrix Laboratories -author_email = twisted-python@twistedmatrix.com -maintainer = Glyph Lefkowitz -maintainer_email = glyph@twistedmatrix.com -url = https://twistedmatrix.com/ -project_urls = - Documentation=https://docs.twistedmatrix.com/ - Source=https://github.com/twisted/twisted - Issues=https://twistedmatrix.com/trac/report - Twitter=https://twitter.com/twistedmatrix - Changelog=https://github.com/twisted/twisted/blob/HEAD/NEWS.rst -license = MIT -classifiers = - Programming Language :: Python :: 3 - 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 -long_description_content_type = text/x-rst - -[options] -# When updating this value, make sure our CI matrix includes a matching minimum version. -python_requires = >=3.7.1 -install_requires = - zope.interface >= 4.4.2 - constantly >= 15.1 - incremental >= 21.3.0 - Automat >= 0.8.0 - hyperlink >= 17.1.1 - attrs >= 19.2.0 - typing_extensions >= 3.6.5 - twisted-iocpsupport >= 1.0.2, <2; platform_system == "Windows" -include_package_data = True -zip_safe = False -package_dir = =src -packages = find: - -[options.extras_require] -; This is list of minimum dependencies required to run the test. -; The plan is to remove the `test` extra requirement and skip tests that -; depend on then -; To prevent trunk failures we should pin all dev dependencies to minor -; versions. -; We trust semantic versioning and auto-upgrading to a bugfix release -; should be OK. -test = - cython-test-exception-raiser >= 1.0.2, <2 - PyHamcrest >= 1.9.0 - hypothesis ~= 6.0 - -; List of dependencies required to build the documentation and test the -; release scripts and process. -dev_release = - towncrier ~= 22.8 - pydoctor ~= 22.9.0 - sphinx_rtd_theme ~= 1.0 - readthedocs-sphinx-ext ~= 2.1 - sphinx >= 5.0, <6 - -; All the extra tools used to help with the development process. -dev = - %(dev_release)s - pyflakes ~= 2.2 - # TODO: support python-subunit in py3.10 https://twistedmatrix.com/trac/ticket/10115 - python-subunit ~= 1.4; python_version < "3.10" - twistedchecker ~= 0.7 - coverage >= 6b1, <7 - -tls = - pyopenssl >= 21.0.0 - # service_identity 18.1.0 added support for validating IP addresses in - # certificate subjectAltNames - service_identity >= 18.1.0 - idna >= 2.4 - -conch = - pyasn1 - cryptography >= 2.6 - appdirs >= 1.4.0 - bcrypt >= 3.0.0 - -conch_nacl = - %(conch)s - # Used to support Ed25519 keys on systems with OpenSSL < 1.1.1b - PyNaCl - -serial = - pyserial >= 3.0 - pywin32 != 226; platform_system == "Windows" - -http2 = - h2 >= 3.0, < 5.0 - priority >= 1.1.0, < 2.0 - -contextvars = - contextvars >= 2.4, < 3; python_version < "3.7" - -all_non_platform = - %(test)s - %(tls)s - %(conch)s - %(serial)s - %(http2)s - %(contextvars)s - -macos_platform = - pyobjc-core - pyobjc-framework-CFNetwork - pyobjc-framework-Cocoa - %(all_non_platform)s - -windows_platform = - pywin32 != 226 - %(all_non_platform)s - -osx_platform = - %(macos_platform)s - -gtk_platform = - pygobject - %(all_non_platform)s - -mypy = - mypy==0.930 - mypy-zope==0.3.4 - types-setuptools - types-pyOpenSSL - %(dev)s - %(all_non_platform)s - %(conch_nacl)s - -[options.packages.find] -where = src - -[options.entry_points] -console_scripts = - ckeygen = twisted.conch.scripts.ckeygen:run - cftp = twisted.conch.scripts.cftp:run - conch = twisted.conch.scripts.conch:run - mailmail = twisted.mail.scripts.mailmail:run - pyhtmlizer = twisted.scripts.htmlizer:run - tkconch = twisted.conch.scripts.tkconch:run - trial = twisted.scripts.trial:run - twist = twisted.application.twist._twist:Twist.main - twistd = twisted.scripts.twistd:run - -[options.exclude_package_data] -* = - *.c - *.h - *.pxi - *.pyx - build.bat - - [flake8] disable-noqa = True max-line-length = 182 diff --git a/setup.py b/setup.py deleted file mode 100755 index dd52b25db63..00000000000 --- a/setup.py +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env python - -# Copyright (c) Twisted Matrix Laboratories. -# See LICENSE for details. - -""" -Setuptools installer for Twisted. -""" - -import pathlib -import re - -import setuptools - -setuptools.setup( - # Munge links of the form `NEWS `_ to point at the appropriate - # location on GitHub so that they function when the long description is - # displayed on PyPI. - long_description=re.sub( - r"`([^`]+)\s+<(?!https?://)([^>]+)>`_", - r"`\1 `_", - pathlib.Path("README.rst").read_text(encoding="utf8"), - flags=re.I, - ) -) diff --git a/src/twisted/newsfragments/11655.removal b/src/twisted/newsfragments/11655.removal new file mode 100644 index 00000000000..f777602a34b --- /dev/null +++ b/src/twisted/newsfragments/11655.removal @@ -0,0 +1 @@ +Optional dependency "extras" names like `conch_nacl` now use hyphens rather than underscores to comply with PEP 685. diff --git a/tox.ini b/tox.ini index 1be5cc7c3f6..4a84938f451 100644 --- a/tox.ini +++ b/tox.ini @@ -30,7 +30,7 @@ isolated_build=true [default] ; Files and directories that contain Python source for linting. -sources = setup.py src/ docs/conch/examples docs/mail/examples docs/names/examples docs/pair/examples docs/web/examples docs/words/examples +sources = src/ docs/conch/examples docs/mail/examples docs/names/examples docs/pair/examples docs/web/examples docs/words/examples ; These examples fail lint, see https://twistedmatrix.com/trac/ticket/9952 ; docs/core/examples @@ -40,22 +40,22 @@ sources = setup.py src/ docs/conch/examples docs/mail/examples docs/names/exampl # process to generate its own wheels. wheel = True parallel_show_output = True -;; dependencies managed by extras in setup.cfg +;; dependencies managed by extras in pyproject.toml extras = ; The "nodeps" build still depends on PyHamcrest. nodeps: test - ; We also need to include `dev_release` so that we can test our - ; release helpers or documentation generation, and `conch_nacl` so that + ; We also need to include `dev-release` so that we can test our + ; release helpers or documentation generation, and `conch-nacl` so that ; we can test conch fallbacks to PyNaCl without requiring most users to ; install it. - alldeps: all_non_platform, dev_release, conch_nacl + alldeps: all-non-platform, dev-release, conch-nacl - windows: windows_platform + windows: windows-platform - alldeps-macos: osx_platform + alldeps-macos: osx-platform - gtk: gtk_platform + gtk: gtk-platform serial: serial @@ -109,9 +109,9 @@ commands = description = Create the release notes from the current fragment files found in the source tree. ; towncrier needs Twisted install to get the version -; and dev_release requires the towncrier package. +; and dev-release requires the towncrier package. extras = - dev_release + dev-release commands = towncrier --yes @@ -131,7 +131,7 @@ wheel = False usedevelop = True ; Documentation needs Twisted install to get the version. extras = - dev_release + dev-release setenv = # Set this to `True` to run similar to Read The Docs. @@ -156,7 +156,7 @@ commands = [testenv:apidocs] description = Build the API documentation and fail on any errors or warnings. -extras = dev_release +extras = dev-release commands = # FIXME:https://github.com/twisted/twisted/issues/11590 # After all the pydoctor errors are fixed, the tox should be updated @@ -185,12 +185,10 @@ commands = deps = pep517 twine - check-manifest>=0.44 whitelist_externals = cp rm commands = - check-manifest --ignore "docs/_build/**,docs/historic/**,admin/**,bin/admin/**" rm -rf {toxinidir}/dist cp -r {distdir} {toxinidir}/dist # copy the wheel built by tox-wheel {envpython} -m pep517.build --source --out-dir={toxinidir}/dist {toxinidir} From 3f49b88b2304d66a2691bbaf8a506fd5824cb7bd Mon Sep 17 00:00:00 2001 From: Ofek Lev Date: Mon, 19 Sep 2022 00:16:34 -0400 Subject: [PATCH 2/7] support old names --- pyproject.toml | 26 ++++++++++++++++++++++++- src/twisted/newsfragments/11655.removal | 2 +- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 4f3497179ea..69621b2261c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [build-system] requires = [ - "hatchling", + "hatchling >= 1.10.0", "hatch-fancy-pypi-readme >= 22.5.0", "incremental >= 21.3.0", ] @@ -61,6 +61,9 @@ dev-release = [ "readthedocs-sphinx-ext ~= 2.1", "sphinx >= 4.1.2, <6", ] +dev_release = [ + "twisted[dev-release]", +] # All the extra tools used to help with the development process. dev = [ @@ -92,6 +95,9 @@ conch-nacl = [ # Used to support Ed25519 keys on systems with OpenSSL < 1.1.1b "PyNaCl", ] +conch_nacl = [ + "twisted[conch-nacl]", +] serial = [ "pyserial >= 3.0", @@ -110,6 +116,9 @@ contextvars = [ all-non-platform = [ "twisted[test,tls,conch,serial,http2,contextvars]", ] +all_non_platform = [ + "twisted[all-non-platform]", +] macos-platform = [ "twisted[all-non-platform]", @@ -117,20 +126,32 @@ macos-platform = [ "pyobjc-framework-CFNetwork", "pyobjc-framework-Cocoa", ] +macos_platform = [ + "twisted[macos-platform]", +] windows-platform = [ "twisted[all-non-platform]", "pywin32 != 226", ] +windows_platform = [ + "twisted[windows-platform]", +] osx-platform = [ "twisted[macos-platform]", ] +osx_platform = [ + "twisted[osx-platform]", +] gtk-platform = [ "twisted[all-non-platform]", "pygobject", ] +gtk_platform = [ + "twisted[gtk-platform]", +] mypy = [ "twisted[dev,all-non-platform,conch-nacl]", @@ -159,6 +180,9 @@ Issues = "https://twistedmatrix.com/trac/report" Source = "https://github.com/twisted/twisted" Twitter = "https://twitter.com/twistedmatrix" +[tool.hatch.metadata] +allow-ambiguous-features = true + [tool.hatch.version] source = "code" path = "src/twisted/__init__.py" diff --git a/src/twisted/newsfragments/11655.removal b/src/twisted/newsfragments/11655.removal index f777602a34b..d411b1cd610 100644 --- a/src/twisted/newsfragments/11655.removal +++ b/src/twisted/newsfragments/11655.removal @@ -1 +1 @@ -Optional dependency "extras" names like `conch_nacl` now use hyphens rather than underscores to comply with PEP 685. +Optional dependency "extras" names like `conch_nacl` now use hyphens rather than underscores to comply with PEP 685. The old names will be supported until the end of 2023. From 0295a48fad4c1259f96f3fac856c23e6b653a5cb Mon Sep 17 00:00:00 2001 From: Ofek Lev Date: Wed, 5 Oct 2022 00:56:17 -0400 Subject: [PATCH 3/7] rebase --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 69621b2261c..002290b1ec3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -56,7 +56,7 @@ test = [ # release scripts and process. dev-release = [ "towncrier ~= 22.8", - "pydoctor ~= 22.7.0", + "pydoctor ~= 22.9.0", "sphinx-rtd-theme ~= 0.5", "readthedocs-sphinx-ext ~= 2.1", "sphinx >= 4.1.2, <6", From 4b8b09a874da69ed8908c3f300f004e7e8604d15 Mon Sep 17 00:00:00 2001 From: Ofek Lev Date: Thu, 6 Oct 2022 18:45:24 -0400 Subject: [PATCH 4/7] Delete twisted.spec --- admin/twisted.spec | 56 ---------------------------------------------- 1 file changed, 56 deletions(-) delete mode 100644 admin/twisted.spec diff --git a/admin/twisted.spec b/admin/twisted.spec deleted file mode 100644 index 9be64a849a1..00000000000 --- a/admin/twisted.spec +++ /dev/null @@ -1,56 +0,0 @@ -%define name Twisted -%define version SVN-trunk -%define release 1tummy -%define prefix %{_prefix} -%define py_libver 2.3 - -Summary: Twisted is an event-based framework for internet applications. -Name: %{name} -Version: %{version} -Release: %{release} -Source: %{name}-%{version}.tar.bz2 -License: MIT -Group: System/Libraries -URL: http://www.twistedmatrix.com/ -Requires: python >= %{py_libver} -BuildRequires: python-devel -BuildRequires: pyproject-rpm-macros >= 1.2.0 -BuildRoot: %{_tmppath}/%{name}-buildroot -Prefix: %{_prefix} - -%description -Twisted is an event-based framework for internet applications. It includes a -web server, a telnet server, a chat server, a news server, a generic client -and server for remote object access, and APIs for creating new protocols and -services. Twisted supports integration of the Tk, GTK+, Qt or wxPython event -loop with its main event loop. The Win32 event loop is also supported, as is -basic support for running servers on top of Jython. - -%package doc -Summary: Twisted documentation and example programs -Group: Development/Python -%description doc -Twisted is an event-based framework for internet applications. -Install Twisted-doc if you need the API documentation and example programs. - -%prep -%setup -n %{name}-%{version} -%build - -%install -%pyproject_install -%pyproject_save_files %{srcname} - -%clean -[ -n "$RPM_BUILD_ROOT" -a "$RPM_BUILD_ROOT" != / ] && rm -rf "$RPM_BUILD_ROOT" - -%files -%defattr(755,root,root) -%doc CREDITS LICENSE README -%{_bindir}/* -%attr(644,-,-) %{_mandir}/man1/* -%{_libdir}/python%{py_libver}/site-packages/twisted/ - -%files doc -%defattr(-,root,root) -%doc doc/* From 1440ba94e02ebc33234902b361f885614126cfc6 Mon Sep 17 00:00:00 2001 From: Ofek Lev Date: Thu, 6 Oct 2022 19:09:51 -0400 Subject: [PATCH 5/7] Apply suggestions from code review Co-authored-by: Glyph --- pyproject.toml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 002290b1ec3..ed29faade8e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -242,7 +242,17 @@ include = [ ] exclude = [ # Do not include the news fragments - "/src/twisted/newsfragments", + "src/twisted/conch/newsfragments", + "src/twisted/trial/newsfragments", + "src/twisted/mail/newsfragments", + "src/twisted/newsfragments", + "src/twisted/persisted/newsfragments", + "src/twisted/names/newsfragments", + "src/twisted/words/newsfragments", + "src/twisted/scripts/newsfragments", + "src/twisted/runner/newsfragments", + "src/twisted/application/newsfragments", + "src/twisted/web/newsfragments", ] [tool.towncrier] From d943e4c6ebc54f949300945303fd112df1f3263b Mon Sep 17 00:00:00 2001 From: Ofek Lev Date: Wed, 12 Oct 2022 15:38:43 -0400 Subject: [PATCH 6/7] address feedback --- pyproject.toml | 67 ++++++++++++++++++++++---------------------------- tox.ini | 14 +++++------ 2 files changed, 37 insertions(+), 44 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index ed29faade8e..50f74879c74 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -61,9 +61,6 @@ dev-release = [ "readthedocs-sphinx-ext ~= 2.1", "sphinx >= 4.1.2, <6", ] -dev_release = [ - "twisted[dev-release]", -] # All the extra tools used to help with the development process. dev = [ @@ -95,9 +92,6 @@ conch-nacl = [ # Used to support Ed25519 keys on systems with OpenSSL < 1.1.1b "PyNaCl", ] -conch_nacl = [ - "twisted[conch-nacl]", -] serial = [ "pyserial >= 3.0", @@ -116,9 +110,6 @@ contextvars = [ all-non-platform = [ "twisted[test,tls,conch,serial,http2,contextvars]", ] -all_non_platform = [ - "twisted[all-non-platform]", -] macos-platform = [ "twisted[all-non-platform]", @@ -126,32 +117,20 @@ macos-platform = [ "pyobjc-framework-CFNetwork", "pyobjc-framework-Cocoa", ] -macos_platform = [ - "twisted[macos-platform]", -] windows-platform = [ "twisted[all-non-platform]", "pywin32 != 226", ] -windows_platform = [ - "twisted[windows-platform]", -] osx-platform = [ "twisted[macos-platform]", ] -osx_platform = [ - "twisted[osx-platform]", -] gtk-platform = [ "twisted[all-non-platform]", "pygobject", ] -gtk_platform = [ - "twisted[gtk-platform]", -] mypy = [ "twisted[dev,all-non-platform,conch-nacl]", @@ -161,6 +140,34 @@ mypy = [ "types-pyOpenSSL", ] +# We define all the legacy dependency targets using the +# underscore for backward compatibility. +# Once underscores are no longer supported by Python package tools +# like pip and PyPI, these can be removed. +# Any new extra dependency should not be added here. +# This list is here only for backward compatiblility. +dev_release = [ + "twisted[dev-release]", +] +conch_nacl = [ + "twisted[conch-nacl]", +] +all_non_platform = [ + "twisted[all-non-platform]", +] +macos_platform = [ + "twisted[macos-platform]", +] +windows_platform = [ + "twisted[windows-platform]", +] +osx_platform = [ + "twisted[osx-platform]", +] +gtk_platform = [ + "twisted[gtk-platform]", +] + [project.scripts] cftp = "twisted.conch.scripts.cftp:run" ckeygen = "twisted.conch.scripts.ckeygen:run" @@ -181,6 +188,8 @@ Source = "https://github.com/twisted/twisted" Twitter = "https://twitter.com/twistedmatrix" [tool.hatch.metadata] +# This is here to enable backward compatible extra dependencies +# that are defined using underscores. allow-ambiguous-features = true [tool.hatch.version] @@ -207,8 +216,6 @@ packages = [ "src/twisted", ] exclude = [ - "*.c", - "*.h", "*.pxi", "*.pyx", "build.bat", @@ -240,20 +247,6 @@ include = [ "/mypy.ini", "/tox.ini", ] -exclude = [ - # Do not include the news fragments - "src/twisted/conch/newsfragments", - "src/twisted/trial/newsfragments", - "src/twisted/mail/newsfragments", - "src/twisted/newsfragments", - "src/twisted/persisted/newsfragments", - "src/twisted/names/newsfragments", - "src/twisted/words/newsfragments", - "src/twisted/scripts/newsfragments", - "src/twisted/runner/newsfragments", - "src/twisted/application/newsfragments", - "src/twisted/web/newsfragments", -] [tool.towncrier] package = "twisted" diff --git a/tox.ini b/tox.ini index 443ef0d515b..223fdd52e45 100644 --- a/tox.ini +++ b/tox.ini @@ -49,13 +49,13 @@ extras = ; release helpers or documentation generation, and `conch-nacl` so that ; we can test conch fallbacks to PyNaCl without requiring most users to ; install it. - alldeps: all-non-platform, dev-release, conch-nacl + alldeps: all_non_platform, dev_release, conch_nacl - windows: windows-platform + windows: windows_platform - alldeps-macos: osx-platform + alldeps-macos: osx_platform - gtk: gtk-platform + gtk: gtk_platform serial: serial @@ -111,7 +111,7 @@ description = Create the release notes from the current fragment files found in ; towncrier needs Twisted install to get the version ; and dev-release requires the towncrier package. extras = - dev-release + dev_release commands = towncrier --yes @@ -131,7 +131,7 @@ wheel = False usedevelop = True ; Documentation needs Twisted install to get the version. extras = - dev-release + dev_release setenv = # Set this to `True` to run similar to Read The Docs. @@ -156,7 +156,7 @@ commands = [testenv:apidocs] description = Build the API documentation and fail on any errors or warnings. -extras = dev-release +extras = dev_release commands = # FIXME:https://github.com/twisted/twisted/issues/11590 # After all the pydoctor errors are fixed, the tox should be updated From bd6eeb2f6a52d3abf2bb52c699eece640c4a13e0 Mon Sep 17 00:00:00 2001 From: Ofek Lev Date: Wed, 19 Oct 2022 00:01:46 -0400 Subject: [PATCH 7/7] address --- hatch_build.py | 20 ++++++++++++++++++++ pyproject.toml | 34 +++++----------------------------- 2 files changed, 25 insertions(+), 29 deletions(-) create mode 100644 hatch_build.py diff --git a/hatch_build.py b/hatch_build.py new file mode 100644 index 00000000000..29cbce88e46 --- /dev/null +++ b/hatch_build.py @@ -0,0 +1,20 @@ +# Copyright (c) Twisted Matrix Laboratories. +# See LICENSE for details. +from hatchling.metadata.plugin.interface import MetadataHookInterface + + +class CustomMetadataHook(MetadataHookInterface): + def update(self, metadata): + optional_dependencies = self.config["optional-dependencies"] + for feature, dependencies in list(optional_dependencies.items()): + if "-" not in feature: + continue + + # We define all the legacy dependency targets using the + # underscore for backward compatibility. + # + # See: https://github.com/twisted/twisted/pull/11656#issuecomment-1282855123 + legacy_feature = feature.replace("-", "_") + optional_dependencies[legacy_feature] = dependencies + + metadata["optional-dependencies"] = optional_dependencies diff --git a/pyproject.toml b/pyproject.toml index 50f74879c74..667bc880b31 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,6 +11,8 @@ name = "Twisted" dynamic = [ "version", "readme", + # Remove this when the legacy optional dependency names are removed + "optional-dependencies", ] description = "An asynchronous networking framework written in Python" license = "MIT" @@ -38,7 +40,9 @@ dependencies = [ "twisted-iocpsupport >= 1.0.2, <2; platform_system == 'Windows'", ] -[project.optional-dependencies] +# Switch to this when the legacy optional dependency names are removed +# [project.optional-dependencies] +[tool.hatch.metadata.hooks.custom.optional-dependencies] # This is list of minimum dependencies required to run the tests. # The plan is to remove the `test` extra requirement and skip tests that # depend on them @@ -140,34 +144,6 @@ mypy = [ "types-pyOpenSSL", ] -# We define all the legacy dependency targets using the -# underscore for backward compatibility. -# Once underscores are no longer supported by Python package tools -# like pip and PyPI, these can be removed. -# Any new extra dependency should not be added here. -# This list is here only for backward compatiblility. -dev_release = [ - "twisted[dev-release]", -] -conch_nacl = [ - "twisted[conch-nacl]", -] -all_non_platform = [ - "twisted[all-non-platform]", -] -macos_platform = [ - "twisted[macos-platform]", -] -windows_platform = [ - "twisted[windows-platform]", -] -osx_platform = [ - "twisted[osx-platform]", -] -gtk_platform = [ - "twisted[gtk-platform]", -] - [project.scripts] cftp = "twisted.conch.scripts.cftp:run" ckeygen = "twisted.conch.scripts.ckeygen:run"