summary refs log tree commit diff
path: root/pkgs/development/interpreters/python
diff options
context:
space:
mode:
authorWinter <winter@winter.cafe>2023-02-21 14:50:30 -0500
committerWinter <winter@winter.cafe>2023-02-25 13:43:28 -0500
commite4dd2b8ca0269c0d283f4f74ccfe9bec082b3563 (patch)
treebabb64e10f8815fd2c4148d6601b15cd6f2873c5 /pkgs/development/interpreters/python
parentab8815a4b681e15da4b5c5dbbb137a4b64136377 (diff)
downloadnixpkgs-e4dd2b8ca0269c0d283f4f74ccfe9bec082b3563.tar
nixpkgs-e4dd2b8ca0269c0d283f4f74ccfe9bec082b3563.tar.gz
nixpkgs-e4dd2b8ca0269c0d283f4f74ccfe9bec082b3563.tar.bz2
nixpkgs-e4dd2b8ca0269c0d283f4f74ccfe9bec082b3563.tar.lz
nixpkgs-e4dd2b8ca0269c0d283f4f74ccfe9bec082b3563.tar.xz
nixpkgs-e4dd2b8ca0269c0d283f4f74ccfe9bec082b3563.tar.zst
nixpkgs-e4dd2b8ca0269c0d283f4f74ccfe9bec082b3563.zip
pypy3{8,9}: fix sitePackages
When PyPy introduced Python 3.8 support with version 7.3.6, they also
migrated to using CPython's directory layout [0]:

> The 3.8 package now uses the same layout as CPython, and many of the
PyPy-specific changes to `sysconfig`, `distutils.sysconfig`, and
`distutils.commands.install.py` have been removed. The stdlib now is
located in `<base>/lib/pypy3.8` on `posix` systems...

When we upgraded past this version and added Python 3.8 support [1], the
`sitePackages` value was never updated, leading `bootstrapped-pip` to fail
to build, because wheel was trying to be located in `$out/site-packages`,
when it was actually installed to `$out/lib/pypy3.8/site-packages`.

[0]: https://www.pypy.org/posts/2021/10/pypy-v736-release.html
[1]: eec28b8cfd7923a876fb47af8a0459c1a550fd97
Diffstat (limited to 'pkgs/development/interpreters/python')
-rw-r--r--pkgs/development/interpreters/python/pypy/default.nix7
1 files changed, 4 insertions, 3 deletions
diff --git a/pkgs/development/interpreters/python/pypy/default.nix b/pkgs/development/interpreters/python/pypy/default.nix
index b7597a9925b..79dec91f073 100644
--- a/pkgs/development/interpreters/python/pypy/default.nix
+++ b/pkgs/development/interpreters/python/pypy/default.nix
@@ -21,13 +21,14 @@ assert zlibSupport -> zlib != null;
 
 let
   isPy3k = (lib.versions.major pythonVersion) == "3";
+  isPy38OrNewer = lib.versionAtLeast pythonVersion "3.8";
   isPy39OrNewer = lib.versionAtLeast pythonVersion "3.9";
-  passthru = passthruFun {
+  passthru = passthruFun rec {
     inherit self sourceVersion pythonVersion packageOverrides;
     implementation = "pypy";
     libPrefix = "pypy${pythonVersion}";
     executable = "pypy${if isPy39OrNewer then lib.versions.majorMinor pythonVersion else lib.optionalString isPy3k "3"}";
-    sitePackages = "site-packages";
+    sitePackages = "${lib.optionalString isPy38OrNewer "lib/${libPrefix}/"}site-packages";
     hasDistutilsCxxPatch = false;
     inherit pythonAttr;
 
@@ -122,7 +123,7 @@ in with passthru; stdenv.mkDerivation rec {
     ln -s $out/${executable}-c/lib-python/${if isPy3k then "3" else pythonVersion} $out/lib/${libPrefix}
 
     # Include a sitecustomize.py file
-    cp ${../sitecustomize.py} $out/lib/${libPrefix}/${sitePackages}/sitecustomize.py
+    cp ${../sitecustomize.py} $out/${if isPy38OrNewer then sitePackages else "lib/${libPrefix}/${sitePackages}"}/sitecustomize.py
 
     runHook postInstall
   '';