From b43959a817c115d92d5adcf7c6db80e58aa22e92 Mon Sep 17 00:00:00 2001 From: Dmitry Kalinkin Date: Fri, 16 Jul 2021 01:59:26 -0400 Subject: [PATCH 1/4] pypy: fix for sandboxed darwin The implementation of multiprocessing.cpu_count() tries to call the impure sysctl binary. In the sandbox that fails, so cffi bindings are not generated. --- pkgs/development/interpreters/python/pypy/default.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkgs/development/interpreters/python/pypy/default.nix b/pkgs/development/interpreters/python/pypy/default.nix index a5ba4983e43c..1f229c7d34e2 100644 --- a/pkgs/development/interpreters/python/pypy/default.nix +++ b/pkgs/development/interpreters/python/pypy/default.nix @@ -84,6 +84,9 @@ in with passthru; stdenv.mkDerivation rec { ]; postPatch = '' + substituteInPlace lib_pypy/pypy_tools/build_cffi_imports.py \ + --replace "multiprocessing.cpu_count()" "$NIX_BUILD_CORES" + substituteInPlace "lib-python/${if isPy3k then "3/tkinter/tix.py" else "2.7/lib-tk/Tix.py"}" --replace "os.environ.get('TIX_LIBRARY')" "os.environ.get('TIX_LIBRARY') or '${tix}/lib'" sed -i "s@libraries=\['sqlite3'\]\$@libraries=['sqlite3'], include_dirs=['${sqlite.dev}/include'], library_dirs=['${sqlite.out}/lib']@" lib_pypy/_sqlite3_build.py From d5577087616bc7e9e1933e865984b479cfe26864 Mon Sep 17 00:00:00 2001 From: Dmitry Kalinkin Date: Fri, 16 Jul 2021 02:02:58 -0400 Subject: [PATCH 2/4] pypy: don't try to fetch vendored dependencies for cffi bindings Specifically, this affects _ssl and lzma. This should be useful on Hydra/macOS where sandboxing is disabled. --- .../development/interpreters/python/pypy/default.nix | 2 ++ .../python/pypy/dont_fetch_vendored_deps.patch | 12 ++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 pkgs/development/interpreters/python/pypy/dont_fetch_vendored_deps.patch diff --git a/pkgs/development/interpreters/python/pypy/default.nix b/pkgs/development/interpreters/python/pypy/default.nix index 1f229c7d34e2..e4e95ad4c57d 100644 --- a/pkgs/development/interpreters/python/pypy/default.nix +++ b/pkgs/development/interpreters/python/pypy/default.nix @@ -73,6 +73,8 @@ in with passthru; stdenv.mkDerivation rec { LD_LIBRARY_PATH = makeLibraryPath (filter (x : x.outPath != stdenv.cc.libc.outPath or "") buildInputs); patches = [ + ./dont_fetch_vendored_deps.patch + (substituteAll { src = ./tk_tcl_paths.patch; inherit tk tcl; diff --git a/pkgs/development/interpreters/python/pypy/dont_fetch_vendored_deps.patch b/pkgs/development/interpreters/python/pypy/dont_fetch_vendored_deps.patch new file mode 100644 index 000000000000..bc959e15d1af --- /dev/null +++ b/pkgs/development/interpreters/python/pypy/dont_fetch_vendored_deps.patch @@ -0,0 +1,12 @@ +diff -ur a/lib_pypy/pypy_tools/build_cffi_imports.py b/lib_pypy/pypy_tools/build_cffi_imports.py +--- a/lib_pypy/pypy_tools/build_cffi_imports.py 2021-04-12 01:11:48.000000000 -0400 ++++ b/lib_pypy/pypy_tools/build_cffi_imports.py 2021-07-16 06:37:03.000000000 -0400 +@@ -225,6 +225,8 @@ + + print('*', ' '.join(args), file=sys.stderr) + if embed_dependencies and key in cffi_dependencies: ++ print("Nixpkgs: skipping fetching/building dependency", key) ++ elif False: + status, stdout, stderr = _build_dependency(key) + if status != 0: + failures.append((key, module)) From c168edeeb93fd551e8d0eb50387cc44addce7aef Mon Sep 17 00:00:00 2001 From: Dmitry Kalinkin Date: Wed, 14 Jul 2021 23:37:23 -0400 Subject: [PATCH 3/4] pypy3: change pythonVersion to 3.7 --- pkgs/development/interpreters/python/default.nix | 8 ++++---- pkgs/top-level/all-packages.nix | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkgs/development/interpreters/python/default.nix b/pkgs/development/interpreters/python/default.nix index 30134a056284..2c89fdd42196 100644 --- a/pkgs/development/interpreters/python/default.nix +++ b/pkgs/development/interpreters/python/default.nix @@ -247,15 +247,15 @@ in { inherit (darwin.apple_sdk.frameworks) Security; }; - pypy36 = callPackage ./pypy { - self = pypy36; + pypy37 = callPackage ./pypy { + self = pypy37; sourceVersion = { major = "7"; minor = "3"; patch = "3"; }; - sha256 = "1bq5i2mqgjjfc4rhxgxm6ihwa76vn2qapd7l59ri7xp01p522gd2"; - pythonVersion = "3.6"; + sha256 = "sha256-9slkAfdjMeR0zKLRRDfrOy9ooPJyIKbcvFN0Rf6dW3g="; + pythonVersion = "3.7"; db = db.override { dbmSupport = !stdenv.isDarwin; }; python = python27; inherit passthruFun; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 1b9f95610228..bb960c3e0ae9 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -12569,7 +12569,7 @@ in python3 = python38; pypy = pypy2; pypy2 = pypy27; - pypy3 = pypy36; + pypy3 = pypy37; # Python interpreter that is build with all modules, including tkinter. # These are for compatibility and should not be used inside Nixpkgs. @@ -12625,7 +12625,7 @@ in python3Packages = python3.pkgs; pythonInterpreters = callPackage ./../development/interpreters/python { }; - inherit (pythonInterpreters) python27 python36 python37 python38 python39 python310 python3Minimal pypy27 pypy36; + inherit (pythonInterpreters) python27 python36 python37 python38 python39 python310 python3Minimal pypy27 pypy37; # Python package sets. python27Packages = python27.pkgs; From 3d68137c6e5094ac738745ac41ec980af725590b Mon Sep 17 00:00:00 2001 From: Dmitry Kalinkin Date: Wed, 14 Jul 2021 19:37:37 -0400 Subject: [PATCH 4/4] pypy: 7.3.3 -> 7.3.5 --- pkgs/development/interpreters/python/default.nix | 8 ++++---- .../development/interpreters/python/pypy/default.nix | 7 +++++-- .../interpreters/python/pypy/sqlite_paths.patch | 12 ++++++++++++ 3 files changed, 21 insertions(+), 6 deletions(-) create mode 100644 pkgs/development/interpreters/python/pypy/sqlite_paths.patch diff --git a/pkgs/development/interpreters/python/default.nix b/pkgs/development/interpreters/python/default.nix index 2c89fdd42196..f700eb163a90 100644 --- a/pkgs/development/interpreters/python/default.nix +++ b/pkgs/development/interpreters/python/default.nix @@ -236,9 +236,9 @@ in { sourceVersion = { major = "7"; minor = "3"; - patch = "3"; + patch = "5"; }; - sha256 = "0di3dr5ry4r0hwxh4fbqjhyl5im948wdby0bhijzsxx83c2qhd7n"; + sha256 = "sha256-wERP2YcwWMHA2Z4TqTTpIoXLBZksmWi/Ujwyv5vsCp0="; pythonVersion = "2.7"; db = db.override { dbmSupport = !stdenv.isDarwin; }; python = python27; @@ -252,9 +252,9 @@ in { sourceVersion = { major = "7"; minor = "3"; - patch = "3"; + patch = "5"; }; - sha256 = "sha256-9slkAfdjMeR0zKLRRDfrOy9ooPJyIKbcvFN0Rf6dW3g="; + sha256 = "sha256-2SD+QJqeytnQdKqFaMpfPtNYG+ZvZuXYmIt+xm5tmaI="; pythonVersion = "3.7"; db = db.override { dbmSupport = !stdenv.isDarwin; }; python = python27; diff --git a/pkgs/development/interpreters/python/pypy/default.nix b/pkgs/development/interpreters/python/pypy/default.nix index e4e95ad4c57d..668a4e24b39e 100644 --- a/pkgs/development/interpreters/python/pypy/default.nix +++ b/pkgs/development/interpreters/python/pypy/default.nix @@ -83,6 +83,11 @@ in with passthru; stdenv.mkDerivation rec { tk_libprefix = tk.libPrefix; tcl_libprefix = tcl.libPrefix; }) + + (substituteAll { + src = ./sqlite_paths.patch; + inherit (sqlite) out dev; + }) ]; postPatch = '' @@ -90,8 +95,6 @@ in with passthru; stdenv.mkDerivation rec { --replace "multiprocessing.cpu_count()" "$NIX_BUILD_CORES" substituteInPlace "lib-python/${if isPy3k then "3/tkinter/tix.py" else "2.7/lib-tk/Tix.py"}" --replace "os.environ.get('TIX_LIBRARY')" "os.environ.get('TIX_LIBRARY') or '${tix}/lib'" - - sed -i "s@libraries=\['sqlite3'\]\$@libraries=['sqlite3'], include_dirs=['${sqlite.dev}/include'], library_dirs=['${sqlite.out}/lib']@" lib_pypy/_sqlite3_build.py ''; buildPhase = '' diff --git a/pkgs/development/interpreters/python/pypy/sqlite_paths.patch b/pkgs/development/interpreters/python/pypy/sqlite_paths.patch new file mode 100644 index 000000000000..42de7efb3ea3 --- /dev/null +++ b/pkgs/development/interpreters/python/pypy/sqlite_paths.patch @@ -0,0 +1,12 @@ +diff -ur a/lib_pypy/_sqlite3_build.py b/lib_pypy/_sqlite3_build.py +--- a/lib_pypy/_sqlite3_build.py 2021-04-12 01:11:48.000000000 -0400 ++++ b/lib_pypy/_sqlite3_build.py 2021-07-14 18:08:33.000000000 -0400 +@@ -301,6 +301,8 @@ + else: + extra_args = dict( + libraries=libraries, ++ include_dirs=['@dev@/include'], ++ library_dirs=['@out@/lib'] + ) + + SOURCE = """