Skip to content

python: support withPackages with venvs and prepare for upstream patch#2234

Merged
domenkozar merged 20 commits intomainfrom
fix-1218
Nov 13, 2025
Merged

python: support withPackages with venvs and prepare for upstream patch#2234
domenkozar merged 20 commits intomainfrom
fix-1218

Conversation

@sandydoo
Copy link
Member

@sandydoo sandydoo commented Oct 22, 2025

This prepares us for the arrival of several upstream patches (including NixOS/nixpkgs#442540) that will make it possible to drop the python wrapper.

  • withPackages are now propagated through the wrapper
  • Adds a patches.buildEnv.enable option to toggle the wrapper

Fixes #1807.
Fixes #1792.
Fixes #1486. (possibly earlier)
Fixes #1218.

@sandydoo sandydoo added the bug Something isn't working label Oct 22, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Oct 22, 2025

🔍 Suggested Reviewers

Based on git blame analysis of the changed lines, the following contributors have significant experience with the modified code:

  • @Mshnwq - 67.7% of changed lines (42 lines)
  • @k3yss - 32.3% of changed lines (20 lines)

Please consider reviewing this PR as you have authored significant portions of the code being modified. Your expertise would be valuable! 🙏

This comment was automatically generated by git-blame-auto-reviewer

Last updated: 2025-11-11T14:08:15.535Z

@sandydoo sandydoo changed the title python: prepare to drop legacy venv wrapper python: prepare to drop legacy venv wrapper and adjust how the legacy wrapper is applied Oct 22, 2025
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Oct 22, 2025

Deploying devenv with  Cloudflare Pages  Cloudflare Pages

Latest commit: 3f7cac2
Status: ✅  Deploy successful!
Preview URL: https://5880f4d8.devenv.pages.dev
Branch Preview URL: https://fix-1218.devenv.pages.dev

View logs

@sandydoo sandydoo changed the title python: prepare to drop legacy venv wrapper and adjust how the legacy wrapper is applied python: prepare to drop legacy wrapper and adjust how it's applied Oct 23, 2025
@sandydoo
Copy link
Member Author

Added a test to verify sys.base_prefix and the interaction between withPackages and venv.enable.

We now also patch buildEnv in a way that avoids nesting envs.

This PR still needs to be tested against the upstream nixpkgs PR. Once it's out of staging, we can verify this easily without rebuilding the universe.

@domenkozar
Copy link
Member

Shall we merge this?

@gabyx
Copy link
Contributor

gabyx commented Nov 2, 2025

suggestion: we need another uv test as uv is the predominant tool
in the future

@gabyx
Copy link
Contributor

gabyx commented Nov 2, 2025

but should not hold it back!

Let's wait until the upsteam patch is released proper.
If the python executable is a symlink, e.g. in a devenv profile, we won't correctly resolve to the buildEnv-wrapped executable without `resolve-argv0`.
@sandydoo sandydoo changed the title python: prepare to drop legacy wrapper and adjust how it's applied python: support withPackages with venvs and prepare for upstream patch Nov 10, 2025
@domenkozar domenkozar merged commit 88d1aa6 into main Nov 13, 2025
275 of 293 checks passed
@sandydoo sandydoo deleted the fix-1218 branch November 17, 2025 15:29
takeda added a commit to takeda/devenv-uv2nix that referenced this pull request Dec 19, 2025
cachix/devenv#2234 change causes
shell fail to build, because languages.python.packages to be modified.

As a result, the python package needs to be specified in
languages.python.uv2nix.package.

I initially though of setting languages.python.packages as the default
but there's no point as the shell will be broken with it.
I also did not set it to pkgs.python3 as it would lead to silently
replacing python version with one that might not be desired.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

3 participants