Skip to content

Replace hatch env layer with native uv commands#8510

Merged
manzt merged 22 commits intomainfrom
push-kmswtyynuukw
Mar 11, 2026
Merged

Replace hatch env layer with native uv commands#8510
manzt merged 22 commits intomainfrom
push-kmswtyynuukw

Conversation

@manzt
Copy link
Collaborator

@manzt manzt commented Feb 27, 2026

Many of the APIs are similar and I'm curious what this would look like in CI. Converts hatch environments to PEP 735 dependency groups and replaces hatch run with uv run --group across Makefile, scripts, workflows, and docs. Keeps hatch publish for releases.

@vercel
Copy link

vercel bot commented Feb 27, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
marimo-docs Error Error Mar 11, 2026 5:29pm

Request Review

@manzt manzt added the internal A refactor or improvement that is not user facing label Feb 27, 2026
Comment on lines -285 to -297
[tool.hatch.envs.test.scripts]
test = "pytest{env:HATCH_TEST_ARGS:} {args:tests}"
default = "pytest{env:HATCH_TEST_ARGS:} {args:tests}"
# This is used externally from the narwhals repo to run our tests from their repo.
# This should include any tests that may use narwhals.
# It is ok if we test more than narwhals here, but we should not test less.
test-narwhals = """
pytest{env:HATCH_TEST_ARGS:} \
tests/_data/ \
tests/_plugins/ui/_impl/ \
tests/_utils/test_narwhals_utils.py
"""

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

moved into Makefile

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

akshayka
akshayka previously approved these changes Feb 28, 2026
mscolnick
mscolnick previously approved these changes Mar 3, 2026
Copy link
Contributor

@mscolnick mscolnick left a comment

Choose a reason for hiding this comment

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

looks good

manzt and others added 22 commits March 11, 2026 13:29
Many of the APIs are similar and I'm curious what this would look like
in CI. Converts hatch environments to PEP 735 dependency groups and
replaces `hatch run` with `uv run --group` across Makefile, scripts,
workflows, and docs. Keeps `hatch publish` for releases.
The narwhals repo used to invoke `hatch run test:test-narwhals`
externally to run marimo's narwhals-related tests. That hatch script
entry point was removed in the hatch-to-uv migration, so this preserves
the capability as a Makefile target.
The `~=10.4.0` constraint forced pillow 10.4.x which lacks prebuilt
wheels for some platform/Python combos, causing compilation failures
when jpeg headers aren't available. Using `>=10.4.0` lets uv pick a
newer version with wheels.
Under hatch, `UV_RESOLUTION: lowest` was scoped to an isolated test
environment. With `uv run`, resolution covers the entire project
including all dependency groups, so transitive deps like `lz4` were
getting pinned to unbuildable ancient versions. `lowest-direct` still
validates that marimo works with its minimum declared dependency
versions without forcing the lowest possible transitive deps.
The repo now has a `.python-version` file that uv respects by default,
so hardcoding `--python 3.12` (or 3.13) in the Makefile and CI is
redundant and creates a maintenance burden when the target version
changes. Removing it from dev commands (codegen, snapshots, narwhals
tests) and the non-matrix CI coverage job lets `.python-version` be the
single source of truth.

Documentation examples in AGENTS.md files are updated to show the
three-command pattern: default run, optional deps, and explicit
`--python` override for when you need a specific version.
Running changed-file tests across Python versions locally previously
meant manually invoking uv/pytest for each version. This script wraps
the pytest-changed plugin with a version matrix loop, defaulting to
3.10–3.13 with `test-optional` deps and diffing against `main`. A user
can narrow to a single version with `--python` or switch to core-only
deps with `--group test`. Extra pytest flags pass through after `--`.
`uv run` sets `UV` to the absolute path of its binary, which leaked into
tests causing `infer_package_manager()` to always return `"uv"` and
`find_uv_bin()` to return a full path instead of bare `"uv"`. This broke
mock assertions, snapshot tests, and config inference tests. Clearing it
at the top of conftest before any marimo imports fixes all of these.
The CLI test job installs marimo from a wheel (which includes
`_static/index.html`), but pytest runs from the repo checkout where the
local `marimo/` source directory shadows the installed package. Since
the checkout has no built frontend assets, the export HTML tests fail
with a missing `index.html`. Changing the working directory to
`runner.temp` before running pytest ensures Python imports the
wheel-installed package.

Also drops the redundant `--group=test` since `test-optional` already
includes it via `include-group`.
`black` was removed as a dev dependency since it is only used as an
optional runtime dependency behind lazy imports with try/except guards.
This adds `type: ignore[import-not-found]` to the two import sites so
mypy doesn't fail when `black` isn't installed in the typecheck
environment, consistent with how all other optional imports are handled
in the codebase.
The CLI tests `cd` to a temp directory before running pytest via `uv run
--no-project` to ensure tests run against the installed wheel rather
than the source checkout. After the hatch-to-uv migration, uv can no
longer discover the venv created in the workspace directory once the
working directory changes. Setting `VIRTUAL_ENV` explicitly points uv
back to the right venv.
After migrating from hatch to uv, the shared `.venv` includes packages
like `ibis-framework` from test-optional, causing mypy to raise
`import-untyped` errors. Using `--only-group typecheck` restores the
isolated environment hatch provided.
On Windows, `${{ runner.temp }}` expands to `D:\a\_temp` which bash
interprets as escape sequences (`\a`, `\_`), producing `D:a_temp`.
Single quotes prevent bash from processing the backslashes.
The `# type: ignore[import-not-found]` on the black import causes mypy
to treat the module as `Any` when black isn't installed, which cascades
into a `no-any-return` error on the return value of `format_str`.
The `cd ${{ runner.temp }}` broke tests like `test_openapi_up_to_date`
that use paths relative to the repo root. `--no-project` is sufficient
to prevent uv from discovering and rebuilding the project from source.
The setup section previously led with pixi as the primary tool, which
caused confusion for contributors who don't use it. This restructures
the guide to lead with the prerequisites we actually use on the team
(uv, Node 20+, pnpm 9+) and a minimal getting started flow. Pixi and
Gitpod are mentioned as unsupported alternatives in a tip callout.
@manzt manzt merged commit 707e285 into main Mar 11, 2026
32 of 50 checks passed
@manzt manzt deleted the push-kmswtyynuukw branch March 11, 2026 17:58
@github-actions
Copy link

🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.20.5-dev42

dmadisetti pushed a commit that referenced this pull request Mar 11, 2026
Many of the APIs are similar and I'm curious what this would look like
in CI. Converts hatch environments to PEP 735 dependency groups and
replaces `hatch run` with `uv run --group` across Makefile, scripts,
workflows, and docs. Keeps `hatch publish` for releases.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal A refactor or improvement that is not user facing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants