Skip to content

feat(python): use uv.lock by default - #8311

Merged
helderco merged 5 commits into
dagger:mainfrom
helderco:helder/dev-4476-python-use-uvlock-by-default
Sep 10, 2024
Merged

helderco merged 5 commits into
dagger:mainfrom
helderco:helder/dev-4476-python-use-uvlock-by-default

Conversation

@helderco

@helderco helderco commented Sep 3, 2024 •

Copy link
Copy Markdown
Contributor

Closes #8309
Closes #8310

Use uv.lock by default in new Dagger Modules

dagger init now creates a uv.lock file instead of a requirements.lock file, which provides a simpler workflow with uv when developing:

dagger init --sdk=python my-module
cd my-module
uv run vim .

To migrate an existing Dagger Module using requirements.lock, to uv.lock:

dagger develop
uv add --editable ./sdk

Note

The above command will not preserve the pinned versions in requirements.lock. There’s not yet a way to do it automatically, but there’s a workaround in the meantime:

  • Add all the constraints in requirements.lock to tool.uv.constraint-dependencies.
  • Run uv lock.
  • Remove the constraints from tool.uv.constraint-dependencies.

To go back to the previous behavior and replace uv.lock with requirements.lock:

uv export --no-dev --no-emit-workspace --no-emit-package=dagger-io -o requirements.lock
uv remove dagger-io
rm uv.lock

If both files exist, uv.lock will take precedence.

To know more, read about managing projects with uv, and Astral’s uv: Unified Python packaging blog post for more on what uv can do for Python users.

Modules run in Python 3.12 by default

The base image that runs Module Functions is now running Python 3.12 by default. If you need to go back to 3.11, either change requires-python = ">=3.11" in pyproject.toml, or create a .python-version file with 3.11 as the content.


TODO: Updates to the documentation website will follow in a separate PR.

@helderco helderco added this to the v0.13.0 milestone Sep 3, 2024
@helderco
helderco force-pushed the helder/dev-4476-python-use-uvlock-by-default branch 2 times, most recently from 6223192 to 6bf42c1 Compare September 8, 2024 18:43
@helderco
helderco requested a review from TomChv September 9, 2024 10:45
@helderco
helderco marked this pull request as ready for review September 9, 2024 10:45
@helderco
helderco requested a review from a team as a code owner September 9, 2024 10:45
@helderco
helderco force-pushed the helder/dev-4476-python-use-uvlock-by-default branch from 6bf42c1 to 75b29f7 Compare September 9, 2024 22:10
@helderco

helderco commented Sep 9, 2024 •

Copy link
Copy Markdown
Contributor Author

This one's ready. I added two change logs (there's a precedence for this). It wanted to split the upgrade to Python 3.12 in a separate PR but was rushed for time to get this by 0.13, so it was much easier to make both changes together.

@TomChv TomChv left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Lot of good changes in this PR! Love it!

Signed-off-by: Helder Correia <[email protected]>
Signed-off-by: Helder Correia <[email protected]>
Signed-off-by: Helder Correia <[email protected]>
@helderco
helderco force-pushed the helder/dev-4476-python-use-uvlock-by-default branch from 75b29f7 to 28530dc Compare September 10, 2024 11:06
@helderco
helderco merged commit 8ba0e9e into dagger:main Sep 10, 2024
@helderco
helderco deleted the helder/dev-4476-python-use-uvlock-by-default branch September 10, 2024 11:28
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.

Python: Default to Python 3.12 for new Modules Python: Use uv.lock by default

2 participants