Add pyproject.toml and require Python 3.12 for local dev - #717
Conversation
setup-environment failed on CentOS Stream 9/RHEL 9/UBI9 because their default Python is 3.9, and pytest>=9.0 dropped 3.9 support. Downstream packaging already targets Python 3.12 (python-obsah builds against it, foremanctl.spec requires python3.12-obsah) and CI already sets up 3.12, so align local dev tooling with that instead of downgrading pytest. pyproject.toml declares requires-python>=3.12 plus project metadata and dependencies (metadata-only package, no console-script entry points), using setuptools_scm for the version so it mirrors what VERSION/ export-subst does for release tarballs. setup-environment now enforces python3.12 explicitly instead of relying on whatever "python" resolves to on PATH. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
|
||
| set -eou pipefail | ||
|
|
||
| REQUIRED_PYTHON=python3.12 |
There was a problem hiding this comment.
setup-environment now checks for python3.12 explicitly (instead of relying on whatever python resolves to on PATH) and fails fast with a clear, actionable error if it's missing.
src/requirements.txt / development/requirements.txt are left unchanged for now — this is a first step, not a full migration.
DEVELOPMENT.md now lists Python - 3.12+ under Requirements.
So which is it? 3.12+ or 3.12 exactly?
There was a problem hiding this comment.
Changed to one dynamic resolution that will failed if it's not 3.12+, when I tried to run on CS9 with only python3.9 it failed, and later worked with 3.12.
setup-environment checks command -v python3.12, which only matches a
binary literally named python3.12 -- it would never pick up a
hypothetical python3.13. requires-python (">=3.12") and DEVELOPMENT.md
("3.12+") implied a floor instead of an exact pin, which was
inconsistent with what the script actually enforces and with
downstream packaging (python-obsah.spec pins python3.12 specifically).
Reported in review: theforeman#717 (comment)
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
command -v python3.12 only ever matches a binary literally named
python3.12 -- it would never pick up python3.13+ even though
pyproject.toml's requires-python (">=3.12") and DEVELOPMENT.md ("3.12+")
both say any 3.12-or-newer interpreter is fine. Search python3.12 (the
name EL9 ships it under, unaliased) then fall back to python3, checking
each candidate's actual version instead of just its name, so this keeps
working as newer Pythons become the default (e.g. future EL releases).
Verified via podman on CentOS Stream 9 (python3.12 package installed),
CentOS Stream 10 (python3 already 3.12), and CS9 with only the default
python3 (3.9) present, which still correctly fails with a clear error.
Reported in review: theforeman#717 (comment)
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
ekohl
left a comment
There was a problem hiding this comment.
./setup-environment fails on CentOS Stream 9/RHEL 9/UBI9 because their default Python is 3.9, and development/requirements.txt pins pytest>=9.0, which dropped Python 3.9 support (requires 3.10+).
I'm sorry for adding that. I didn't realize it when I bumped it for the subtests feature.
I don't like duplicating the dependencies in 2 places. IMHO that needs to be solved.
| [project] | ||
| name = "foremanctl" | ||
| description = "Deployment tool for Foreman and Katello using Podman quadlets and Ansible" | ||
| requires-python = ">=3.12" |
There was a problem hiding this comment.
Runtime wise I think this is lower. It's just for testing now.
Why are you introducing these changes? (Problem description, related links)
./setup-environmentfails on CentOS Stream 9/RHEL 9/UBI9 because their default Python is 3.9, anddevelopment/requirements.txtpinspytest>=9.0, which dropped Python 3.9 support (requires 3.10+). Downgrading the pytest pin would just be papering over a version mismatch: downstream packaging already targets Python 3.12 (python-obsahbuilds againstpython3.12,foremanctl.specrequirespython3.12-obsah) and CI already sets up Python 3.12 for every job. EL9's default 3.9 was never actually a supported target for this project, and EL10 ships 3.12 by default anyway.What are the changes introduced in this pull request?
pyproject.tomldeclaringrequires-python = ">=3.12"plus project metadata and dependencies. This is metadata-only (foremanctl/forgestay as bash wrappers, no console-script entry points, no bundling ofsrc//development/as package data). Version is resolved viasetuptools_scmfromgit describe, mirroring whatVERSION/export-substdoes for release tarballs but working correctly from a plain checkout too (a customtag_regexhandles this repo's non-PEP-440 tags like3.0.0-develop). The build backend (setuptools) is left unpinned so it uses whatever version already ships with the running system rather than one pip would fetch from PyPI.setup-environmentnow checks forpython3.12explicitly (instead of relying on whateverpythonresolves to on PATH) and fails fast with a clear, actionable error if it's missing.src/requirements.txt/development/requirements.txtare left unchanged for now — this is a first step, not a full migration.DEVELOPMENT.mdnow listsPython - 3.12+under Requirements.How to test this pull request
Steps to reproduce:
python3.12on PATH (e.g. plainquay.io/centos/centos:stream9), run./setup-environmentand confirm it fails fast withError: python3.12 is required ...instead of pip's confusing "no matching distribution" error.python3.12/python3.12-devel(CS9) or just use CS10 (shipspython3.12as defaultpython3), run./setup-environment, and confirm.venv/bin/python --versionreports 3.12 andpytest>=9.0installs successfully.pip install --upgrade setuptools setuptools_scm && pip install --no-build-isolation -e '.[dev]'and confirm it builds using the system's ownsetuptools(checkpip show setuptoolsmatches the OS package version) and resolves a valid version viapip show foremanctl.This was verified end-to-end with
podman runon bothquay.io/centos/centos:stream9and:stream10.Checklist
setup-environmentitself.DEVELOPMENT.md