Skip to content

Move project configuration to pyproject.toml - #157

Open
TOMASEZARATE wants to merge 2 commits into
pytest-dev:mainfrom
TOMASEZARATE:pyproject-config
Open

TOMASEZARATE wants to merge 2 commits into
pytest-dev:mainfrom
TOMASEZARATE:pyproject-config

Conversation

@TOMASEZARATE

@TOMASEZARATE TOMASEZARATE commented Nov 17, 2026 •

Copy link
Copy Markdown

Closes #126

The package metadata now lives in the [project] table in pyproject.toml, so setup.py and setup.cfg are removed. Python 3.7, 3.8 and 3.9 are dropped (requires-python is >=3.10). The setuptools-scm config now uses setuptools-scm>=10, version_file, and write_to_source = true. license stays "MIT", with setuptools>=77.

Two real metadata differences from setup.py:

  • readme = "README.rst" now emits Description-Content-Type: text/x-rst (setup.py set none)
  • tests_require is dropped (it had no effect)

Written with some help from AI.

@diazona

diazona commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Hi Tomas, thanks for your contribution! I'm actually not sure if we can accept a PR made with AI assistance, though. Let me see if there are any relevant policies yo consider.

@TOMASEZARATE

Copy link
Copy Markdown
Author

Thanks for taking a look, and no problem, I'll wait to hear what you decide about the AI policy.

About the failing jobs, there are two separate things:

  • Python 3.9 fails before any tests run, because setup-python can't find 3.9 for ubuntu-26.04 ("The version '3.9' with architecture 'x64' was not found"). That isn't related to this PR; the latest run on main fails the same way.
  • Python 3.7/3.8 and PyPy 3.7/3.8 are on me. setuptools 77 needs Python >=3.9, so those environments end up with an older setuptools that doesn't accept the PEP 639 string form of project.license and the sdist build fails. I can switch the license back to a form older setuptools understands and drop the >=77 requirement, so the build works on every supported version. I'll push that if you'd like to move forward with the PR.

@RonnyPfannschmidt RonnyPfannschmidt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🤖 Written by Claude Opus 5.5 via Claude Code for the pytest-localserver maintainers; I prompted it, it did the work, I read it.

Thanks for picking up #126 and for disclosing the AI use. The mapping from setup.py into [project] is correct, and your read of the CI failures is right. Rather than falling back to the old license form, let's go forward: drop the old Pythons and modernise the setuptools-scm config in this PR.

1. Drop Python 3.7, 3.8 and 3.9 (requires-python = ">=3.10").
All three are EOL, setup-python no longer ships 3.9 for ubuntu-26.04 (that's the unrelated 3.9 failure, main fails the same way), current setuptools needs 3.10, and setuptools-scm 10.0.x needs 3.10. That means touching:

  • pyproject.toml: requires-python, remove the 3.7/3.8/3.9 classifiers, [tool.black] target-version = ['py310']
  • tox.ini: envlist py{310,311,312,313,314,315,py3}{,-smtp},lint, and drop the now-dead pytest >=4.6, <10; python_version <'3.10' line
  • .github/workflows/tests.yml: remove the 3.7/3.8/3.9 and pypy-3.7/3.8/3.9 matrix entries (that also removes the last ubuntu-22.04 pins and the pytest==4.6 min-deps runs)
  • .pre-commit-config.yaml: pyupgrade --py37-plus → --py310-plus

2. Keep the PEP 639 license as you have it. setuptools>=77 and license = "MIT" are right once 3.7–3.9 are gone. Please don't switch to license = {text = "MIT"}: it drops License-Expression from the published wheel and setuptools (84.2.1) deprecates the table form, with removal due 2027-02-18.

3. Update the setuptools-scm config.

  • setuptools_scm[toml] >=3.4.1 → setuptools-scm>=10. The toml extra is empty in current releases, and 10 is what the config below needs.
  • write_to → version_file. The current docs only document version_file; write_to is the legacy spelling.
  • Set write_to_source = true explicitly. Without it, setuptools-scm 10 emits a DeprecationWarning on every build, and its default flips in the next major to not writing into the source tree. pytest_localserver/__init__.py imports pytest_localserver._version, so editable installs and source checkouts would lose that file.
[build-system]
requires = ["setuptools>=77", "setuptools-scm>=10"]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
version_file = "pytest_localserver/_version.py"
write_to_source = true

4. Description and CHANGES.

  • The description says the metadata matches apart from formatting, but there are two real differences: readme = "README.rst" now emits Description-Content-Type: text/x-rst (setup.py set none), and tests_require is dropped (it had no effect). Please list both.
  • Please add a CHANGES entry, e.g. "Drop Python 3.7, 3.8 and 3.9 support" and "Move project metadata from setup.py to pyproject.toml".

Generated by Claude Code

@TOMASEZARATE

Copy link
Copy Markdown
Author

Thanks, I pushed the requested changes

@RonnyPfannschmidt RonnyPfannschmidt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

looks good to me, thanks
@diazona please take a look if you see anything amiss

Comment thread pyproject.toml
[tool.setuptools_scm]
write_to = "pytest_localserver/_version.py"
version_file = "pytest_localserver/_version.py"
write_to_source = true

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

optional nitpick - we may not need write_to_source

Comment thread tox.ini
@@ -1,5 +1,5 @@
[tox]
envlist = py{37,38,39,310,311,312,313,314,315,py3}{,-smtp},lint
envlist = py{310,311,312,313,314,315,py3}{,-smtp},lint

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

followup note - i am under the impression no need to do the smpt thing for all python versions, maybe this can be reduced

@diazona

diazona commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

I'll take a look at the PR as soon as I have a chance, but it might not be until tomorrow or Saturday since I'm having a particularly busy week at work. So if you don't hear from me before then, don't worry, I haven't forgotten.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consolidate project configuration in pyproject.toml

3 participants