-
Notifications
You must be signed in to change notification settings - Fork 7
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
uv, tox and Python 3.12 #168
base: main
Are you sure you want to change the base?
Conversation
Prior to this change, development virtual environments were provisioned with `pip` (a relatively slow tool) with dependency versions solved dynamically using spec in 'pyproject.toml' (making each build something of a lottery). This change replaces `pip` with the far faster `uv` [^1], and uses pinned versions of dependencies in 'requirements.txt' (making environments reproducible). [^1]: https://github.com/astral-sh/uv
Prior to this change, `pip install xocto[dev]` would use pinned versions of 'dev' dependencies This change removes pinned versions from 'dev' dependencies in 'pyproject.toml'. Package maintainers should provision virtual environments using versions in 'requirements.txt' with `uv pip sync requirements.txt`.
Adding 'tox' [^1] makes it possible to test xocto against multiple versions of Python. [^1]: https://tox.wiki/
This change adds Python 3.10, 3.11, and 3.12 to 'tox.ini', and makes changes to 'dev' dependencies, and to pytest filter warnings, such that tests pass on Python 3.9 to 3.12 inclusive.
a4e34c8
to
615a080
Compare
pip install pip==23.3.1 | ||
pip install -e '.[dev,docs]' | ||
pip install uv==0.2.34 | ||
uv pip install -r requirements.txt --editable . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer this to be uv pip sync requirements.txt
but without --editable .
CI fails with importlib.metadata.PackageNotFoundError: xocto
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is largely fine.
Big picture is we want to break this repo up into smaller repos that follow the CookieCutterPackage (CCP) structure:
https://app.asana.com/0/1206645373701928/1205859480233767/f
This repo doesn't follow the CCP structure and it's likely not worth the effort to convert it. I would consider following how the makefile is set-up for CCP though, as the consistency will make it easier to jump between projects.
|
||
* Edit `pyproject.toml`. | ||
* `make sync_requirements` to refresh `requirements.txt`. | ||
* `make install test format_check lint_check mypy`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's probably worth copying the makefile targets from the CookieCutterPackage repo:
https://github.com/octoenergy/cookiecutter-kraken-package/blob/main/%7B%7B%20cookiecutter.repo_name%20%7D%7D/makefile
Run [tox](https://tox.wiki/) to test the package on supported versions | ||
of Python. | ||
|
||
Each versions of Python listed in `tox.ini` must be present on your |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🐼 "version"
system. On Linux it is probably easiest to build each version from | ||
source, using `make altinstall`. | ||
If you use Mac you can install each version using homebrew e.g., | ||
`brew install [email protected]`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to recommend pyenv
than Homebrew. This mirrors CookieCutterPackage repo:
https://github.com/octoenergy/cookiecutter-kraken-package/tree/main/%7B%7B%20cookiecutter.repo_name%20%7D%7D#testing-single-python-version
@@ -47,10 +48,10 @@ dev = [ | |||
"moto[s3,sqs]", | |||
"mypy-boto3-s3", | |||
"mypy", | |||
"numpy", | |||
"numpy>=1.26.4", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's worth a comment to explain why we need the version filter.
Changes:
pip
touv
for managing 'dev' dependencies.TODO, possibly in a subsequent PR: setup CI to use
tox
to test against all supported versions of Python.