diff options
author | Vladimír Čunát <vcunat@gmail.com> | 2017-12-19 10:27:13 +0100 |
---|---|---|
committer | Vladimír Čunát <vcunat@gmail.com> | 2017-12-19 10:27:13 +0100 |
commit | 4a2340ff6bd0474d9a3e933f28b8568c59019b82 (patch) | |
tree | 235f2b7adf6b6f25c416c0d3223ce4f3bfed2319 /pkgs/development/interpreters | |
parent | b4551924b183f0f0a34868f76f52ae0bff5d041c (diff) | |
parent | 69345ec37b8da3de94d4262b81bfa08000d35427 (diff) | |
download | nixlib-4a2340ff6bd0474d9a3e933f28b8568c59019b82.tar nixlib-4a2340ff6bd0474d9a3e933f28b8568c59019b82.tar.gz nixlib-4a2340ff6bd0474d9a3e933f28b8568c59019b82.tar.bz2 nixlib-4a2340ff6bd0474d9a3e933f28b8568c59019b82.tar.lz nixlib-4a2340ff6bd0474d9a3e933f28b8568c59019b82.tar.xz nixlib-4a2340ff6bd0474d9a3e933f28b8568c59019b82.tar.zst nixlib-4a2340ff6bd0474d9a3e933f28b8568c59019b82.zip |
Merge branch 'staging'
Diffstat (limited to 'pkgs/development/interpreters')
-rw-r--r-- | pkgs/development/interpreters/python/build-python-package.nix | 4 | ||||
-rw-r--r-- | pkgs/development/interpreters/python/mk-python-derivation.nix | 22 |
2 files changed, 16 insertions, 10 deletions
diff --git a/pkgs/development/interpreters/python/build-python-package.nix b/pkgs/development/interpreters/python/build-python-package.nix index 982542c1fc3e..12d17b2e8322 100644 --- a/pkgs/development/interpreters/python/build-python-package.nix +++ b/pkgs/development/interpreters/python/build-python-package.nix @@ -7,7 +7,7 @@ , setuptools , unzip , ensureNewerSourcesHook -, pythonModule +, toPythonModule , namePrefix , bootstrapped-pip , flit @@ -19,7 +19,7 @@ let wheel-specific = import ./build-python-package-wheel.nix { }; common = import ./build-python-package-common.nix { inherit python bootstrapped-pip; }; mkPythonDerivation = import ./mk-python-derivation.nix { - inherit lib python wrapPython setuptools unzip ensureNewerSourcesHook pythonModule namePrefix; + inherit lib python wrapPython setuptools unzip ensureNewerSourcesHook toPythonModule namePrefix; }; in diff --git a/pkgs/development/interpreters/python/mk-python-derivation.nix b/pkgs/development/interpreters/python/mk-python-derivation.nix index a0cac7d1ddda..5f7348ac825f 100644 --- a/pkgs/development/interpreters/python/mk-python-derivation.nix +++ b/pkgs/development/interpreters/python/mk-python-derivation.nix @@ -7,7 +7,7 @@ , unzip , ensureNewerSourcesHook # Whether the derivation provides a Python module or not. -, pythonModule +, toPythonModule , namePrefix }: @@ -40,6 +40,12 @@ # Skip wrapping of python programs altogether , dontWrapPythonPrograms ? false +# Remove bytecode from bin folder. +# When a Python script has the extension `.py`, bytecode is generated +# Typically, executables in bin have no extension, so no bytecode is generated. +# However, some packages do provide executables with extensions, and thus bytecode is generated. +, removeBinBytecode ? true + , meta ? {} , passthru ? {} @@ -54,7 +60,7 @@ if disabled then throw "${name} not supported for interpreter ${python.executable}" else -python.stdenv.mkDerivation (builtins.removeAttrs attrs [ +toPythonModule (python.stdenv.mkDerivation (builtins.removeAttrs attrs [ "disabled" "checkInputs" "doCheck" "doInstallCheck" "dontWrapPythonPrograms" "catchConflicts" ] // { @@ -77,6 +83,11 @@ python.stdenv.mkDerivation (builtins.removeAttrs attrs [ postFixup = lib.optionalString (!dontWrapPythonPrograms) '' wrapPythonPrograms + '' + lib.optionalString removeBinBytecode '' + if [ -d "$out/bin" ]; then + rm -rf "$out/bin/__pycache__" # Python 3 + find "$out/bin" -type f -name "*.pyc" -delete # Python 2 + fi '' + lib.optionalString catchConflicts '' # 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. @@ -84,14 +95,9 @@ python.stdenv.mkDerivation (builtins.removeAttrs attrs [ ${python.interpreter} ${./catch_conflicts}/catch_conflicts.py '' + attrs.postFixup or ''''; - passthru = { - inherit python; # The python interpreter - inherit pythonModule; - } // passthru; - meta = { # default to python's platforms platforms = python.meta.platforms; isBuildPythonPackage = python.meta.platforms; } // meta; -}) +})) |