Commit bff6c679 authored by Jairo Llopis's avatar Jairo Llopis Committed by Frederik Rietdijk
Browse files

python.pipInstallHook: avoid producing wrong direct_url.json file

When installing many python packages, a `direct_url.json` file appeared in the lib directory. Example:

```sh
➤ nix build nixpkgs/29755fec#python3Packages.flask

➤ cat result/lib/python3.10/site-packages/Flask-2.2.3.dist-info/direct_url.json
{"archive_info": {}, "url": "file:///build/Flask-2.2.3/dist/Flask-2.2.3-py3-none-any.whl"}⏎
```

As you can see, that file contains a wrong reference to `/build`.

In https://discuss.python.org/t/pep-610-usage-guidelines-for-linux-distributions/4012/4 there's an explanation on how to avoid this. Here, I'm implementing that change for nixpkgs.

@moduon MT-1075
parent e6a40d6f
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -10,9 +10,7 @@ pipInstallPhase() {
    mkdir -p "$out/@pythonSitePackages@"
    export PYTHONPATH="$out/@pythonSitePackages@:$PYTHONPATH"

    pushd dist || return 1
    @pythonInterpreter@ -m pip install ./*.whl --no-index --no-warn-script-location --prefix="$out" --no-cache $pipInstallFlags
    popd || return 1
    @pythonInterpreter@ -m pip install $pname --find-links dist --no-index --no-warn-script-location --prefix="$out" --no-cache $pipInstallFlags

    runHook postInstall
    echo "Finished executing pipInstallPhase"