python3: fix build on native FreeBSD
* Make use of libxcrypt conditional (documented inline) * Patch use of uname to to not pull in some impure information * Various cases where behavior is split out among operating systems are now inclusive of FreeBSD
This commit is contained in:
@@ -121,6 +121,9 @@ let
|
||||
versionOlder
|
||||
;
|
||||
|
||||
# mixes libc and libxcrypt headers and libs and causes segfaults on importing crypt
|
||||
libxcrypt = if stdenv.hostPlatform.isFreeBSD then null else inputs.libxcrypt;
|
||||
|
||||
buildPackages = pkgsBuildHost;
|
||||
inherit (passthru) pythonOnBuildForHost;
|
||||
|
||||
@@ -261,6 +264,7 @@ let
|
||||
|
||||
multiarch =
|
||||
if isDarwin then "darwin"
|
||||
else if isFreeBSD then ""
|
||||
else if isWindows then ""
|
||||
else "${multiarchCpu}-${machdep}-${pythonAbiName}";
|
||||
|
||||
@@ -445,7 +449,11 @@ in with passthru; stdenv.mkDerivation (finalAttrs: {
|
||||
"LDFLAGS=-static"
|
||||
];
|
||||
|
||||
preConfigure = optionalString (pythonOlder "3.12") ''
|
||||
preConfigure = ''
|
||||
# Attempt to purify some of the host info collection
|
||||
sed -E -i -e 's/uname -r/echo/g' -e 's/uname -n/echo nixpkgs/g' config.guess
|
||||
sed -E -i -e 's/uname -r/echo/g' -e 's/uname -n/echo nixpkgs/g' configure
|
||||
'' + optionalString (pythonOlder "3.12") ''
|
||||
# Improve purity
|
||||
for path in /usr /sw /opt /pkg; do
|
||||
substituteInPlace ./setup.py --replace-warn $path /no-such-path
|
||||
@@ -476,10 +484,10 @@ in with passthru; stdenv.mkDerivation (finalAttrs: {
|
||||
postInstall = let
|
||||
# References *not* to nuke from (sys)config files
|
||||
keep-references = concatMapStringsSep " " (val: "-e ${val}") ([
|
||||
(placeholder "out") libxcrypt
|
||||
] ++ optionals tzdataSupport [
|
||||
tzdata
|
||||
]);
|
||||
(placeholder "out")
|
||||
] ++ lib.optional (libxcrypt != null) libxcrypt
|
||||
++ lib.optional tzdataSupport tzdata
|
||||
);
|
||||
in lib.optionalString enableFramework ''
|
||||
for dir in include lib share; do
|
||||
ln -s $out/Library/Frameworks/Python.framework/Versions/Current/$dir $out/$dir
|
||||
@@ -661,7 +669,7 @@ in with passthru; stdenv.mkDerivation (finalAttrs: {
|
||||
'';
|
||||
license = licenses.psfl;
|
||||
pkgConfigModules = [ "python3" ];
|
||||
platforms = platforms.linux ++ platforms.darwin ++ platforms.windows;
|
||||
platforms = platforms.linux ++ platforms.darwin ++ platforms.windows ++ platforms.freebsd;
|
||||
mainProgram = executable;
|
||||
};
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user