Add pyproject.toml for certbot (#10402)

This sets up a `pyproject.toml` file for certbot, initially generated
[using](https://hatch.pypa.io/latest/intro/#existing-project) `hatch new
--init` and modifying from there. Since we dynamically require acme of a
matching version, I kept that around in `setup.py` to do the simplest
thing in this PR.

Other possible (future) implementations:
- setuptools has a beta implementation to read from a
`requirements.txt`. we could generate one of those.
- we could just hardcode it and update at release time. I like not
having to keep the version up to date in various places but maybe it's
actually fine
- something something integration with poetry pinning?

I think the syntax for setting version dynamically in `pyproject.toml`
is much nicer than what we do in `setup.py`. It's a little silly to do
it there after we've bothered to calculate it, but I put it there in the
hopes of being able to remove it from `setup.py` someday/somehow.

It would be nice to access the version dynamically set in
`pyproject.toml` in `setup.py`, but I do not think it is likely to be
possible.

Here are some useful links regarding this migrations:
- [How to modernize a `setup.py` based
project?](https://packaging.python.org/en/latest/guides/modernize-setup-py-project/)
- [Writing your
`pyproject.toml`](https://packaging.python.org/en/latest/guides/writing-pyproject-toml/)
- [Configuring setuptools using `pyproject.toml` files](
https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html)
- [`pyproject.toml`
specification](https://packaging.python.org/en/latest/specifications/pyproject-toml/)
- [Platform compatibility
tags](https://packaging.python.org/en/latest/specifications/platform-compatibility-tags/)
This commit is contained in:
ohemorange 2025-08-11 10:50:41 -07:00 committed by GitHub
parent f0f036a34c
commit 9b3db6d52c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 100 additions and 97 deletions

99
certbot/pyproject.toml Normal file
View file

@ -0,0 +1,99 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
[project]
name = "certbot"
dynamic = ["version", "dependencies"]
description = "ACME client"
readme = "README.rst"
license = "Apache-2.0"
requires-python = ">=3.9.2"
authors = [
{ name = "Certbot Project", email = "certbot-dev@eff.org" },
]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
"Environment :: Console :: Curses",
"Intended Audience :: System Administrators",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Security",
"Topic :: System :: Installation/Setup",
"Topic :: System :: Networking",
"Topic :: System :: Systems Administration",
"Topic :: Utilities",
]
[project.optional-dependencies]
dev = [
"azure-devops",
"ipdb",
# allows us to use newer urllib3 https://github.com/python-poetry/poetry-plugin-export/issues/183
"poetry-plugin-export>=1.9.0",
# poetry 1.2.0+ is required for it to pin pip, setuptools, and wheel. See
# https://github.com/python-poetry/poetry/issues/1584.
"poetry>=1.2.0",
"towncrier",
"twine",
]
docs = [
# If you have Sphinx<1.5.1, you need docutils<0.13.1
# https://github.com/sphinx-doc/sphinx/issues/3212
"Sphinx>=1.2", # Annotation support
"sphinx_rtd_theme",
]
# Tools like pip, wheel, and tox are listed here to ensure they are properly
# pinned and installed during automated testing.
test = [
"coverage",
"mypy",
"pip",
"pylint",
"pytest",
"pytest-cov",
"pytest-xdist",
"ruff",
"setuptools",
"tox",
"types-httplib2",
"types-pyRFC3339",
"types-pywin32",
"types-requests",
"types-setuptools",
"wheel",
]
all = [
"certbot[dev,docs,test]"
]
[project.scripts]
certbot = "certbot.main:main"
[project.entry-points."certbot.plugins"]
manual = "certbot._internal.plugins.manual:Authenticator"
null = "certbot._internal.plugins.null:Installer"
standalone = "certbot._internal.plugins.standalone:Authenticator"
webroot = "certbot._internal.plugins.webroot:Authenticator"
[project.urls]
Homepage = "https://github.com/certbot/certbot"
[tool.setuptools]
package-dir = {"" = "src"}
[tool.setuptools.packages.find]
where = ["src"] # list of folders that contain the packages (["."] by default)
exclude = ['docs', 'examples', 'tests', 'venv'] # exclude packages matching these glob patterns
[tool.setuptools.dynamic]
version = {attr = "certbot.__version__"} # any module attribute compatible with ast.literal_eval

View file

@ -2,7 +2,6 @@ import codecs
import os
import re
from setuptools import find_packages
from setuptools import setup
@ -18,7 +17,6 @@ here = os.path.abspath(os.path.dirname(__file__))
init_fn = os.path.join(here, 'src', 'certbot', '__init__.py')
meta = dict(re.findall(r"""__([a-z]+)__ = '([^']+)""", read_file(init_fn)))
readme = read_file(os.path.join(here, 'README.rst'))
version = meta['version']
# This package relies on PyOpenSSL and requests, however, it isn't specified
@ -42,102 +40,7 @@ install_requires = [
'pywin32>=300 ; sys_platform == "win32"',
]
dev_extras = [
'azure-devops',
'ipdb',
# poetry 1.2.0+ is required for it to pin pip, setuptools, and wheel. See
# https://github.com/python-poetry/poetry/issues/1584.
'poetry>=1.2.0',
# allows us to use newer urllib3 https://github.com/python-poetry/poetry-plugin-export/issues/183
'poetry-plugin-export>=1.9.0',
'towncrier',
'twine',
]
docs_extras = [
# If you have Sphinx<1.5.1, you need docutils<0.13.1
# https://github.com/sphinx-doc/sphinx/issues/3212
'Sphinx>=1.2', # Annotation support
'sphinx_rtd_theme',
]
# Tools like pip, wheel, and tox are listed here to ensure they are properly
# pinned and installed during automated testing.
test_extras = [
'coverage',
'mypy',
'pip',
'pylint',
'pytest',
'pytest-cov',
'pytest-xdist',
'ruff',
'setuptools',
'tox',
'types-httplib2',
'types-pyRFC3339',
'types-pywin32',
'types-requests',
'types-setuptools',
'wheel',
]
all_extras = dev_extras + docs_extras + test_extras
setup(
name='certbot',
version=version,
description="ACME client",
long_description=readme,
url='https://github.com/certbot/certbot',
author="Certbot Project",
author_email='certbot-dev@eff.org',
license='Apache License 2.0',
python_requires='>=3.9.2',
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Console',
'Environment :: Console :: Curses',
'Intended Audience :: System Administrators',
'License :: OSI Approved :: Apache Software License',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: 3.13',
'Topic :: Internet :: WWW/HTTP',
'Topic :: Security',
'Topic :: System :: Installation/Setup',
'Topic :: System :: Networking',
'Topic :: System :: Systems Administration',
'Topic :: Utilities',
],
packages=find_packages(where='src', exclude=['docs', 'examples', 'tests', 'venv']),
package_dir={'': 'src'},
include_package_data=True,
install_requires=install_requires,
extras_require={
'all': all_extras,
'dev': dev_extras,
'docs': docs_extras,
'test': test_extras,
},
entry_points={
'console_scripts': [
'certbot = certbot.main:main',
],
'certbot.plugins': [
'manual = certbot._internal.plugins.manual:Authenticator',
'null = certbot._internal.plugins.null:Installer',
'standalone = certbot._internal.plugins.standalone:Authenticator',
'webroot = certbot._internal.plugins.webroot:Authenticator',
],
},
)

View file

@ -0,0 +1 @@
Migrated most functionality from `certbot/setup.py` to `certbot/pyproject.toml`