Skip to content

WIP: Python no runtime deps at build time#272179

Closed
adisbladis wants to merge 5 commits intoNixOS:masterfrom
adisbladis:python-no-runtime-deps-at-build
Closed

WIP: Python no runtime deps at build time#272179
adisbladis wants to merge 5 commits intoNixOS:masterfrom
adisbladis:python-no-runtime-deps-at-build

Conversation

@adisbladis
Copy link
Member

@adisbladis adisbladis commented Dec 5, 2023

Description of changes

Removes dependency propagation from buildPythonPackage when a runtime dependency is passed via dependencies.

Please don't actually review the code yet. This a a very WIP, very draft PoC & should be considered a demo for #272178.
This also includes the commits from #271597.
Only the commits prefixed with WIP: are a part of this.

python3Packages.foo

Depending on a Python package like this will break:

stdenv.mkDerivation {
  propagatedBuildInputs = [ python3Packages.requests ];
}

You will instead need to:

stdenv.mkDerivation {
  propagatedBuildInputs = python3Packages.requiredPythonModules [ python3Packages.requests ];
}

This is because dependencies are no longer build-time propagated, so the full dependency graph calculation needs to happen in the Nix evaluator.

python3Packages.buildPythonPackage vs python3Packages.buildPythonApplication

  • buildPythonPackage is for building a Python package without dependency propagation
  • buildPythonApplication is for building application bundles. This internally calls buildPythonPackage, and also creates a wrapper derivation that takes care of calling requiredPythonModules.

All Python applications which has runnable binaries now needs to either be:

  • Created using buildPythonApplication
  • Converted from a Python module using toPythonApplication

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.05 Release Notes (or backporting 23.05 and 23.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@github-actions github-actions bot added 6.topic: python Python is a high-level, general-purpose programming language. 8.has: documentation This PR adds or changes documentation labels Dec 5, 2023
@adisbladis adisbladis marked this pull request as draft December 5, 2023 02:22
@wegank wegank added the 2.status: merge conflict This PR has merge conflicts with the target branch label Mar 20, 2024
@wegank wegank added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jul 4, 2024
@adisbladis adisbladis force-pushed the python-no-runtime-deps-at-build branch from dcceee3 to 0050637 Compare July 18, 2024 00:35
@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jul 18, 2024
@github-actions github-actions bot removed the 8.has: documentation This PR adds or changes documentation label Jul 18, 2024
@adisbladis adisbladis force-pushed the python-no-runtime-deps-at-build branch from 0050637 to 67d7d6b Compare July 18, 2024 00:59
@ofborg ofborg bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Jul 18, 2024
@adisbladis adisbladis force-pushed the python-no-runtime-deps-at-build branch 2 times, most recently from 196a0c1 to 6bb412c Compare July 18, 2024 03:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2.status: merge conflict This PR has merge conflicts with the target branch 6.topic: python Python is a high-level, general-purpose programming language.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants