Skip to content
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

Open
wants to merge 46 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
5819a2e
ci: remove unused `--parents` option
dangotbanned Dec 24, 2024
ddc8358
ci: replace `sync_website.sh` with `.py`
dangotbanned Dec 24, 2024
6ebc0ee
ci(DRAFT): migrate `hatch` scripts to hybrid `tasks.py` runner
dangotbanned Dec 29, 2024
fbc5a0f
ci: switch `Tasks` runner to `"uv"`
dangotbanned Dec 29, 2024
f614e4f
build(uv): Generate `uv.lock`
dangotbanned Dec 29, 2024
0fa8ecc
refactor: Move `PYTEST_ARGS` -> `tool.pytest.ini_options.addopts`
dangotbanned Dec 29, 2024
dca3f0d
fix: Add recursive guard during `Tasks._expand`
dangotbanned Dec 29, 2024
8bf774f
ci: add `export-tasks` and update `tasks.toml`
dangotbanned Dec 29, 2024
3513259
ci: try fixing `anywidget` import error
dangotbanned Dec 29, 2024
c160c4c
feat: Improve `*_cmd` functions
dangotbanned Dec 29, 2024
53bc298
refactor: reduce overloading of term `"cmd"`
dangotbanned Dec 29, 2024
8323881
feat: adds `cmd` helper class
dangotbanned Dec 29, 2024
1fd5790
chore: re-enable `tasks.py` export
dangotbanned Dec 29, 2024
cd9ccf9
docs: fix incorrect import path
dangotbanned Dec 29, 2024
ee426d9
Merge branch 'main' into migrate-hatch-scripts
dangotbanned Dec 29, 2024
74c10bb
ci: Prefix doc-related tasks
dangotbanned Dec 30, 2024
9900aa1
ci: Adds `clean`, `build`, `publish` tasks
dangotbanned Dec 30, 2024
ba836ab
ci: disable hard-coded no-op for `tools/sync_website.py`
dangotbanned Dec 30, 2024
404bb26
fix(DRAFT): resolve some `sync_website.py` issues
dangotbanned Dec 30, 2024
9285871
ci: Add different no-op in `sync_website.py`
dangotbanned Dec 30, 2024
6e792a1
fix: Resolve typo in `hatch` extras check
dangotbanned Dec 31, 2024
e8d57cd
ci: Remove all unused `hatch` config
dangotbanned Dec 31, 2024
1c0310b
refactor: Use `tomlkit.toml_file_TOMLFile` directly
dangotbanned Dec 31, 2024
fc6496f
ci: Support updating `tasks` table in-place
dangotbanned Dec 31, 2024
aaca9bc
Merge branch 'main' into migrate-hatch-scripts
dangotbanned Jan 1, 2025
9150935
Merge remote-tracking branch 'upstream/main' into migrate-hatch-scripts
dangotbanned Jan 2, 2025
f240884
Merge remote-tracking branch 'upstream/main' into migrate-hatch-scripts
dangotbanned Jan 2, 2025
b61dc3c
Merge remote-tracking branch 'upstream/main' into migrate-hatch-scripts
dangotbanned Jan 6, 2025
f3a7f62
ci(uv): sync dependencies
dangotbanned Jan 6, 2025
e43e464
chore(typing): Ignore `mypy` inference
dangotbanned Jan 6, 2025
00f353a
ci: Port to `taskipy`
dangotbanned Jan 7, 2025
d79f621
Merge remote-tracking branch 'upstream/main' into migrate-hatch-scripts
dangotbanned Jan 8, 2025
0e099de
docs(DRAFT): Update some of `CONTRIBUTING.md`
dangotbanned Jan 8, 2025
b116d29
docs: Update `NOTES_FOR_MAINTAINERS.md`
dangotbanned Jan 8, 2025
a9bcba1
docs: Update `README.md`
dangotbanned Jan 8, 2025
6d89e85
docs: Update `RELEASING.md`
dangotbanned Jan 8, 2025
d9b0de2
docs: Update `CONTRIBUTING.md#Setting Up Your Environment`
dangotbanned Jan 8, 2025
8c1f143
docs: Update test matrix guidance
dangotbanned Jan 8, 2025
361df23
Merge remote-tracking branch 'upstream/main' into migrate-hatch-scripts
dangotbanned Jan 9, 2025
872d337
ci(uv): run `uv sync --all-extras`
dangotbanned Jan 9, 2025
20f2894
ci(uv): Switch `lint.yml` to `uv sync`
dangotbanned Jan 9, 2025
449aaac
ci(uv): Switch `docbuild.yml` to `uv sync`
dangotbanned Jan 9, 2025
b9e6eb9
revert: Remove `_tasks.py` dependents
dangotbanned Jan 9, 2025
2ed212a
refactor: Remove `_tasks.py`, work into `fs.py`
dangotbanned Jan 9, 2025
2b962ea
docs: Deduplicate dev instructions
dangotbanned Jan 9, 2025
0ed58e5
chore: misc cleaning up `tools.fs`
dangotbanned Jan 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
fi
- name: Test with pytest
run: |
uv run pytest --pyargs --numprocesses=logical --doctest-modules tests
uv run pytest --pyargs --numprocesses=logical --doctest-modules --doctest-ignore-import-errors tests
- name: Validate Vega-Lite schema
run: |
# We install all 'format' dependencies of jsonschema as check-jsonschema
Expand Down
14 changes: 8 additions & 6 deletions .github/workflows/docbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ name: docbuild

on: [push, pull_request]

env:
UV_SYSTEM_PYTHON: 1

jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -16,13 +13,18 @@ jobs:
python-version: "3.12"
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
cache-dependency-glob: |
**/uv.lock
**/pyproject.toml
- name: Install dependencies
run: uv pip install -e ".[dev, all, doc]"
- name: Run doc:build-html
run: uv sync --all-extras
- name: Build docs
run: |
mkdir -p doc/_images
uv run sphinx-build -b html -d doc/_build/doctrees doc doc/_build/html
- name: Run doc:doctest
- name: Run doctests
run: |
uv run sphinx-build -b doctest -d doc/_build/doctrees doc doc/_build/doctest

Expand Down
13 changes: 9 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,20 @@ jobs:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
cache-dependency-glob: |
**/uv.lock
**/pyproject.toml
# Installing all dependencies and not just the linters as mypy needs them for type checking
- name: Install dependencies
run: uv pip install -e ".[dev, all]" --system
- name: Lint with ruff
run: uv sync --all-extras
- name: ruff check (lint)
run: |
uv run ruff check
- name: Check formatting with ruff
- name: ruff format
run: |
uv run ruff format --check --diff
- name: Lint with mypy
- name: mypy (type check)
run: |
uv run mypy altair tests
94 changes: 62 additions & 32 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,54 @@ git clone https://github.com/YOUR-USERNAME/altair.git
To keep your fork up to date with changes in this repo,
you can [use the fetch upstream button on GitHub](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork).

Now you can install the latest version of Altair locally using `pip`.
The `-e` flag indicates that your local changes will be reflected
every time you open a new Python interpreter
(instead of having to reinstall the package each time).

[Install `uv`](https://docs.astral.sh/uv/getting-started/installation/), or update to the latest version:

```cmd
uv self update
```
Install Python:

```cmd
uv python install 3.12
```

Initialize a new virtual environment:

```cmd
cd altair/
python -m pip install -e ".[all, dev]"
cd altair/
uv venv -p 3.12
```

'[all, dev]' indicates that pip should also install the optional and development requirements
which you can find in `pyproject.toml` (`[project.optional-dependencies]/all` and `[project.optional-dependencies]/dev`)
Activate your environment:

<details><summary>macOS/Linux</summary>
<p>

```bash
source .venv/bin/activate
```

</p>
</details>

<details><summary>Windows</summary>
<p>

```cmd
.venv\Scripts\activate
```

</p>
</details>

Install the project with all development dependencies:
```cmd
uv sync --all-extras
```

> [!TIP]
> If you're new to `uv`, check out their [Getting started](https://docs.astral.sh/uv/getting-started/) guide for help

### Creating a Branch

Expand All @@ -59,7 +95,7 @@ make sure to run the following to see if there are any changes
to the automatically generated files:

```bash
hatch run generate-schema-wrapper
uv run task generate-schema-wrapper
```

For information on how to update the Vega-Lite version that Altair uses,
Expand All @@ -72,7 +108,7 @@ it is recommended that you run the Altair test suite,
which includes a number of tests to validate the correctness of your code:

```bash
hatch test
uv run task test
```


Expand All @@ -83,14 +119,15 @@ Study the output of any failed tests and try to fix the issues
before proceeding to the next section.

#### Failures on specific python version(s)
By default, `hatch test` will run the test suite against the currently active python version.

By default, `uv run task test` will run the test suite against the currently active python version.
Two useful variants for debugging failures that only appear *after* you've submitted your PR:

```bash
# Test against all python version(s) in the matrix
hatch test --all
# Test against a specific python version
hatch test --python 3.8
uv run task test-all
# Test against our minimum required version
uv run task test-min
```

See [hatch test](https://hatch.pypa.io/latest/cli/reference/#hatch-test) docs for other options.
Expand All @@ -99,7 +136,7 @@ See [hatch test](https://hatch.pypa.io/latest/cli/reference/#hatch-test) docs fo
If `test_completeness_of__all__` fails, you may need to run:

```bash
hatch run update-init-file
uv run task update-init-file
```
However, this test usually indicates *unintentional* addition(s) to the top-level `alt.` namespace that will need resolving first.

Expand Down Expand Up @@ -204,27 +241,20 @@ Some additional notes:

The process to build the documentation locally consists of three steps:

1. Clean any previously generated files to ensure a clean build.
2. Generate the documentation in HTML format.
3. View the generated documentation using a local Python testing server.

The specific commands for each step depend on your operating system.
Make sure you execute the following commands from the root dir of altair and have [`hatch`](https://hatch.pypa.io/) installed in your local environment.
1. **Clean** (remove) any previously generated documentation files.
2. **Build** the documentation in HTML format.
3. View the documentation using a *local* Python testing **server**.

- For MacOS and Linux, run the following commands in your terminal:
```bash
hatch run doc:clean-all
hatch run doc:build-html
hatch run doc:serve
```

- For Windows, use these commands instead:
Steps 1 & 2 can be run as a single command, followed by step 3:
```cmd
hatch run doc:clean-all-win
hatch run doc:build-html-win
hatch run doc:serve
uv run task doc-clean-build
uv run task doc-serve
```

> [!TIP]
> If these commands were not available for you, make sure you've [set up your environment](#setting-up-your-environment)


To view the documentation, open your browser and go to `http://localhost:8000`. To stop the server, use `^C` (control+c) in the terminal.

---
Expand Down
6 changes: 3 additions & 3 deletions NOTES_FOR_MAINTAINERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ The core Python API for Altair can be found in the following locations:
- ``altair/vegalite/v5/schema/``

All the files within these directories are created automatically by running
the following script from the root of the repository:
the following script:

```bash
hatch run generate-schema-wrapper
uv run task generate-schema-wrapper
```

This script does a couple things:
Expand Down Expand Up @@ -86,7 +86,7 @@ These additional methods have fairly good test coverage, so running the test
suite should identify any inconsistencies:

```bash
hatch test
uv run task test
```

Generally, minor version updates (e.g. Vega-Lite 2.3->2.4) have been relatively
Expand Down
11 changes: 1 addition & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,19 +108,10 @@ you can post it on [StackOverflow](https://stackoverflow.com/questions/tagged/al
For bugs and feature requests, please open a [Github Issue](https://github.com/vega/altair/issues).

## Development

[![Hatch project](https://img.shields.io/badge/%F0%9F%A5%9A-Hatch-4051b5.svg)](https://github.com/pypa/hatch)
[![uv](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json)](https://github.com/astral-sh/uv)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![pytest](https://img.shields.io/badge/logo-pytest-blue?logo=pytest&labelColor=5c5c5c&label=%20)](https://github.com/pytest-dev/pytest)

You can find the instructions on how to install the package for development in [the documentation](https://altair-viz.github.io/getting_started/installation.html).

To run the tests and linters, use

```bash
hatch test
```

For information on how to contribute your developments back to the Vega-Altair repository, see
[`CONTRIBUTING.md`](https://github.com/vega/altair/blob/main/CONTRIBUTING.md)

Expand Down
29 changes: 12 additions & 17 deletions RELEASING.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
1. Check all [Vega project](https://github.com/orgs/vega/repositories?type=source) versions are up-to-date. See [NOTES_FOR_MAINTAINERS.md](NOTES_FOR_MAINTAINERS.md)

2. Make sure to have an environment set up with `hatch` installed. See [CONTRIBUTING.md](CONTRIBUTING.md).
Remove any existing environments managed by `hatch` so that it will create new ones
with the latest dependencies when executing the commands further below:

2. Make sure to have [set up your environment](CONTRIBUTING.md#setting-up-your-environment).
Update your environment with the latest dependencies:

hatch env prune
uv sync --all-extras

3. Make certain your branch is in sync with head, and that you have no uncommitted modifications. If you work on a fork, replace `origin` with `upstream`:

git checkout main
git pull origin main
git status # Should show "nothing to commit, working tree clean"

4. Do a clean doc build:

hatch run doc:clean-all
hatch run doc:build-html
hatch run doc:serve
4. Do a [clean doc build](CONTRIBUTING.md#building-the-documentation-locally):

Navigate to http://localhost:8000 and ensure it looks OK (particularly
do a visual scan of the gallery thumbnails).
Expand All @@ -38,20 +34,19 @@

8. Merge release branch into main, make sure that all required checks pass

9. On main, build source & wheel distributions. If you work on a fork, replace `origin` with `upstream`:
9. Switch to main, 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

10. publish to PyPI (Requires correct PyPI owner permissions):

10. Build a source distribution and universal wheel,
publish to PyPI (Requires correct PyPI owner permissions and [UV_PUBLISH_TOKEN](https://docs.astral.sh/uv/configuration/environment/#uv_publish_token)):

hatch publish
uv run task publish

11. build and publish docs (Requires write-access to altair-viz/altair-viz.github.io):
11. Build and publish docs (Requires write-access to [altair-viz/altair-viz.github.io](https://github.com/altair-viz/altair-viz.github.io)):

hatch run doc:publish-clean-build
uv run task doc-publish-clean-build

12. On main, tag the release. If you work on a fork, replace `origin` with `upstream`:

Expand Down
22 changes: 0 additions & 22 deletions doc/getting_started/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,6 @@ Altair can also be installed with just the dependencies necessary for saving cha
Development Installation
========================

The `Altair source repository`_ is available on GitHub. Once you have cloned the
repository and installed all the above dependencies, run the following command
from the root of the repository to install the main version of Altair:

.. code-block:: bash

pip install -e .

To install optional and development dependencies as well, run

.. code-block:: bash

pip install -e ".[all, dev]"

If you do not wish to clone the source repository, you can install the
development version directly from GitHub using:

.. code-block:: bash

pip install -e git+https://github.com/vega/altair.git

Please see `CONTRIBUTING.md <https://github.com/vega/altair/blob/main/CONTRIBUTING.md>`_
for details on how to contribute to the Altair project.

Expand All @@ -62,4 +41,3 @@ for details on how to contribute to the Altair project.
.. _vega_datasets: https://github.com/altair-viz/vega_datasets
.. _JupyterLab: http://jupyterlab.readthedocs.io/
.. _Jupyter Notebook: https://jupyter-notebook.readthedocs.io/
.. _Altair source repository: http://github.com/vega/altair
27 changes: 0 additions & 27 deletions doc/sync_website.sh

This file was deleted.

Loading
Loading