Python: improve cross-compilation

This changeset allows for cross-compilation of Python packages. Packages
built with buildPythonPackage are not allowed to refer to the build
machine. Executables that have shebangs will refer to the host.
This commit is contained in:
Frederik Rietdijk
2019-01-02 20:09:44 +01:00
parent 613498af97
commit f665828fa3
14 changed files with 68 additions and 41 deletions

View File

@@ -77,7 +77,7 @@ let self = toPythonModule (python.stdenv.mkDerivation (builtins.removeAttrs attr
buildInputs = [ wrapPython ]
++ lib.optional (lib.hasSuffix "zip" (attrs.src.name or "")) unzip
++ lib.optional catchConflicts setuptools # If we no longer propagate setuptools
# ++ lib.optional catchConflicts setuptools # If we no longer propagate setuptools
++ buildInputs
++ pythonPath;
@@ -100,9 +100,12 @@ let self = toPythonModule (python.stdenv.mkDerivation (builtins.removeAttrs attr
# Check if we have two packages with the same name in the closure and fail.
# If this happens, something went wrong with the dependencies specs.
# Intentionally kept in a subdirectory, see catch_conflicts/README.md.
${python.interpreter} ${./catch_conflicts}/catch_conflicts.py
${python.pythonForBuild.interpreter} ${./catch_conflicts}/catch_conflicts.py
'' + 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 ];
meta = {
# default to python's platforms
platforms = python.meta.platforms;