-
Notifications
You must be signed in to change notification settings - Fork 69
Upgrade to Ubuntu 24.04 LTS and Python 3.12 with modern uv dependency management #1100
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
Upgrade to Ubuntu 24.04 LTS and Python 3.12 with modern uv dependency management #1100
Conversation
Co-authored-by: ericholscher <[email protected]>
|
@copilot Update everything that's using a specific python or ubuntu version |
Co-authored-by: ericholscher <[email protected]>
Updated all Python and Ubuntu version references across the repository in commit c876f64:
All configs now consistently use Python 3.12 (the default in Ubuntu 24.04) and Ubuntu 24.04 LTS. |
|
I had a branch I was working on for this (https://github.com/readthedocs/ethical-ad-server/tree/davidfischer/ubuntu24-upgrade) but I was planning to do the UV part in a separate PR/task as I think there's a fair bit of change there. I think there's a few things we want here:
|
@copilot ^^ |
Co-authored-by: ericholscher <[email protected]>
Implemented all the suggested improvements in commit 4ee1ae2: ✅ Moved dependencies to The Dockerfile now uses a single Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Co-authored-by: ericholscher <[email protected]>
|
@copilot Try again now that I've allow listed astral.sh. Ensure tests look good. |
Co-authored-by: ericholscher <[email protected]>
Generated complete uv.lock file and verified tests in commit 6794d0f: ✅ Lock file generated: 247 packages resolved, 4,983 lines with all transitive dependencies pinned
The setup is fully functional and ready for use. All dependencies are now locked with exact versions for reproducible builds across all environments. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
This looks OK. I'm not going to aim to deploy this today as I think it needs more time with testing. Specifically I want to run it in dev for a while with the analyzer and make sure everything is working well. There's a few things to correct:
|
- Tox config in pyproject.toml (run with tox-uv) - In docker, uv has its own isolated environment (at /.venv) - Remove old requirements files (use uv.lock)
| python: "3.12" | ||
| jobs: | ||
| pre_install: | ||
| # Install uv | ||
| - curl -LsSf https://astral.sh/uv/install.sh | sh | ||
| # Ensure uv is on PATH | ||
| - export PATH="$HOME/.local/bin:$PATH" | ||
| install: | ||
| # Sync regular and dev dependencies | ||
| - uv sync --locked | ||
| build: | ||
| - uv run sphinx-build -b html . _build -W |
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'm not 100% sure that this is the best way to do uv on RTD.
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 think this is what's documented: https://docs.readthedocs.com/platform/stable/build-customization.html#install-dependencies-with-uv
|
I think this is ready for review.
|
| @@ -1 +1 @@ | |||
| python-3.8.12 | |||
| python-3.12 | |||
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 don't think this file is used at all. We can probably remove it. I think this is from when we were testing on Heroku years ago.
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.
Yea, we should remove it with this refactor 👍
ericholscher
left a comment
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 looks great. I love the deleting of so many files and moving them into the pyproject.toml.
| # Load model | ||
| RUN python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('multi-qa-MiniLM-L6-cos-v1', cache_folder='/tmp/sentence_transformers')" | ||
| # Not needed if you don't use the analyzer | ||
| RUN uv run python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('multi-qa-MiniLM-L6-cos-v1', cache_folder='/tmp/sentence_transformers')" |
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.
We should probably just remove this at this point? I don't think we really want to be running local models and require a download of this for docker?
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.
Let's get rid of local models, etc. in a separate PR. I already feel like this PR has gotten heavy. I can prioritize this and it should be relatively straight-forward.
docs/developer/quickstart.rst
Outdated
| $ uv sync --all-extras # Install all dependencies including dev tools | ||
| $ uv run pre-commit install # Install a code style pre-commit hook | ||
| Run the server |
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.
We should probably just remove this and only document Docker? I use the local env for my IDE to get autocomplete, but I never run the app outside of docker, and we should probably just not support it.
| ] | ||
|
|
||
| # Analyzer dependencies | ||
| analyzer = [ |
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 feel like we should also split this up into things for openai and things for local models. I'd also be fine with remove the local model support and just depend on an external API (either running locally or remote) and not in the application layer.
These deps are super heavy, and I'd really like to get away from supporting/installing them.
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 agree but let's not change too much in this PR. I think we can get rid of the local models for most cases although the tests do use them. We could mock that.
| # If you do not want the analyzer dependencies (which are LARGE), you can use: | ||
| # RUN --mount=type=cache,target=/root/.cache/uv \ | ||
| # uv sync --frozen --no-install-project --extra dev --extra production | ||
| RUN --mount=type=cache,target=/root/.cache/uv \ |
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 thought we were also talking about installing Python via uv, instead of depending on the system? Seems worth doing during this larger refactor since we're already changing a bunch of stuff, but not too set on it it you don't want to add more here.
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.
We can do that. It's a pretty trivial change. Stick with 3.12 though or go to 3.14?
|
I ran this locally and everything seems to be working! |
|
My plan is to merge this close to as-is.
|
- Fix the docs makefile - Document pre-commit
Modernizes the entire repository to use Ubuntu 24.04 LTS and Python 3.12 across all configurations, and migrates from pip-tools to uv with pyproject.toml-based dependency management for significantly faster package installation (10-100x) and better dependency resolution.
Changes
Docker Infrastructure
ubuntu:22.04→ubuntu:24.04uv pip installcommands to singleuv sync --frozenfor consistent resolution/root/.cache/pip→/root/.cache/uvin mount targetsnetcat→netcat-openbsd(Ubuntu 24.04 package name)Modern Dependency Management (pyproject.toml + uv)
requirements/*.infiles topyproject.tomlrequires-python = ">=3.12"in pyproject.tomluv.lockwith 247 packages and all transitive dependencies (4,983 lines)uv-pre-commithook to keep lock file synchronizeduv syncresolves all dependency groups together, eliminating the version mismatch issue where installing multiple requirements files separately could cause conflictsPython & Ubuntu Version Updates
.github/workflows/ci.yml): Python 3.10 → 3.12, now usesastral-sh/setup-uv@v4.github/workflows/pip-tools.yaml): Migrated from pip-tools touv lock --upgradereadthedocs.yml): ubuntu-22.04 → ubuntu-24.04, Python 3.10 → 3.12pyproject.toml): Python 3.10 → 3.12 (py310 → py312)docs/developer/quickstart.rst): Python 3.10 → 3.12, updated with uv workflowdocs/conf.py): Python 3.8 → 3.12 docs linkruntime.txt): python-3.8.12 → python-3.12Documentation
requirements/README.mdexplaining the migration from pip-tools to uvuv runprefix for consistencyBenefits
uv syncresolves all dependency groups together, preventing version mismatchesuv.lockensures exact versions across all environments (247 packages fully locked)Testing
All changes have been verified:
uv.lockfile generated with 247 packages resolvedMigration Notes
The
uv.lockfile has been fully generated with all 247 packages and their transitive dependencies pinned to exact versions. This ensures reproducible builds across all environments.Legacy
requirements/*.inandrequirements/*.txtfiles are kept for reference during the migration period but are no longer used.Original prompt
This pull request was created as a result of the following prompt from Copilot chat.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.