Skip to content

fix(devshell): isolate uv from Nix Python packages - #40

Merged
jcardozo-eth merged 1 commit into
mainfrom
fix/ci-pytest-environment-isolation
Sep 8, 2026
Merged

fix(devshell): isolate uv from Nix Python packages#40
jcardozo-eth merged 1 commit into
mainfrom
fix/ci-pytest-environment-isolation

Conversation

@jcardozo-eth

@jcardozo-eth jcardozo-eth commented Sep 8, 2026

Copy link
Copy Markdown
Member

Closes #39.

Summary

Before this change, Nix development shells exposed Python packages propagated by Nix’s pre-commit package through PYTHONPATH. Those entries took precedence over uv’s project environment, so uv run pytest could launch pytest from .venv while importing _pytest from the Nix store.

The shared development-shell shellHook now unsets the inherited PYTHONPATH before installing Git hooks. Project commands therefore resolve dependencies from .venv, while Nix’s wrapped pre-commit executable continues to install and run normally.

This fixes the environment mismatch exposed by #38 without changing CI commands or project dependencies.

Test plan

  • In py310 through py314, verify PYTHONPATH is unset, pytest imports from the matching .venv, no Nix-store site-packages entries appear in sys.path, and all 78 tests pass.
  • Run pre-commit validate-config .pre-commit-config.yaml and pre-commit run --all-files --show-diff-on-failure.
  • Run nix flake check --no-build.
  • Confirm CI passes for lint, matrix derivation, and every Python test job.
  • After this PR is created, rebase chore: bump pytest from 9.0.3 to 9.1.1 #38 onto this branch and confirm its pytest 9.1.1 matrix passes.

Checklist

  • Tests green locally (uv run pytest)
  • pre-commit run --all-files exits successfully
  • nix flake check --no-build exits successfully
  • PR CI is green
  • chore: bump pytest from 9.0.3 to 9.1.1 #38 is green after rebasing onto this branch

Nix's Python setup hooks populate PYTHONPATH with propagated packages that take precedence over the project environment. Unset the inherited path on shell entry so uv resolves dependencies from .venv.
@jcardozo-eth
jcardozo-eth merged commit 9d1981a into main Sep 8, 2026
14 checks passed
@jcardozo-eth
jcardozo-eth deleted the fix/ci-pytest-environment-isolation branch September 8, 2026 22:22
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.

Prevent Nix Python packages from overriding uv dependencies

1 participant