Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions doc/languages-frameworks/python.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ buildPythonPackage rec {

The `buildPythonPackage` mainly does four things:

* In the [`buildPhase`](#build-phase), it calls `${python.pythonForBuild.interpreter} setup.py bdist_wheel` to
* In the [`buildPhase`](#build-phase), it calls `${python.pythonOnBuildForHost.interpreter} setup.py bdist_wheel` to
build a wheel binary zipfile.
* In the [`installPhase`](#ssec-install-phase), it installs the wheel file using `pip install *.whl`.
* In the [`postFixup`](#var-stdenv-postFixup) phase, the `wrapPythonPrograms` bash function is called to
Expand Down Expand Up @@ -1682,7 +1682,7 @@ of such package using the feature is `pkgs/tools/X11/xpra/default.nix`.
As workaround install it as an extra `preInstall` step:

```shell
${python.pythonForBuild.interpreter} setup.py install_data --install-dir=$out --root=$out
${python.pythonOnBuildForHost.interpreter} setup.py install_data --install-dir=$out --root=$out
sed -i '/ = data\_files/d' setup.py
```

Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/programs/fish.nix
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ in
''
mkdir -p $out
if [ -d $package/share/man ]; then
find $package/share/man -type f | xargs ${pkgs.python3.pythonForBuild.interpreter} ${patchedGenerator}/create_manpage_completions.py --directory $out >/dev/null
find $package/share/man -type f | xargs ${pkgs.python3.pythonOnBuildForHost.interpreter} ${patchedGenerator}/create_manpage_completions.py --directory $out >/dev/null
fi
'';
in
Expand Down
2 changes: 1 addition & 1 deletion pkgs/applications/misc/calibre/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ stdenv.mkDerivation (finalAttrs: {
export XDG_DATA_HOME=$out/share
export XDG_UTILS_INSTALL_MODE="user"

${python3Packages.python.pythonForBuild.interpreter} setup.py install --root=$out \
${python3Packages.python.pythonOnBuildForHost.interpreter} setup.py install --root=$out \
--prefix=$out \
--libdir=$out/lib \
--staging-root=$out \
Expand Down
4 changes: 2 additions & 2 deletions pkgs/applications/misc/tandoor-recipes/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ python.pkgs.pythonPackages.buildPythonPackage rec {
touch cookbook/static/themes/bootstrap.min.css.map
touch cookbook/static/css/bootstrap-vue.min.css.map

${python.pythonForBuild.interpreter} manage.py collectstatic_js_reverse
${python.pythonForBuild.interpreter} manage.py collectstatic
${python.pythonOnBuildForHost.interpreter} manage.py collectstatic_js_reverse
${python.pythonOnBuildForHost.interpreter} manage.py collectstatic

runHook postBuild
'';
Expand Down
2 changes: 1 addition & 1 deletion pkgs/applications/misc/zathura/core/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ stdenv.mkDerivation (finalAttrs: {
];

nativeBuildInputs = [
meson ninja pkg-config desktop-file-utils python3.pythonForBuild.pkgs.sphinx
meson ninja pkg-config desktop-file-utils python3.pythonOnBuildForHost.pkgs.sphinx
gettext wrapGAppsHook libxml2 appstream-glib
];

Expand Down
4 changes: 2 additions & 2 deletions pkgs/applications/networking/browsers/chromium/common.nix
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
buildFun:

let
python3WithPackages = python3.pythonForBuild.withPackages(ps: with ps; [
python3WithPackages = python3.pythonOnBuildForHost.withPackages(ps: with ps; [
ply jinja2 setuptools
]);
clangFormatPython3 = fetchurl {
Expand Down Expand Up @@ -437,7 +437,7 @@ let

# This is to ensure expansion of $out.
libExecPath="${libExecPath}"
${python3.pythonForBuild}/bin/python3 build/linux/unbundle/replace_gn_files.py --system-libraries ${toString gnSystemLibraries}
${python3.pythonOnBuildForHost}/bin/python3 build/linux/unbundle/replace_gn_files.py --system-libraries ${toString gnSystemLibraries}
${gnChromium}/bin/gn gen --args=${lib.escapeShellArg gnFlags} out/Release | tee gn-gen-outputs.txt

# Fail if `gn gen` contains a WARNING.
Expand Down
2 changes: 1 addition & 1 deletion pkgs/applications/networking/flent/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ buildPythonApplication rec {

cat >test-runner <<EOF
#!/bin/sh
${python.pythonForBuild.interpreter} nix_run_setup test
${python.pythonOnBuildForHost.interpreter} nix_run_setup test
EOF
chmod +x test-runner
wrapQtApp test-runner --prefix PYTHONPATH : $PYTHONPATH
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ python3.pkgs.buildPythonApplication rec {
hash = "sha256-1QNhNPa6ZKn0lGQXs/cmfdSFHscwlYwFC/2DpnMoHvY=";
};

nativeBuildInputs = with python3.pythonForBuild.pkgs; [
nativeBuildInputs = with python3.pythonOnBuildForHost.pkgs; [
setuptools
setuptools-scm
];
Expand Down
2 changes: 1 addition & 1 deletion pkgs/applications/networking/mailreaders/afew/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ python3Packages.buildPythonApplication rec {
outputs = [ "out" "doc" ];

postBuild = ''
${python3Packages.python.pythonForBuild.interpreter} setup.py build_sphinx -b html,man
${python3Packages.python.pythonOnBuildForHost.interpreter} setup.py build_sphinx -b html,man
'';

postInstall = ''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ python3Packages.buildPythonApplication rec {

buildPhase = ''
runHook preBuild
${python3Packages.python.pythonForBuild.interpreter} -O -m compileall .
${python3Packages.python.pythonOnBuildForHost.interpreter} -O -m compileall .
runHook postBuild
'';

Expand Down
2 changes: 1 addition & 1 deletion pkgs/applications/networking/p2p/zeronet/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ python3Packages.buildPythonApplication rec {
];

buildPhase = ''
${python3Packages.python.pythonForBuild.interpreter} -O -m compileall .
${python3Packages.python.pythonOnBuildForHost.interpreter} -O -m compileall .
'';

installPhase = ''
Expand Down
6 changes: 3 additions & 3 deletions pkgs/applications/office/paperless-ngx/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,13 @@ python.pkgs.buildPythonApplication rec {
postBuild = ''
# Compile manually because `pythonRecompileBytecodeHook` only works
# for files in `python.sitePackages`
${python.pythonForBuild.interpreter} -OO -m compileall src
${python.pythonOnBuildForHost.interpreter} -OO -m compileall src

# Collect static files
${python.pythonForBuild.interpreter} src/manage.py collectstatic --clear --no-input
${python.pythonOnBuildForHost.interpreter} src/manage.py collectstatic --clear --no-input

# Compile string translations using gettext
${python.pythonForBuild.interpreter} src/manage.py compilemessages
${python.pythonOnBuildForHost.interpreter} src/manage.py compilemessages
'';

installPhase = ''
Expand Down
2 changes: 1 addition & 1 deletion pkgs/applications/science/biology/quast/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pythonPackages.buildPythonApplication rec {
--replace "/bin/bash" "${bash}/bin/bash"
mkdir -p "$out/${python.sitePackages}"
export PYTHONPATH="$out/${python.sitePackages}:$PYTHONPATH"
${python.pythonForBuild.interpreter} setup.py install \
${python.pythonOnBuildForHost.interpreter} setup.py install \
--install-lib=$out/${python.sitePackages} \
--prefix="$out"
'';
Expand Down
2 changes: 1 addition & 1 deletion pkgs/applications/science/logic/z3/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ let common = { version, sha256, patches ? [ ], tag ? "z3" }:

configurePhase = concatStringsSep " "
(
[ "${python.pythonForBuild.interpreter} scripts/mk_make.py --prefix=$out" ]
[ "${python.pythonOnBuildForHost.interpreter} scripts/mk_make.py --prefix=$out" ]
++ optional javaBindings "--java"
++ optional ocamlBindings "--ml"
++ optional pythonBindings "--python --pypkgdir=$out/${python.sitePackages}"
Expand Down
8 changes: 4 additions & 4 deletions pkgs/applications/terminal-emulators/kitty/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -128,17 +128,17 @@ buildPythonApplication rec {
runHook preBuild
${ lib.optionalString (stdenv.isDarwin && stdenv.isx86_64) "export MACOSX_DEPLOYMENT_TARGET=11" }
${if stdenv.isDarwin then ''
${python.pythonForBuild.interpreter} setup.py build ${darwinOptions}
${python.pythonOnBuildForHost.interpreter} setup.py build ${darwinOptions}
make docs
${python.pythonForBuild.interpreter} setup.py kitty.app ${darwinOptions}
${python.pythonOnBuildForHost.interpreter} setup.py kitty.app ${darwinOptions}
'' else ''
${python.pythonForBuild.interpreter} setup.py linux-package \
${python.pythonOnBuildForHost.interpreter} setup.py linux-package \
--egl-library='${lib.getLib libGL}/lib/libEGL.so.1' \
--startup-notification-library='${libstartup_notification}/lib/libstartup-notification-1.so' \
--canberra-library='${libcanberra}/lib/libcanberra.so' \
--fontconfig-library='${fontconfig.lib}/lib/libfontconfig.so' \
${commonOptions}
${python.pythonForBuild.interpreter} setup.py build-launcher
${python.pythonOnBuildForHost.interpreter} setup.py build-launcher
''}
runHook postBuild
'';
Expand Down
12 changes: 6 additions & 6 deletions pkgs/development/interpreters/python/cpython/2.7/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ assert lib.assertMsg (reproducibleBuild -> (!rebuildBytecode))

let
buildPackages = pkgsBuildHost;
inherit (passthru) pythonForBuild;
inherit (passthru) pythonOnBuildForHost;

pythonForBuildInterpreter = if stdenv.hostPlatform == stdenv.buildPlatform then
pythonOnBuildForHostInterpreter = if stdenv.hostPlatform == stdenv.buildPlatform then
"$out/bin/python"
else pythonForBuild.interpreter;
else pythonOnBuildForHost.interpreter;

passthru = passthruFun rec {
inherit self sourceVersion packageOverrides;
Expand Down Expand Up @@ -297,9 +297,9 @@ in with passthru; stdenv.mkDerivation ({
# We build 3 levels of optimized bytecode. Note the default level, without optimizations,
# is not reproducible yet. https://bugs.python.org/issue29708
# Not creating bytecode will result in a large performance loss however, so we do build it.
find $out -name "*.py" | ${pythonForBuildInterpreter} -m compileall -q -f -x "lib2to3" -i -
find $out -name "*.py" | ${pythonForBuildInterpreter} -O -m compileall -q -f -x "lib2to3" -i -
find $out -name "*.py" | ${pythonForBuildInterpreter} -OO -m compileall -q -f -x "lib2to3" -i -
find $out -name "*.py" | ${pythonOnBuildForHostInterpreter} -m compileall -q -f -x "lib2to3" -i -
find $out -name "*.py" | ${pythonOnBuildForHostInterpreter} -O -m compileall -q -f -x "lib2to3" -i -
find $out -name "*.py" | ${pythonOnBuildForHostInterpreter} -OO -m compileall -q -f -x "lib2to3" -i -
'' + lib.optionalString stdenv.hostPlatform.isCygwin ''
cp libpython2.7.dll.a $out/lib
'';
Expand Down
18 changes: 9 additions & 9 deletions pkgs/development/interpreters/python/cpython/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ let
openssl' = if openssl != null then openssl_legacy else null;

buildPackages = pkgsBuildHost;
inherit (passthru) pythonForBuild;
inherit (passthru) pythonOnBuildForHost;

inherit (darwin.apple_sdk.frameworks) Cocoa;

Expand Down Expand Up @@ -127,7 +127,7 @@ let
nukeReferences
] ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
buildPackages.stdenv.cc
pythonForBuild
pythonOnBuildForHost
] ++ optionals (stdenv.cc.isClang && (!stdenv.hostPlatform.useAndroidPrebuilt or false) && (enableLTO || enableOptimizations)) [
stdenv.cc.cc.libllvm.out
];
Expand All @@ -148,9 +148,9 @@ let

hasDistutilsCxxPatch = !(stdenv.cc.isGNU or false);

pythonForBuildInterpreter = if stdenv.hostPlatform == stdenv.buildPlatform then
pythonOnBuildForHostInterpreter = if stdenv.hostPlatform == stdenv.buildPlatform then
"$out/bin/python"
else pythonForBuild.interpreter;
else pythonOnBuildForHost.interpreter;

src = fetchurl {
url = with sourceVersion; "https://www.python.org/ftp/python/${major}.${minor}.${patch}/Python-${version}.tar.xz";
Expand Down Expand Up @@ -388,7 +388,7 @@ in with passthru; stdenv.mkDerivation (finalAttrs: {
"ac_cv_file__dev_ptmx=${if stdenv.hostPlatform.isWindows then "no" else "yes"}"
"ac_cv_file__dev_ptc=${if stdenv.hostPlatform.isWindows then "no" else "yes"}"
] ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform && pythonAtLeast "3.11") [
"--with-build-python=${pythonForBuildInterpreter}"
"--with-build-python=${pythonOnBuildForHostInterpreter}"
] ++ optionals stdenv.hostPlatform.isLinux [
# Never even try to use lchmod on linux,
# don't rely on detecting glibc-isms.
Expand Down Expand Up @@ -511,9 +511,9 @@ in with passthru; stdenv.mkDerivation (finalAttrs: {
# We build 3 levels of optimized bytecode. Note the default level, without optimizations,
# is not reproducible yet. https://bugs.python.org/issue29708
# Not creating bytecode will result in a large performance loss however, so we do build it.
find $out -name "*.py" | ${pythonForBuildInterpreter} -m compileall -q -f -x "lib2to3" -i -
find $out -name "*.py" | ${pythonForBuildInterpreter} -O -m compileall -q -f -x "lib2to3" -i -
find $out -name "*.py" | ${pythonForBuildInterpreter} -OO -m compileall -q -f -x "lib2to3" -i -
find $out -name "*.py" | ${pythonOnBuildForHostInterpreter} -m compileall -q -f -x "lib2to3" -i -
find $out -name "*.py" | ${pythonOnBuildForHostInterpreter} -O -m compileall -q -f -x "lib2to3" -i -
find $out -name "*.py" | ${pythonOnBuildForHostInterpreter} -OO -m compileall -q -f -x "lib2to3" -i -
'' + ''
# *strip* shebang from libpython gdb script - it should be dual-syntax and
# interpretable by whatever python the gdb in question is using, which may
Expand Down Expand Up @@ -561,7 +561,7 @@ in with passthru; stdenv.mkDerivation (finalAttrs: {
++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
# Ensure we don't have references to build-time packages.
# These typically end up in shebangs.
pythonForBuild buildPackages.bash
pythonOnBuildForHost buildPackages.bash
];

separateDebugInfo = true;
Expand Down
12 changes: 6 additions & 6 deletions pkgs/development/interpreters/python/hooks/default.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
self: dontUse: with self;

let
inherit (python) pythonForBuild;
pythonInterpreter = pythonForBuild.interpreter;
inherit (python) pythonOnBuildForHost;
pythonInterpreter = pythonOnBuildForHost.interpreter;
pythonSitePackages = python.sitePackages;
pythonCheckInterpreter = python.interpreter;
setuppy = ../run_setup.py;
Expand Down Expand Up @@ -68,10 +68,10 @@ in {
# set, but in downstream projects that build packages depending on other
# versions of this hook's dependencies.
passthru.tests = import ./pypa-build-hook-tests.nix {
inherit pythonForBuild runCommand;
inherit pythonOnBuildForHost runCommand;
};
} ./pypa-build-hook.sh) {
inherit (pythonForBuild.pkgs) build;
inherit (pythonOnBuildForHost.pkgs) build;
};

pipInstallHook = callPackage ({ makePythonHook, pip }:
Expand All @@ -91,7 +91,7 @@ in {
inherit pythonInterpreter pythonSitePackages;
};
} ./pypa-install-hook.sh) {
inherit (pythonForBuild.pkgs) installer;
inherit (pythonOnBuildForHost.pkgs) installer;
};

pytestCheckHook = callPackage ({ makePythonHook, pytest }:
Expand Down Expand Up @@ -227,6 +227,6 @@ in {
sphinxHook = callPackage ({ makePythonHook, installShellFiles }:
makePythonHook {
name = "python${python.pythonVersion}-sphinx-hook";
propagatedBuildInputs = [ pythonForBuild.pkgs.sphinx installShellFiles ];
propagatedBuildInputs = [ pythonOnBuildForHost.pkgs.sphinx installShellFiles ];
} ./sphinx-hook.sh) {};
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ pythonForBuild, runCommand }: {
{ pythonOnBuildForHost, runCommand }: {
dont-propagate-conflicting-deps = let
# customize a package so that its store paths differs
mkConflict = pkg: pkg.overrideAttrs { some_modification = true; };
Expand All @@ -16,17 +16,17 @@
'';
in
# this build must never triger conflicts
pythonForBuild.pkgs.buildPythonPackage {
pythonOnBuildForHost.pkgs.buildPythonPackage {
pname = "dont-propagate-conflicting-deps";
version = "0.0.0";
src = projectSource;
format = "pyproject";
propagatedBuildInputs = [
# At least one dependency of `build` should be included here to
# keep the test meaningful
(mkConflict pythonForBuild.pkgs.tomli)
(mkConflict pythonOnBuildForHost.pkgs.tomli)
# setuptools is also needed to build the example project
pythonForBuild.pkgs.setuptools
pythonOnBuildForHost.pkgs.setuptools
];
};
}
6 changes: 3 additions & 3 deletions pkgs/development/interpreters/python/mk-python-derivation.nix
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ let
] ++ lib.optionals (format' == "pyproject") [(
if isBootstrapPackage then
pypaBuildHook.override {
inherit (python.pythonForBuild.pkgs.bootstrap) build;
inherit (python.pythonOnBuildForHost.pkgs.bootstrap) build;
wheel = null;
}
else
Expand All @@ -235,7 +235,7 @@ let
] ++ lib.optionals (format' != "other") [(
if isBootstrapInstallPackage then
pypaInstallHook.override {
inherit (python.pythonForBuild.pkgs.bootstrap) installer;
inherit (python.pythonOnBuildForHost.pkgs.bootstrap) installer;
}
else
pypaInstallHook
Expand Down Expand Up @@ -279,7 +279,7 @@ let
'' + attrs.postFixup or "";

# Python packages built through cross-compilation are always for the host platform.
disallowedReferences = lib.optionals (python.stdenv.hostPlatform != python.stdenv.buildPlatform) [ python.pythonForBuild ];
disallowedReferences = lib.optionals (python.stdenv.hostPlatform != python.stdenv.buildPlatform) [ python.pythonOnBuildForHost ];

outputs = outputs ++ lib.optional withDistOutput "dist";

Expand Down
7 changes: 4 additions & 3 deletions pkgs/development/interpreters/python/passthrufun.nix
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,10 @@ in rec {
pythonAtLeast = lib.versionAtLeast pythonVersion;
pythonOlder = lib.versionOlder pythonVersion;
inherit hasDistutilsCxxPatch;
# TODO: deprecate
# Not done immediately because its likely used outside Nixpkgs.
pythonForBuild = pythonOnBuildForHost_overridden;
# Remove after 24.11 is released.
pythonForBuild =
lib.warnIf (lib.isInOldestRelease 2311) "`pythonForBuild` (from `python*`) has been renamed to `pythonOnBuildForHost`"
pythonOnBuildForHost_overridden;
pythonOnBuildForHost = pythonOnBuildForHost_overridden;

tests = callPackage ./tests.nix {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ let
'' + attrs.postFixup or "";

# Python packages built through cross-compilation are always for the host platform.
disallowedReferences = lib.optionals (python.stdenv.hostPlatform != python.stdenv.buildPlatform) [ python.pythonForBuild ];
disallowedReferences = lib.optionals (python.stdenv.hostPlatform != python.stdenv.buildPlatform) [ python.pythonOnBuildForHost ];

outputs = outputs ++ lib.optional withDistOutput "dist";

Expand Down
2 changes: 1 addition & 1 deletion pkgs/development/interpreters/python/wrap-python.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ makePythonHook {
propagatedBuildInputs = [ makeWrapper ];
substitutions.sitePackages = python.sitePackages;
substitutions.executable = python.interpreter;
substitutions.python = python.pythonForBuild;
substitutions.python = python.pythonOnBuildForHost;
substitutions.pythonHost = python;
substitutions.magicalSedExpression = let
# Looks weird? Of course, it's between single quoted shell strings.
Expand Down
Loading