Skip to content
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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

quicklizard99
Copy link
Contributor

@quicklizard99 quicklizard99 commented Aug 12, 2024

Changes:

  • Switch from pip to uv for managing 'dev' dependencies.
  • Provision development virtual environments using dependencies pinned in 'requirements.txt'.
  • Add support for 'tox', supporting Python versions 3.9 to 3.12.
  • Get tests to pass on Python 3.9 to 3.12 inclusive: bump versions of two 'dev' dependencies, and add a couple of pytest warnings filters.

TODO, possibly in a subsequent PR: setup CI to use tox to test against all supported versions of Python.

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.
@quicklizard99 quicklizard99 force-pushed the uv-and-tox-and-python-3.12 branch from a4e34c8 to 615a080 Compare August 12, 2024 12:06
pip install pip==23.3.1
pip install -e '.[dev,docs]'
pip install uv==0.2.34
uv pip install -r requirements.txt --editable .
Copy link
Contributor Author

@quicklizard99 quicklizard99 Aug 12, 2024

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.

@quicklizard99 quicklizard99 marked this pull request as ready for review August 20, 2024 12:48
Copy link
Contributor

@codeinthehole codeinthehole left a 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`.
Copy link
Contributor

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
Copy link
Contributor

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]`.
Copy link
Contributor

Choose a reason for hiding this comment

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

@@ -47,10 +48,10 @@ dev = [
"moto[s3,sqs]",
"mypy-boto3-s3",
"mypy",
"numpy",
"numpy>=1.26.4",
Copy link
Contributor

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.

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.

2 participants