Merge pull request #29282 from obsidiansystems/soext

lib, treewide: Add `*Platform.extensions` and use it where possible
This commit is contained in:
John Ericson
2017-09-13 11:20:06 -04:00
committed by GitHub
18 changed files with 53 additions and 64 deletions
+4 -11
View File
@@ -80,14 +80,10 @@ let
else throw "Unsupported kind ${kind}");
in fetcher (builtins.removeAttrs attrs ["format"]) );
# This should become part of stdenv!
sharedLibraryExtension = if stdenv.isDarwin then ".dylib" else ".so";
in {
inherit python bootstrapped-pip pythonAtLeast pythonOlder isPy26 isPy27 isPy33 isPy34 isPy35 isPy36 isPyPy isPy3k mkPythonDerivation buildPythonPackage buildPythonApplication;
inherit fetchPypi callPackage;
inherit sharedLibraryExtension;
# helpers
@@ -11647,7 +11643,7 @@ in {
propagatedBuildInputs = with self; [ pkgs.file ];
patchPhase = ''
substituteInPlace magic.py --replace "ctypes.util.find_library('magic')" "'${pkgs.file}/lib/libmagic.${if stdenv.isDarwin then "dylib" else "so"}'"
substituteInPlace magic.py --replace "ctypes.util.find_library('magic')" "'${pkgs.file}/lib/libmagic${stdenv.hostPlatform.extensions.sharedLibrary}'"
'';
doCheck = false;
@@ -11669,7 +11665,7 @@ in {
src = pkgs.file.src;
patchPhase = ''
substituteInPlace python/magic.py --replace "find_library('magic')" "'${pkgs.file}/lib/libmagic.${if stdenv.isDarwin then "dylib" else "so"}'"
substituteInPlace python/magic.py --replace "find_library('magic')" "'${pkgs.file}/lib/libmagic${stdenv.hostPlatform.extensions.sharedLibrary}'"
'';
buildInputs = with self; [ pkgs.file ];
@@ -24184,11 +24180,8 @@ EOF
# Fix the USB backend library lookup
postPatch =
let
# This should really be in the stdenv somewhere
soext = if stdenv.isLinux then "so" else if stdenv.isDarwin then "dylib" else throw "Unsupported platform";
in ''
libusb=${pkgs.libusb1.out}/lib/libusb-1.0.${soext}
''
libusb=${pkgs.libusb1.out}/lib/libusb-1.0${stdenv.hostPlatform.extensions.sharedLibrary}
test -f $libusb || { echo "ERROR: $libusb doesn't exist, please update/fix this build expression."; exit 1; }
sed -i -e "s|find_library=None|find_library=lambda _:\"$libusb\"|" usb/backend/libusb1.py
'';