-
Notifications
You must be signed in to change notification settings - Fork 795
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
build: Migrate from hatch
to uv
#3723
base: main
Are you sure you want to change the base?
Conversation
https://ss64.com/bash/mkdir.html We would want to see an error if `doc/` didn't exist. The docs wouldn't build as all the content is in that directory. Working on migrating to a cross-platform shell that doesn't require this option anyway https://www.nushell.sh/commands/docs/mkdir.html
Decouples from `bash`, simplifies (#3577 (comment))
Provides 2 interfaces: - `tasks.py`: to define using decorators - `tasks.toml`: an example of defining in a similar way to `hatch` scripts #3577 (comment)
Steps to reproduce: - `uv self update` or install `uv` for the [first time](https://docs.astral.sh/uv/getting-started/installation/) - `uv python install 3.12` - `cd $ALTAIR_REPO_ROOT` - `uv venv -p 3.12 --seed` - `uv sync --all-extras`
This is the non-`hatch` equivalent of `tool.hatch.envs.hatch-test.default-args` https://hatch.pypa.io/latest/config/internal/testing/#default-arguments
Bug revealed after changing the `pytest` task to only contain `"pytest"`
- Add docs - Handle semicolon joining in one place - align `mkdir_cmd` with `mkdir -p` (https://ss64.com/bash/mkdir.html)
`*_cmd` functions and these variables are unrelated Planning to namespace the functions, using `cmd`
All of these tools are now accessible under a single namespace, with discoverable docs
You can now safely run: ```py import tools tools.tasks.app.run(["lint", "format"]) ```
Terms like "clean", "build", "publish" have another meaning when talking about the distribution https://docs.astral.sh/uv/concepts/projects/build/
Covers part of step 8, step 9 in https://github.com/vega/altair/blob/7c2d97ffe80749a7cd1b24703547e40f4918172d/RELEASING.md
- Extra prep for string escaping while in a subprocess - Use `--force` in `git add` to override (https://github.com/vega/altair/blob/7c2d97ffe80749a7cd1b24703547e40f4918172d/doc/.gitignore#L1) - Raise a more informative error when a subprocess fails
All previous functionality is possible without this now. Did some tidying up of what is left using (https://github.com/vega/vega-datasets/blob/369b462f7505e4ef3454668793e001e3620861ff/taplo.toml) ## Remaining sections - `build`, `metadata`, `version` tables are used by `hatchling` - (https://hatch.pypa.io/latest/why/#build-backend) - The `doc` environment is retained **only** due to how `_HatchRunner` is implemented - Otherwise we can remove that - (6e792a1) - The test matrix functionality isn't something I've tried to reproduce, so left that in - Unsure how often others use it, but we could swap that out for `nox` - https://github.com/narwhals-dev/narwhals/blob/024d5d2294d1dcdd2e2f043d59eb03a3238c9e87/noxfile.py#L13
Didn't realise this was part of the Public API, as it wasn't listed in https://github.com/python-poetry/tomlkit/blob/635831f1be9b0e107047e74af8ebecc7c0e4b7bf/tomlkit/__init__.py#L31-L59 https://tomlkit.readthedocs.io/en/latest/api/#module-tomlkit.toml_file
if no_commit: | ||
print(f"Unused commit message:\n {commit_message!r}") | ||
elif branch != "main": | ||
# FIXME: Unsure how to reproduce the RELEASING.md steps from this PR | ||
# https://github.com/vega/altair/blob/main/RELEASING.md | ||
print(f"Unable to push from {branch!r}.\n" "Must be on 'main'.") | ||
else: | ||
add_commit_push_github(commit_message) |
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.
FIXME
@mattijn I was wondering if you might be able to help me with this?
Looking at altair-viz.github.io(contributors), it seems like you've run these steps the most.
All the steps up this sequence are working:
Lines 24 to 27 in 48e976e
# add commit, and push to github | |
git add . --all | |
git commit -m "$MSG" | |
git push origin master |
These are the equivalent (with --force
(404bb26)):
Lines 33 to 35 in aaca9bc
CMD_ADD = "git add . --all --force" | |
CMD_COMMIT = "git commit -m" | |
CMD_PUSH = "git push origin master" |
Which are run in:
add_commit_push_github()
Lines 106 to 113 in aaca9bc
def add_commit_push_github(msg: str, /) -> None: | |
os.chdir(DOC_REPO_DIR) | |
print("Pushing ...") | |
# NOTE: Ensures the message uses cross-platform escaping | |
cmd_commit = *CMD_COMMIT.split(" "), msg | |
commands = (CMD_ADD, cmd_commit, CMD_PUSH) | |
for command in commands: | |
run_check(command) |
Problem
Delete L146-L149 and it produces an error that I'm unsure how to solve.
AFAIK, it didn't seem to be related to permissions on https://github.com/altair-viz/altair-viz.github.io - but that is a blocker I'm expecting
RELEASING.md
Lines 37 to 54 in 48e976e
7. Merge release branch into main, make sure that all required checks pass | |
8. On main, build source & wheel distributions. If you work on a fork, replace `origin` with `upstream`: | |
git switch main | |
git pull origin main | |
hatch clean # clean old builds & distributions | |
hatch build # create a source distribution and universal wheel | |
9. publish to PyPI (Requires correct PyPI owner permissions): | |
hatch publish | |
10. build and publish docs (Requires write-access to altair-viz/altair-viz.github.io): | |
hatch run doc:publish-clean-build | |
11. On main, tag the release. If you work on a fork, replace `origin` with `upstream`: |
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 know if this can be resolved prior to merging to main
.
100% sure it will need an assist from one of you fine people 🙂
hatch
to uv
hatch
to uv
- Allows `uv run tools/tasks.py test` to be replaced with `uv run task test` - Handles subprocess better for `pytest` and `sphinx-build` Suggested in astral-sh/uv#5903 (comment)
Currently blocking `generate-schema-wrapper e43e464
Left markdown comments on sections that still need work
Switching directories is handled by https://github.com/taskipy/taskipy?tab=readme-ov-file#working-directory
Reverts a good chuck of new stuff added in this PR, prior to 00f353a Next commit will refactor some of what is left - to simplify `[tool.taskipy.tasks]`
- Has parts of prior `sync_website.py` - Utilizes for more concises commands in `[tool.taskipy.tasks]`
Easier to maintain and understand if this is in one place
- Add missing entries to `__all__` - Add missing `copytree` doc - Remove incorrect `dir_exists` doc
Important I did a bit of a drive-by fix on The current instructions send you along this route to get to how to contribute:
I remember this confusing me when I first contributed and it happened again while I was updating the docs. |
Will close #3577
Description
This PR transitions us from
hatch
touv
with a solution for the issue I raised in (#3577 (comment)).Note
Don't be alarmed by the +3k additions, it is mostly in
uv.lock
More info
Using
uv
Install
uv
for the first time or run:Install python:
Go to the root of the repo:
cd altair/
Initialize a new virtual env:
Install/update dependencies:
Also see CONTRIBUTING
Task Runner
I've been following astral-sh/uv#5903 pretty closely and after experimenting rolling my own runner - I settled on https://github.com/taskipy/taskipy.
Usage
Works in a similar way to
hatch run ...
, with commands defined in[tool.taskipy.tasks]
.Changes
Composition
Composing tasks uses
"... && ..."
, rather than["...", "..."]
Invoking
Invoking a task:
Alternatives
These were also mentioned in astral-sh/uv#5903.
uv
integration is newnoxfile.py
make
pyproject.toml
hatch
venv
and no support foruv
I chose
taskipy
as:The last point is quite apparent when looking at the changes in (00f353a) vs (https://github.com/vega/altair/blob/ba836abb77b8e1eb8b5d194ed9442916ccdbf2a9/tasks.toml)
Tasks
hatch
config frompyproject.toml
(e8d57cd)hatch clean
hatch build
hatch publish
sync_website.py
(https://github.com/altair-viz/altair-viz.github.io)RELEASING.md
NOTES_FOR_MAINTAINERS.md
README.md
uv pip
interfacelint.yml
docbuild.yml
build.yml
to better utilizeuv
#3725tasks.py
,_tasks.py
(b9e6eb9), (2ed212a)