From 6f7199e06055293090d42fc6ae5ac251d1066160 Mon Sep 17 00:00:00 2001 From: DavHau Date: Sun, 3 Jul 2022 12:16:12 +0200 Subject: [PATCH] python: implement extraSetupDeps, remove extraRequirements --- .../python/translators/pip-WIP/default.nix | 29 ++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/src/subsystems/python/translators/pip-WIP/default.nix b/src/subsystems/python/translators/pip-WIP/default.nix index 5d43e11b..be2de0bf 100644 --- a/src/subsystems/python/translators/pip-WIP/default.nix +++ b/src/subsystems/python/translators/pip-WIP/default.nix @@ -39,14 +39,16 @@ in { outputFile=$WORKDIR/$(jq '.outputFile' -c -r $jsonInput) source="$(jq '.source' -c -r $jsonInput)/$(jq '.project.relPath' -c -r $jsonInput)" name="$(jq '.project.name' -c -r $jsonInput)" - pythonAttr=$(jq '.project.subsystemInfo.pythonAttr' -c -r $jsonInput) - extraRequirements=$(jq '.project.subsystemInfo.extraRequirements' -c -r $jsonInput) + pythonAttr=$(jq '.pythonAttr' -c -r $jsonInput) + extraSetupDeps=$(jq '[.extraSetupDeps[]] | join(" ")' -c -r $jsonInput) + + sitePackages=$(nix eval --impure --raw --expr "(import {}).$pythonAttr.sitePackages") # build python and pip executables tmpBuild=$(mktemp -d) nix build \ --impure \ - --expr "(import {}).$pythonAttr.withPackages (ps: with ps; [pip setuptools $extraRequirements])" \ + --expr "(import {}).$pythonAttr.withPackages (ps: with ps; [pip setuptools])" \ -o $tmpBuild/python python=$tmpBuild/python/bin/python @@ -57,6 +59,12 @@ in { cp -r $source ./source chmod +w -R ./source + # install setup dependencies from extraSetupDeps + echo "$(jq '.extraSetupDeps[]' -c -r $jsonInput)" > __extra_setup_reqs.txt + $python -m pip install \ + --prefix ./install \ + -r __extra_setup_reqs.txt + # download setup dependencies from pyproject.toml toml2json ./source/pyproject.toml | jq '."build-system".requires[]' -r > __setup_reqs.txt || : $python -m pip download \ @@ -65,11 +73,12 @@ in { -r __setup_reqs.txt # download files according to requirements - $python -m pip download \ - --dest $tmp \ - --progress-bar off \ - -r __setup_reqs.txt \ - ./source + PYTHONPATH=$(realpath ./install/$sitePackages) \ + $python -m pip download \ + --dest $tmp \ + --progress-bar off \ + -r __setup_reqs.txt \ + ./source # generate the dream lock from the downloaded list of files cd ./source @@ -95,8 +104,8 @@ in { type = "argument"; }; - extraRequirements = { - default = ""; + extraSetupDeps = { + default = []; description = "a list of extra requirements to add"; examples = [ "cython"