-
Notifications
You must be signed in to change notification settings - Fork 486
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
Use uv
for Python tasks
#3955
Use uv
for Python tasks
#3955
Conversation
This has not been done in a while.
75ce7b2
to
1e3af45
Compare
I actually have a local branch where I switched to Hatch, but I'm not happy with it yet. Is that something you considered? |
My local branch (which had been intermingled with other changes, so I pulled this out) was on PDM prior to this proposal. I’ve tried Poetry, PDM, Hatch, and now uv (I haven't tried Rye for this, but this is by the same team that does Rye). And, of course, the manual way. Poetry is the oldest and most mature, but also doesn't fully conform to the packaging PEPs, and I found Hatch nearly unusable. PDM is currently nicer than uv (because it includes task running directly, see astral-sh/uv#5903), and offers a GitHub setup action as well. uv is the designated successor to Rye, but Rye is still being developed as uv improves (currently rye uses parts of uv for package resolution, but the original developer of rye is now working on uv as well). There are some really interesting things with respect to $ uvx --with mkdocs-material==9.5.34 --with mkdocs-mermaid2-plugin==1.1.1 \
--with pymdown-extensions==10.10.1 [email protected]
# or
$ uv tool install [email protected] --with mkdocs-material==9.5.34 \
--with mkdocs-mermaid2-plugin==1.1.1 \
--with pymdown-extensions==10.10.1
$ uvx mkdocs That replaces The I chose not to go that direction for several reasons:
|
All valid points. I don't think there is much value in setting I was going to add it to this PR, but I don't want to complicate anything yet, so I think I'll just write it here for now.
|
I can tweak the format-yaml bits to have the dependencies go one way, and then we can revisit the format-yaml script in a different PR. |
1e3af45
to
3f47420
Compare
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 fantastic, thank you!
3f47420
to
0fbe841
Compare
Python packaging is in flux, but the old form of requirements (`requirements.txt`) is no longer recommended. The use of a more modern alternative (such as Poetry, PDM, Rye, or uv) is recommended as they also provide dependency lock files so that downstream dependencies are not updated on installation. For a project that is not written in Python, `uv` looks likely to be the best choice because it can also manage the Python installation, using a suitable existing Python installation if present. As `uv` does not currently support running tasks (unlike Poetry and pdm), we have added `taskipy` with useful shorthand tasks defined for this purpose: | name | command | | ----------- | -------------------------------------------- | | build-docs | mkdocs build -f assets/chezmoi.io/mkdocs.yml | | serve-docs | mkdocs serve -f assets/chezmoi.io/mkdocs.yml | | deploy-docs | cd assets/chezmoi.io && mkdocs gh-deploy | | lint | ruff check | | format | ruff format | | pycheck | task lint && task format --diff | | pyfix | task lint --fix && task format | | format-yaml | make format-yaml | These are run with `uv run task <name>`. Note that `make format-yaml` is the preferred way to format YAML documents, and it runs the `format-yaml.py` script directly.`
0fbe841
to
593c2d8
Compare
I’m tracking the task management issue previously mentioned for uv; when it is implemented, I’ll transition the tasks off taskipy and into native uv tasks. (I will probably do so in stages so that |
I’ll look at merging this tomorrow as I’m not around to watch it if something breaks on merge. Because the docs push commands have been updated, we should be aware of this for the next release but I don't think anything will break. |
I just tagged |
I love it when everything works like it's supposed to. |
Python packaging is in flux, but the old form of requirements (
requirements.txt
) is no longer recommended. The use of a more modern alternative (such as Poetry, PDM, Rye, or uv) is recommended as they also provide dependency lock files so that downstream dependencies are not updated on installation.For a project that is not written in Python,
uv
looks likely to be the best choice because it can also manage the Python installation, using a suitable existing Python installation if present.As
uv
does not currently support running tasks (unlike Poetry and pdm), we have addedtaskipy
with useful shorthand tasks defined for this purpose:These are run with
uv run task <name>
. Note thatmake format-yaml
is the preferred way to format YAML documents, and it runs theformat-yaml.py
script directly.During development of this, it was discovered that the YAML files in the repo have not been formatted recently, so this was done as a separate commit at the head of this branch.