treewide: Format all Nix files
Format all Nix files using the officially approved formatter, making the CI check introduced in the previous commit succeed: nix-build ci -A fmt.check This is the next step of the of the [implementation](https://github.com/NixOS/nixfmt/issues/153) of the accepted [RFC 166](https://github.com/NixOS/rfcs/pull/166). This commit will lead to merge conflicts for a number of PRs, up to an estimated ~1100 (~33%) among the PRs with activity in the past 2 months, but that should be lower than what it would be without the previous [partial treewide format](https://github.com/NixOS/nixpkgs/pull/322537). Merge conflicts caused by this commit can now automatically be resolved while rebasing using the [auto-rebase script](https://github.com/NixOS/nixpkgs/tree/8616af08d915377bd930395f3b700a0e93d08728/maintainers/scripts/auto-rebase). If you run into any problems regarding any of this, please reach out to the [formatting team](https://nixos.org/community/teams/formatting/) by pinging @NixOS/nix-formatting.
This commit is contained in:
@@ -1,22 +1,41 @@
|
||||
{ lib, stdenv, replaceVars, fetchurl
|
||||
, zlibSupport ? true, zlib
|
||||
, bzip2, pkg-config, libffi
|
||||
, sqlite, openssl, ncurses, python, expat, tcl, tk, tclPackages, libX11
|
||||
, gdbm, db, xz, python-setup-hook
|
||||
, optimizationLevel ? "jit", boehmgc
|
||||
# For the Python package set
|
||||
, hash
|
||||
, self
|
||||
, packageOverrides ? (self: super: {})
|
||||
, pkgsBuildBuild
|
||||
, pkgsBuildHost
|
||||
, pkgsBuildTarget
|
||||
, pkgsHostHost
|
||||
, pkgsTargetTarget
|
||||
, sourceVersion
|
||||
, pythonVersion
|
||||
, passthruFun
|
||||
, pythonAttr ? "pypy${lib.substring 0 1 pythonVersion}${lib.substring 2 3 pythonVersion}"
|
||||
{
|
||||
lib,
|
||||
stdenv,
|
||||
replaceVars,
|
||||
fetchurl,
|
||||
zlibSupport ? true,
|
||||
zlib,
|
||||
bzip2,
|
||||
pkg-config,
|
||||
libffi,
|
||||
sqlite,
|
||||
openssl,
|
||||
ncurses,
|
||||
python,
|
||||
expat,
|
||||
tcl,
|
||||
tk,
|
||||
tclPackages,
|
||||
libX11,
|
||||
gdbm,
|
||||
db,
|
||||
xz,
|
||||
python-setup-hook,
|
||||
optimizationLevel ? "jit",
|
||||
boehmgc,
|
||||
# For the Python package set
|
||||
hash,
|
||||
self,
|
||||
packageOverrides ? (self: super: { }),
|
||||
pkgsBuildBuild,
|
||||
pkgsBuildHost,
|
||||
pkgsBuildTarget,
|
||||
pkgsHostHost,
|
||||
pkgsTargetTarget,
|
||||
sourceVersion,
|
||||
pythonVersion,
|
||||
passthruFun,
|
||||
pythonAttr ? "pypy${lib.substring 0 1 pythonVersion}${lib.substring 2 3 pythonVersion}",
|
||||
}:
|
||||
|
||||
assert zlibSupport -> zlib != null;
|
||||
@@ -26,10 +45,17 @@ let
|
||||
isPy38OrNewer = lib.versionAtLeast pythonVersion "3.8";
|
||||
isPy39OrNewer = lib.versionAtLeast pythonVersion "3.9";
|
||||
passthru = passthruFun rec {
|
||||
inherit self sourceVersion pythonVersion packageOverrides;
|
||||
inherit
|
||||
self
|
||||
sourceVersion
|
||||
pythonVersion
|
||||
packageOverrides
|
||||
;
|
||||
implementation = "pypy";
|
||||
libPrefix = "pypy${pythonVersion}";
|
||||
executable = "pypy${if isPy39OrNewer then lib.versions.majorMinor pythonVersion else lib.optionalString isPy3k "3"}";
|
||||
executable = "pypy${
|
||||
if isPy39OrNewer then lib.versions.majorMinor pythonVersion else lib.optionalString isPy3k "3"
|
||||
}";
|
||||
sitePackages = "${lib.optionalString isPy38OrNewer "lib/${libPrefix}/"}site-packages";
|
||||
hasDistutilsCxxPatch = false;
|
||||
inherit pythonAttr;
|
||||
@@ -38,13 +64,15 @@ let
|
||||
pythonOnBuildForHost = pkgsBuildHost.${pythonAttr};
|
||||
pythonOnBuildForTarget = pkgsBuildTarget.${pythonAttr};
|
||||
pythonOnHostForHost = pkgsHostHost.${pythonAttr};
|
||||
pythonOnTargetForTarget = pkgsTargetTarget.${pythonAttr} or {};
|
||||
pythonOnTargetForTarget = pkgsTargetTarget.${pythonAttr} or { };
|
||||
};
|
||||
pname = passthru.executable;
|
||||
version = with sourceVersion; "${major}.${minor}.${patch}";
|
||||
pythonForPypy = python.withPackages (ppkgs: [ ]);
|
||||
|
||||
in with passthru; stdenv.mkDerivation rec {
|
||||
in
|
||||
with passthru;
|
||||
stdenv.mkDerivation rec {
|
||||
inherit pname version;
|
||||
|
||||
src = fetchurl {
|
||||
@@ -53,17 +81,41 @@ in with passthru; stdenv.mkDerivation rec {
|
||||
};
|
||||
|
||||
nativeBuildInputs = [ pkg-config ];
|
||||
buildInputs = [
|
||||
bzip2 openssl pythonForPypy libffi ncurses expat sqlite tk tcl libX11 gdbm db
|
||||
] ++ lib.optionals isPy3k [
|
||||
xz
|
||||
] ++ lib.optionals (stdenv ? cc && stdenv.cc.libc != null) [
|
||||
stdenv.cc.libc
|
||||
] ++ lib.optionals zlibSupport [
|
||||
zlib
|
||||
] ++ lib.optionals (lib.any (l: l == optimizationLevel) [ "0" "1" "2" "3"]) [
|
||||
boehmgc
|
||||
];
|
||||
buildInputs =
|
||||
[
|
||||
bzip2
|
||||
openssl
|
||||
pythonForPypy
|
||||
libffi
|
||||
ncurses
|
||||
expat
|
||||
sqlite
|
||||
tk
|
||||
tcl
|
||||
libX11
|
||||
gdbm
|
||||
db
|
||||
]
|
||||
++ lib.optionals isPy3k [
|
||||
xz
|
||||
]
|
||||
++ lib.optionals (stdenv ? cc && stdenv.cc.libc != null) [
|
||||
stdenv.cc.libc
|
||||
]
|
||||
++ lib.optionals zlibSupport [
|
||||
zlib
|
||||
]
|
||||
++
|
||||
lib.optionals
|
||||
(lib.any (l: l == optimizationLevel) [
|
||||
"0"
|
||||
"1"
|
||||
"2"
|
||||
"3"
|
||||
])
|
||||
[
|
||||
boehmgc
|
||||
];
|
||||
|
||||
# Remove bootstrap python from closure
|
||||
dontPatchShebangs = true;
|
||||
@@ -71,7 +123,9 @@ in with passthru; stdenv.mkDerivation rec {
|
||||
|
||||
C_INCLUDE_PATH = lib.makeSearchPathOutput "dev" "include" buildInputs;
|
||||
LIBRARY_PATH = lib.makeLibraryPath buildInputs;
|
||||
LD_LIBRARY_PATH = lib.makeLibraryPath (builtins.filter (x : x.outPath != stdenv.cc.libc.outPath or "") buildInputs);
|
||||
LD_LIBRARY_PATH = lib.makeLibraryPath (
|
||||
builtins.filter (x: x.outPath != stdenv.cc.libc.outPath or "") buildInputs
|
||||
);
|
||||
|
||||
patches = [
|
||||
./dont_fetch_vendored_deps.patch
|
||||
@@ -123,83 +177,102 @@ 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/${if isPy38OrNewer then sitePackages else "lib/${libPrefix}/${sitePackages}"}/sitecustomize.py
|
||||
cp ${../sitecustomize.py} $out/${
|
||||
if isPy38OrNewer then sitePackages else "lib/${libPrefix}/${sitePackages}"
|
||||
}/sitecustomize.py
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
preFixup = lib.optionalString (stdenv.hostPlatform.isDarwin) ''
|
||||
install_name_tool -change @rpath/lib${executable}-c.dylib $out/lib/lib${executable}-c.dylib $out/bin/${executable}
|
||||
'' + lib.optionalString (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) ''
|
||||
mkdir -p $out/${executable}-c/pypy/bin
|
||||
mv $out/bin/${executable} $out/${executable}-c/pypy/bin/${executable}
|
||||
ln -s $out/${executable}-c/pypy/bin/${executable} $out/bin/${executable}
|
||||
'';
|
||||
preFixup =
|
||||
lib.optionalString (stdenv.hostPlatform.isDarwin) ''
|
||||
install_name_tool -change @rpath/lib${executable}-c.dylib $out/lib/lib${executable}-c.dylib $out/bin/${executable}
|
||||
''
|
||||
+ lib.optionalString (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) ''
|
||||
mkdir -p $out/${executable}-c/pypy/bin
|
||||
mv $out/bin/${executable} $out/${executable}-c/pypy/bin/${executable}
|
||||
ln -s $out/${executable}-c/pypy/bin/${executable} $out/bin/${executable}
|
||||
'';
|
||||
|
||||
setupHook = python-setup-hook sitePackages;
|
||||
|
||||
# TODO: A bunch of tests are failing as of 7.1.1, please feel free to
|
||||
# fix and re-enable if you have the patience and tenacity.
|
||||
doCheck = false;
|
||||
checkPhase = let
|
||||
disabledTests = [
|
||||
# disable shutils because it assumes gid 0 exists
|
||||
"test_shutil"
|
||||
# disable socket because it has two actual network tests that fail
|
||||
"test_socket"
|
||||
] ++ lib.optionals (!isPy3k) [
|
||||
# disable test_urllib2net, test_urllib2_localnet, and test_urllibnet because they require networking (example.com)
|
||||
"test_urllib2net"
|
||||
"test_urllibnet"
|
||||
"test_urllib2_localnet"
|
||||
] ++ lib.optionals isPy3k [
|
||||
# disable asyncio due to https://github.com/NixOS/nix/issues/1238
|
||||
"test_asyncio"
|
||||
# disable os due to https://github.com/NixOS/nixpkgs/issues/10496
|
||||
"test_os"
|
||||
# disable pathlib due to https://bitbucket.org/pypy/pypy/pull-requests/594
|
||||
"test_pathlib"
|
||||
# disable tarfile because it assumes gid 0 exists
|
||||
"test_tarfile"
|
||||
# disable __all__ because of spurious imp/importlib warning and
|
||||
# warning-to-error test policy
|
||||
"test___all__"
|
||||
];
|
||||
in ''
|
||||
export TERMINFO="${ncurses.out}/share/terminfo/";
|
||||
export TERM="xterm";
|
||||
export HOME="$TMPDIR";
|
||||
checkPhase =
|
||||
let
|
||||
disabledTests =
|
||||
[
|
||||
# disable shutils because it assumes gid 0 exists
|
||||
"test_shutil"
|
||||
# disable socket because it has two actual network tests that fail
|
||||
"test_socket"
|
||||
]
|
||||
++ lib.optionals (!isPy3k) [
|
||||
# disable test_urllib2net, test_urllib2_localnet, and test_urllibnet because they require networking (example.com)
|
||||
"test_urllib2net"
|
||||
"test_urllibnet"
|
||||
"test_urllib2_localnet"
|
||||
]
|
||||
++ lib.optionals isPy3k [
|
||||
# disable asyncio due to https://github.com/NixOS/nix/issues/1238
|
||||
"test_asyncio"
|
||||
# disable os due to https://github.com/NixOS/nixpkgs/issues/10496
|
||||
"test_os"
|
||||
# disable pathlib due to https://bitbucket.org/pypy/pypy/pull-requests/594
|
||||
"test_pathlib"
|
||||
# disable tarfile because it assumes gid 0 exists
|
||||
"test_tarfile"
|
||||
# disable __all__ because of spurious imp/importlib warning and
|
||||
# warning-to-error test policy
|
||||
"test___all__"
|
||||
];
|
||||
in
|
||||
''
|
||||
export TERMINFO="${ncurses.out}/share/terminfo/";
|
||||
export TERM="xterm";
|
||||
export HOME="$TMPDIR";
|
||||
|
||||
${pythonForPypy.interpreter} ./pypy/test_all.py --pypy=./${executable}-c -k 'not (${lib.concatStringsSep " or " disabledTests})' lib-python
|
||||
'';
|
||||
${pythonForPypy.interpreter} ./pypy/test_all.py --pypy=./${executable}-c -k 'not (${lib.concatStringsSep " or " disabledTests})' lib-python
|
||||
'';
|
||||
|
||||
# verify cffi modules
|
||||
doInstallCheck = true;
|
||||
installCheckPhase = let
|
||||
modules = [
|
||||
"curses"
|
||||
"sqlite3"
|
||||
] ++ lib.optionals (!isPy3k) [
|
||||
"Tkinter"
|
||||
] ++ lib.optionals isPy3k [
|
||||
"tkinter"
|
||||
"lzma"
|
||||
];
|
||||
imports = lib.concatMapStringsSep "; " (x: "import ${x}") modules;
|
||||
in ''
|
||||
echo "Testing whether we can import modules"
|
||||
$out/bin/${executable} -c '${imports}'
|
||||
'';
|
||||
installCheckPhase =
|
||||
let
|
||||
modules =
|
||||
[
|
||||
"curses"
|
||||
"sqlite3"
|
||||
]
|
||||
++ lib.optionals (!isPy3k) [
|
||||
"Tkinter"
|
||||
]
|
||||
++ lib.optionals isPy3k [
|
||||
"tkinter"
|
||||
"lzma"
|
||||
];
|
||||
imports = lib.concatMapStringsSep "; " (x: "import ${x}") modules;
|
||||
in
|
||||
''
|
||||
echo "Testing whether we can import modules"
|
||||
$out/bin/${executable} -c '${imports}'
|
||||
'';
|
||||
|
||||
inherit passthru;
|
||||
enableParallelBuilding = true; # almost no parallelization without STM
|
||||
enableParallelBuilding = true; # almost no parallelization without STM
|
||||
|
||||
meta = with lib; {
|
||||
homepage = "https://www.pypy.org/";
|
||||
description = "Fast, compliant alternative implementation of the Python language (${pythonVersion})";
|
||||
mainProgram = "pypy";
|
||||
license = licenses.mit;
|
||||
platforms = [ "aarch64-linux" "x86_64-linux" "aarch64-darwin" "x86_64-darwin" ];
|
||||
platforms = [
|
||||
"aarch64-linux"
|
||||
"x86_64-linux"
|
||||
"aarch64-darwin"
|
||||
"x86_64-darwin"
|
||||
];
|
||||
broken = optimizationLevel == "0"; # generates invalid code
|
||||
maintainers = with maintainers; [ andersk ];
|
||||
};
|
||||
|
||||
@@ -1,26 +1,27 @@
|
||||
{ lib
|
||||
, stdenv
|
||||
, fetchurl
|
||||
, autoPatchelfHook
|
||||
, python-setup-hook
|
||||
, self
|
||||
# Dependencies
|
||||
, bzip2
|
||||
, expat
|
||||
, gdbm
|
||||
, ncurses6
|
||||
, sqlite
|
||||
, tcl-8_5
|
||||
, tk-8_5
|
||||
, tcl-8_6
|
||||
, tk-8_6
|
||||
, zlib
|
||||
# For the Python package set
|
||||
, packageOverrides ? (self: super: {})
|
||||
, sourceVersion
|
||||
, pythonVersion
|
||||
, hash
|
||||
, passthruFun
|
||||
{
|
||||
lib,
|
||||
stdenv,
|
||||
fetchurl,
|
||||
autoPatchelfHook,
|
||||
python-setup-hook,
|
||||
self,
|
||||
# Dependencies
|
||||
bzip2,
|
||||
expat,
|
||||
gdbm,
|
||||
ncurses6,
|
||||
sqlite,
|
||||
tcl-8_5,
|
||||
tk-8_5,
|
||||
tcl-8_6,
|
||||
tk-8_6,
|
||||
zlib,
|
||||
# For the Python package set
|
||||
packageOverrides ? (self: super: { }),
|
||||
sourceVersion,
|
||||
pythonVersion,
|
||||
hash,
|
||||
passthruFun,
|
||||
}:
|
||||
|
||||
# This version of PyPy is primarily added to speed-up translation of
|
||||
@@ -29,7 +30,12 @@
|
||||
let
|
||||
isPy3k = majorVersion == "3";
|
||||
passthru = passthruFun rec {
|
||||
inherit self sourceVersion pythonVersion packageOverrides;
|
||||
inherit
|
||||
self
|
||||
sourceVersion
|
||||
pythonVersion
|
||||
packageOverrides
|
||||
;
|
||||
implementation = "pypy";
|
||||
libPrefix = "pypy${pythonVersion}";
|
||||
executable = "pypy${lib.optionalString isPy3k "3"}";
|
||||
@@ -55,7 +61,9 @@ let
|
||||
x86_64-darwin = "https://downloads.python.org/pypy/pypy${pythonVersion}-v${version}-macos_x86_64.tar.bz2";
|
||||
};
|
||||
|
||||
in with passthru; stdenv.mkDerivation {
|
||||
in
|
||||
with passthru;
|
||||
stdenv.mkDerivation {
|
||||
inherit pname version;
|
||||
|
||||
src = fetchurl {
|
||||
@@ -63,21 +71,24 @@ in with passthru; stdenv.mkDerivation {
|
||||
inherit hash;
|
||||
};
|
||||
|
||||
buildInputs = [
|
||||
bzip2
|
||||
expat
|
||||
gdbm
|
||||
ncurses6
|
||||
sqlite
|
||||
zlib
|
||||
stdenv.cc.cc.libgcc or null
|
||||
] ++ lib.optionals stdenv.hostPlatform.isLinux [
|
||||
tcl-8_5
|
||||
tk-8_5
|
||||
] ++ lib.optionals stdenv.hostPlatform.isDarwin [
|
||||
tcl-8_6
|
||||
tk-8_6
|
||||
];
|
||||
buildInputs =
|
||||
[
|
||||
bzip2
|
||||
expat
|
||||
gdbm
|
||||
ncurses6
|
||||
sqlite
|
||||
zlib
|
||||
stdenv.cc.cc.libgcc or null
|
||||
]
|
||||
++ lib.optionals stdenv.hostPlatform.isLinux [
|
||||
tcl-8_5
|
||||
tk-8_5
|
||||
]
|
||||
++ lib.optionals stdenv.hostPlatform.isDarwin [
|
||||
tcl-8_6
|
||||
tk-8_6
|
||||
];
|
||||
|
||||
nativeBuildInputs = lib.optionals stdenv.hostPlatform.isLinux [ autoPatchelfHook ];
|
||||
|
||||
@@ -101,52 +112,59 @@ in with passthru; stdenv.mkDerivation {
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
preFixup = lib.optionalString stdenv.hostPlatform.isLinux ''
|
||||
find $out/{lib,lib_pypy*} -name "*.so" \
|
||||
-exec patchelf \
|
||||
--replace-needed libtinfow.so.6 libncursesw.so.6 \
|
||||
--replace-needed libgdbm.so.4 libgdbm_compat.so.4 {} \;
|
||||
'' + lib.optionalString stdenv.hostPlatform.isDarwin ''
|
||||
install_name_tool \
|
||||
-change \
|
||||
@rpath/lib${libPrefix}-c.dylib \
|
||||
$out/lib/lib${libPrefix}-c.dylib \
|
||||
$out/bin/${executable}
|
||||
install_name_tool \
|
||||
-change \
|
||||
@rpath/lib${libPrefix}-c.dylib \
|
||||
$out/lib/lib${libPrefix}-c.dylib \
|
||||
$out/bin/${libPrefix}
|
||||
install_name_tool \
|
||||
-change \
|
||||
/opt/homebrew${lib.optionalString stdenv.hostPlatform.isx86_64 "_x86_64"}/opt/tcl-tk/lib/libtcl8.6.dylib \
|
||||
${tcl-8_6}/lib/libtcl8.6.dylib \
|
||||
$out/lib/${libPrefix}/_tkinter/*.so
|
||||
install_name_tool \
|
||||
-change \
|
||||
/opt/homebrew${lib.optionalString stdenv.hostPlatform.isx86_64 "_x86_64"}/opt/tcl-tk/lib/libtk8.6.dylib \
|
||||
${tk-8_6}/lib/libtk8.6.dylib \
|
||||
$out/lib/${libPrefix}/_tkinter/*.so
|
||||
'';
|
||||
preFixup =
|
||||
lib.optionalString stdenv.hostPlatform.isLinux ''
|
||||
find $out/{lib,lib_pypy*} -name "*.so" \
|
||||
-exec patchelf \
|
||||
--replace-needed libtinfow.so.6 libncursesw.so.6 \
|
||||
--replace-needed libgdbm.so.4 libgdbm_compat.so.4 {} \;
|
||||
''
|
||||
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
|
||||
install_name_tool \
|
||||
-change \
|
||||
@rpath/lib${libPrefix}-c.dylib \
|
||||
$out/lib/lib${libPrefix}-c.dylib \
|
||||
$out/bin/${executable}
|
||||
install_name_tool \
|
||||
-change \
|
||||
@rpath/lib${libPrefix}-c.dylib \
|
||||
$out/lib/lib${libPrefix}-c.dylib \
|
||||
$out/bin/${libPrefix}
|
||||
install_name_tool \
|
||||
-change \
|
||||
/opt/homebrew${lib.optionalString stdenv.hostPlatform.isx86_64 "_x86_64"}/opt/tcl-tk/lib/libtcl8.6.dylib \
|
||||
${tcl-8_6}/lib/libtcl8.6.dylib \
|
||||
$out/lib/${libPrefix}/_tkinter/*.so
|
||||
install_name_tool \
|
||||
-change \
|
||||
/opt/homebrew${lib.optionalString stdenv.hostPlatform.isx86_64 "_x86_64"}/opt/tcl-tk/lib/libtk8.6.dylib \
|
||||
${tk-8_6}/lib/libtk8.6.dylib \
|
||||
$out/lib/${libPrefix}/_tkinter/*.so
|
||||
'';
|
||||
|
||||
doInstallCheck = true;
|
||||
|
||||
# Check whether importing of (extension) modules functions
|
||||
installCheckPhase = let
|
||||
modules = [
|
||||
"ssl"
|
||||
"sys"
|
||||
"curses"
|
||||
] ++ lib.optionals (!isPy3k) [
|
||||
"Tkinter"
|
||||
] ++ lib.optionals isPy3k [
|
||||
"tkinter"
|
||||
];
|
||||
imports = lib.concatMapStringsSep "; " (x: "import ${x}") modules;
|
||||
in ''
|
||||
echo "Testing whether we can import modules"
|
||||
$out/bin/${executable} -c '${imports}'
|
||||
'';
|
||||
installCheckPhase =
|
||||
let
|
||||
modules =
|
||||
[
|
||||
"ssl"
|
||||
"sys"
|
||||
"curses"
|
||||
]
|
||||
++ lib.optionals (!isPy3k) [
|
||||
"Tkinter"
|
||||
]
|
||||
++ lib.optionals isPy3k [
|
||||
"tkinter"
|
||||
];
|
||||
imports = lib.concatMapStringsSep "; " (x: "import ${x}") modules;
|
||||
in
|
||||
''
|
||||
echo "Testing whether we can import modules"
|
||||
$out/bin/${executable} -c '${imports}'
|
||||
'';
|
||||
|
||||
setupHook = python-setup-hook sitePackages;
|
||||
|
||||
|
||||
@@ -1,26 +1,27 @@
|
||||
{ lib
|
||||
, stdenv
|
||||
, fetchurl
|
||||
, autoPatchelfHook
|
||||
, python-setup-hook
|
||||
, self
|
||||
# Dependencies
|
||||
, bzip2
|
||||
, expat
|
||||
, gdbm
|
||||
, ncurses6
|
||||
, sqlite
|
||||
, tcl-8_5
|
||||
, tk-8_5
|
||||
, tcl-8_6
|
||||
, tk-8_6
|
||||
, zlib
|
||||
# For the Python package set
|
||||
, packageOverrides ? (self: super: {})
|
||||
, sourceVersion
|
||||
, pythonVersion
|
||||
, hash
|
||||
, passthruFun
|
||||
{
|
||||
lib,
|
||||
stdenv,
|
||||
fetchurl,
|
||||
autoPatchelfHook,
|
||||
python-setup-hook,
|
||||
self,
|
||||
# Dependencies
|
||||
bzip2,
|
||||
expat,
|
||||
gdbm,
|
||||
ncurses6,
|
||||
sqlite,
|
||||
tcl-8_5,
|
||||
tk-8_5,
|
||||
tcl-8_6,
|
||||
tk-8_6,
|
||||
zlib,
|
||||
# For the Python package set
|
||||
packageOverrides ? (self: super: { }),
|
||||
sourceVersion,
|
||||
pythonVersion,
|
||||
hash,
|
||||
passthruFun,
|
||||
}:
|
||||
|
||||
# This version of PyPy is primarily added to speed-up translation of
|
||||
@@ -29,7 +30,12 @@
|
||||
let
|
||||
isPy3k = majorVersion == "3";
|
||||
passthru = passthruFun {
|
||||
inherit self sourceVersion pythonVersion packageOverrides;
|
||||
inherit
|
||||
self
|
||||
sourceVersion
|
||||
pythonVersion
|
||||
packageOverrides
|
||||
;
|
||||
implementation = "pypy";
|
||||
libPrefix = "pypy${pythonVersion}";
|
||||
executable = "pypy${lib.optionalString isPy3k "3"}";
|
||||
@@ -55,7 +61,9 @@ let
|
||||
x86_64-darwin = "https://downloads.python.org/pypy/pypy${pythonVersion}-v${version}-macos_x86_64.tar.bz2";
|
||||
};
|
||||
|
||||
in with passthru; stdenv.mkDerivation {
|
||||
in
|
||||
with passthru;
|
||||
stdenv.mkDerivation {
|
||||
inherit pname version;
|
||||
|
||||
src = fetchurl {
|
||||
@@ -63,21 +71,24 @@ in with passthru; stdenv.mkDerivation {
|
||||
inherit hash;
|
||||
};
|
||||
|
||||
buildInputs = [
|
||||
bzip2
|
||||
expat
|
||||
gdbm
|
||||
ncurses6
|
||||
sqlite
|
||||
zlib
|
||||
stdenv.cc.cc.libgcc or null
|
||||
] ++ lib.optionals stdenv.hostPlatform.isLinux [
|
||||
tcl-8_5
|
||||
tk-8_5
|
||||
] ++ lib.optionals stdenv.hostPlatform.isDarwin [
|
||||
tcl-8_6
|
||||
tk-8_6
|
||||
];
|
||||
buildInputs =
|
||||
[
|
||||
bzip2
|
||||
expat
|
||||
gdbm
|
||||
ncurses6
|
||||
sqlite
|
||||
zlib
|
||||
stdenv.cc.cc.libgcc or null
|
||||
]
|
||||
++ lib.optionals stdenv.hostPlatform.isLinux [
|
||||
tcl-8_5
|
||||
tk-8_5
|
||||
]
|
||||
++ lib.optionals stdenv.hostPlatform.isDarwin [
|
||||
tcl-8_6
|
||||
tk-8_6
|
||||
];
|
||||
|
||||
nativeBuildInputs = lib.optionals stdenv.hostPlatform.isLinux [ autoPatchelfHook ];
|
||||
|
||||
@@ -102,47 +113,54 @@ in with passthru; stdenv.mkDerivation {
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
preFixup = lib.optionalString (stdenv.hostPlatform.isLinux) ''
|
||||
find $out/{lib,lib_pypy*} -name "*.so" \
|
||||
-exec patchelf \
|
||||
--replace-needed libtinfow.so.6 libncursesw.so.6 \
|
||||
--replace-needed libgdbm.so.4 libgdbm_compat.so.4 {} \;
|
||||
'' + lib.optionalString (stdenv.hostPlatform.isDarwin) ''
|
||||
install_name_tool \
|
||||
-change \
|
||||
@rpath/lib${executable}-c.dylib \
|
||||
$out/lib/lib${executable}-c.dylib \
|
||||
$out/bin/${executable}
|
||||
install_name_tool \
|
||||
-change \
|
||||
/opt/homebrew${lib.optionalString stdenv.hostPlatform.isx86_64 "_x86_64"}/opt/tcl-tk/lib/libtcl8.6.dylib \
|
||||
${tcl-8_6}/lib/libtcl8.6.dylib \
|
||||
$out/lib_pypy/_tkinter/*.so
|
||||
install_name_tool \
|
||||
-change \
|
||||
/opt/homebrew${lib.optionalString stdenv.hostPlatform.isx86_64 "_x86_64"}/opt/tcl-tk/lib/libtk8.6.dylib \
|
||||
${tk-8_6}/lib/libtk8.6.dylib \
|
||||
$out/lib_pypy/_tkinter/*.so
|
||||
'';
|
||||
preFixup =
|
||||
lib.optionalString (stdenv.hostPlatform.isLinux) ''
|
||||
find $out/{lib,lib_pypy*} -name "*.so" \
|
||||
-exec patchelf \
|
||||
--replace-needed libtinfow.so.6 libncursesw.so.6 \
|
||||
--replace-needed libgdbm.so.4 libgdbm_compat.so.4 {} \;
|
||||
''
|
||||
+ lib.optionalString (stdenv.hostPlatform.isDarwin) ''
|
||||
install_name_tool \
|
||||
-change \
|
||||
@rpath/lib${executable}-c.dylib \
|
||||
$out/lib/lib${executable}-c.dylib \
|
||||
$out/bin/${executable}
|
||||
install_name_tool \
|
||||
-change \
|
||||
/opt/homebrew${lib.optionalString stdenv.hostPlatform.isx86_64 "_x86_64"}/opt/tcl-tk/lib/libtcl8.6.dylib \
|
||||
${tcl-8_6}/lib/libtcl8.6.dylib \
|
||||
$out/lib_pypy/_tkinter/*.so
|
||||
install_name_tool \
|
||||
-change \
|
||||
/opt/homebrew${lib.optionalString stdenv.hostPlatform.isx86_64 "_x86_64"}/opt/tcl-tk/lib/libtk8.6.dylib \
|
||||
${tk-8_6}/lib/libtk8.6.dylib \
|
||||
$out/lib_pypy/_tkinter/*.so
|
||||
'';
|
||||
|
||||
doInstallCheck = true;
|
||||
|
||||
# Check whether importing of (extension) modules functions
|
||||
installCheckPhase = let
|
||||
modules = [
|
||||
"ssl"
|
||||
"sys"
|
||||
"curses"
|
||||
] ++ lib.optionals (!isPy3k) [
|
||||
"Tkinter"
|
||||
] ++ lib.optionals isPy3k [
|
||||
"tkinter"
|
||||
];
|
||||
imports = lib.concatMapStringsSep "; " (x: "import ${x}") modules;
|
||||
in ''
|
||||
echo "Testing whether we can import modules"
|
||||
$out/bin/${executable} -c '${imports}'
|
||||
'';
|
||||
installCheckPhase =
|
||||
let
|
||||
modules =
|
||||
[
|
||||
"ssl"
|
||||
"sys"
|
||||
"curses"
|
||||
]
|
||||
++ lib.optionals (!isPy3k) [
|
||||
"Tkinter"
|
||||
]
|
||||
++ lib.optionals isPy3k [
|
||||
"tkinter"
|
||||
];
|
||||
imports = lib.concatMapStringsSep "; " (x: "import ${x}") modules;
|
||||
in
|
||||
''
|
||||
echo "Testing whether we can import modules"
|
||||
$out/bin/${executable} -c '${imports}'
|
||||
'';
|
||||
|
||||
setupHook = python-setup-hook sitePackages;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user