-
Notifications
You must be signed in to change notification settings - Fork 455
CDRIVER-6042 Migrate Python scripts from Poetry to Astral UV #2039
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
Conversation
@eramongodb TBH, I am not certain. But don't worry about that for now. Things are a bit of a mess with the packaging since the 2.0 release and I will need to rework several different things. If this happens to break building the docs, I'm sure that I'll encounter the failure as I work on updating the packaging for 2.0 and I'll deal with it then. |
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.
LGTM with one remaining update. Thank you for the change. uv
seems simpler to use (no separate install step) and faster.
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.
Sorry to delay, thought I had approved this last week. LGTM.
🎉🎉🎉🥳
I think there is potential benefit to a uv.sh
shim akin to poetry.sh
, but YAGNI until we actually need it.
* CDRIVER-5891 address implicit bool-to-null conversion in return statements (#1888) * CDRIVER-5891 extend C standard coverage up to C23 (#1890) * CDRIVER-5959 sync change streams unified spec tests with 0aee4aad (#1971) * CDRIVER-5304 set cluster time in test sessions (#2008) * Ignore -Wpre-c11-compat warnings when building public-header-warnings (#2027) * CDRIVER-6042 Migrate Python scripts from Poetry to Astral UV (#2039) * Migrate EVG task coverage to latest Debian, Ubuntu, and RHEL distros (#2044) * CDRIVER-6010 use `ec2.assume_role` for Azure KMS task (#2051) * CDRIVER-5971 Use Amazon ECR to obtain OCI images in EVG (#2058) * update Earthly version from 0.8.3 to 0.8.16 (#2072) --------- Co-authored-by: Kevin Albertson <[email protected]>
* CDRIVER-5959 temporarily restrict updateDescription tests to 8.1 or older (#1970) * CDRIVER-5959 sync change streams unified spec tests with 0aee4aad (#1971) * CDRIVER-5304 set cluster time in test sessions (#2008) * CDRIVER-6010 use `ec2.assume_role` for mongohouse task (#2025) * Ignore -Wpre-c11-compat warnings when building public-header-warnings (#2027) * CDRIVER-6042 Migrate Python scripts from Poetry to Astral UV (#2039) * Migrate EVG task coverage to latest Debian, Ubuntu, and RHEL distros (#2044) * CDRIVER-6010 use `ec2.assume_role` for Azure KMS task (#2051) * CDRIVER-5971 Use Amazon ECR to obtain OCI images in EVG (#2058) * CDRIVER-5874 Drop Debian 10 EVG task coverage (#2062) * update Earthly version from 0.8.3 to 0.8.16 (#2072) --------- Co-authored-by: Kevin Albertson <[email protected]>
Resolves CDRIVER-6042. Followup to mongodb/mongo-cxx-driver#1244.
Migrates our Python script configuration and runner from Poetry to Astral UV. This removes the need for manual virtual environment handling, package dependency installation steps, and Python binary compatibility and version management.
Tip
As a reminder, all
uv
commands should be invoked with--frozen
by default to avoid updating theuv.lock
file. TheUV_FROZEN
environment variable can also be set to1
,true
,on
, etc. instead.Scripts which are affected by these changes include:
.evergreen/scripts/clang-format-all.sh
.evergreen/config_generator/*
.evergreen/legacy_config_generator/*
.evergreen/scripts/build-docs.sh
These scripts and related docs have been updated to require/assume invocation via
uv run
. All necessary dependencies (e.g.clang-format
,shrub-py
,sphinx
, etc.) are managed by thepyproject.toml
file and implicitly installed during theuv run
command. As a CI optimization (not a requirement), the--only-group
flag is used to limit the set of packages downloaded for the given task (e.g.format
forclang-format
,docs
forsphinx
).Because Poetry is no longer used, the following helper scripts are removed by this PR:
tools/poetry.sh
(provided by user/system)tools/poetry.ps1
(provided by user/system)tools/python.sh
(handled by uv)Following DEVPROD-13413, most (but not quite all) EVG distros provide a system-installed
uv
binary. Due to the set of tasks requiring uv being relatively small compared to the C++ Driver, theuv-installer.sh
script andInstallUV
component function do not need to be ported over from the C++ Driver. Instead, theubuntu2004
distro (one of the distros currently missing a system-installeduv
) is removed from the list of allowed distros for theclang-format
task. As a result, all tasks which invokeuv
are on distros which provide a system-installeduv
binary (specifically,ubuntu2204
).All dependencies and affected scripts were tested with:
-p <python-version>
(Python versions 3.10 through 3.13).--no-project
(do not use an existing project or workspace).--isolated
(do not reuse the project's virtual environment).--with <dependency>
(to discover and minimize required dependencies).--resolution lowest-direct
(to validate minimum version requirements, but without lowering current requirements).--resolution highest
(the default; to validate forward compatibility with latest versions)This PR does not update minimum required versions for existing dependencies. However, this PR proposes relaxing the max version requirements so newer package versions may be used. Specifically,
>=
is used instead of~=
(equivalent to^
for Poetry). Only packages which must be pinned to a specific version use~=
, which is currently limited toclang-format
.Note
The
uv tree
command displays a helpful visualization of the current package dependency tree. This tree can be used to optimize the list of dependencies. For example,uv tree --outdated --resolution lowest-direct
for the currently proposed dependency list produces the following (abbreviated):Aside: I do not know to prevent
uv tree
with--resolution lowest-direct
from updating the lock file while still evaluating the lowest-direct tree as intended. Passing--frozen
returns thehighest
resolution tree (unmodified). 🤔Additional notes:
sphinx-autobuild
) are removed. Instead, the--with <package>
flag can be used when needed (e.g. see updated instructions in CONTRIBUTING.md). For local development environments,uv pip install
can also be used obtain additional packages without modifying the lock file.yamlordereddictloader
dependency, which is deprecated, has been replaced withyamlloader
instead. This is used by the legacy config generator. Since no prior minimum requirement exists, I've set it to the latest release version (1.5.1 due to 1.5.0 being yanked).mc-evg-generate
entry point, uv requires defining a build system. This PR proposes using Hatchling, the default choice for uv. This also allowsconfig_generator
to be defined as a package, enablingimport config_generator
by other Python scripts within this project (analogous topackages = [ include = "config_generator" ]
with Poetry).--fresh
CMake flag is added tobuild-docs.sh
so that the CMake cache will not incorrectly continue to reuse a Sphinx binary when the script is rerun with an updated Python virtual environment (possibly an entirely new, isolated virtual environment) which provides its own distinct Sphinx binary.RemovedInSphinx90Warning
warnings. These are deliberately ignored for now in favor of applying a<9.0
dependency requirement to avoid breaking changes when Sphinx 9.0 is released. These should be addressed by CDRIVER-6031.doc2path()
should be namedbase
, which is neitherabsolute
(current) norbasedir
(previous) following Fix Debian package build #1470 (CDRIVER-4773). I do not know what's going on with this function, but I've opted to remove the named parameter entirely in favor of simply passingTrue
. (@rcsanchez97 does this change break Debian doc builds again?)