buildPythonPackage: add support for conda
This commit is contained in:
parent
ae3d04bf55
commit
6c0b85cf3a
14
.github/CODEOWNERS
vendored
14
.github/CODEOWNERS
vendored
|
@ -72,12 +72,14 @@
|
||||||
/pkgs/common-updater/scripts/update-source-version @jtojnar
|
/pkgs/common-updater/scripts/update-source-version @jtojnar
|
||||||
|
|
||||||
# Python-related code and docs
|
# Python-related code and docs
|
||||||
/maintainers/scripts/update-python-libraries @FRidh
|
/maintainers/scripts/update-python-libraries @FRidh
|
||||||
/pkgs/top-level/python-packages.nix @FRidh @jonringer
|
/pkgs/top-level/python-packages.nix @FRidh @jonringer
|
||||||
/pkgs/development/interpreters/python @FRidh
|
/pkgs/development/interpreters/python @FRidh
|
||||||
/pkgs/development/python-modules @FRidh @jonringer
|
/pkgs/development/python-modules @FRidh @jonringer
|
||||||
/doc/languages-frameworks/python.section.md @FRidh
|
/doc/languages-frameworks/python.section.md @FRidh
|
||||||
/pkgs/development/tools/poetry2nix @adisbladis
|
/pkgs/development/tools/poetry2nix @adisbladis
|
||||||
|
/pkgs/development/interpreters/python/hooks @FRidh @jonringer @DavHau
|
||||||
|
/pkgs/development/interpreters/python/conda @DavHau
|
||||||
|
|
||||||
# Haskell
|
# Haskell
|
||||||
/doc/languages-frameworks/haskell.section.md @cdepillabout @sternenseemann @maralorn
|
/doc/languages-frameworks/haskell.section.md @cdepillabout @sternenseemann @maralorn
|
||||||
|
|
25
pkgs/development/interpreters/python/conda/default.nix
Normal file
25
pkgs/development/interpreters/python/conda/default.nix
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
{ pkgs }: {
|
||||||
|
|
||||||
|
# List of libraries that are needed for conda binary packages.
|
||||||
|
# When installing a conda binary package, just extend
|
||||||
|
# the `buildInputs` with `condaAutopatchLibs`.
|
||||||
|
condaPatchelfLibs = builtins.map (p: p.lib or p) ([
|
||||||
|
pkgs.alsaLib
|
||||||
|
pkgs.cups
|
||||||
|
pkgs.gcc-unwrapped
|
||||||
|
pkgs.libGL
|
||||||
|
] ++ (with pkgs.xorg; [
|
||||||
|
libSM
|
||||||
|
libICE
|
||||||
|
libX11
|
||||||
|
libXau
|
||||||
|
libXdamage
|
||||||
|
libXi
|
||||||
|
libXrender
|
||||||
|
libXrandr
|
||||||
|
libXcomposite
|
||||||
|
libXcursor
|
||||||
|
libXtst
|
||||||
|
libXScrnSaver])
|
||||||
|
);
|
||||||
|
}
|
|
@ -44,6 +44,8 @@ with pkgs;
|
||||||
toPythonModule toPythonApplication
|
toPythonModule toPythonApplication
|
||||||
buildSetupcfg
|
buildSetupcfg
|
||||||
|
|
||||||
|
condaInstallHook
|
||||||
|
condaUnpackHook
|
||||||
eggUnpackHook
|
eggUnpackHook
|
||||||
eggBuildHook
|
eggBuildHook
|
||||||
eggInstallHook
|
eggInstallHook
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
# Setup hook to use in case a conda binary package is installed
|
||||||
|
echo "Sourcing conda install hook"
|
||||||
|
|
||||||
|
condaInstallPhase(){
|
||||||
|
echo "Executing condaInstallPhase"
|
||||||
|
runHook preInstall
|
||||||
|
|
||||||
|
# There are two different formats of conda packages.
|
||||||
|
# It either contains only a site-packages directory
|
||||||
|
# or multiple top level directories.
|
||||||
|
siteDir=@pythonSitePackages@
|
||||||
|
if [ -e ./site-packages ]; then
|
||||||
|
mkdir -p $out/$siteDir
|
||||||
|
cp -r ./site-packages/* $out/$siteDir
|
||||||
|
else
|
||||||
|
cp -r . $out
|
||||||
|
rm $out/env-vars
|
||||||
|
fi
|
||||||
|
|
||||||
|
runHook postInstall
|
||||||
|
echo "Finished executing condaInstallPhase"
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ -z "${installPhase-}" ]; then
|
||||||
|
echo "Using condaInstallPhase"
|
||||||
|
installPhase=condaInstallPhase
|
||||||
|
fi
|
|
@ -0,0 +1,18 @@
|
||||||
|
# Setup hook to use in case a conda binary package is fetched
|
||||||
|
echo "Sourcing conda unpack hook"
|
||||||
|
|
||||||
|
condaUnpackPhase(){
|
||||||
|
echo "Executing condaUnpackPhase"
|
||||||
|
runHook preUnpack
|
||||||
|
|
||||||
|
# use lbzip2 for parallel decompression (bz2 is slow)
|
||||||
|
lbzip2 -dc -n $NIX_BUILD_CORES $src | tar --exclude='info' -x
|
||||||
|
|
||||||
|
# runHook postUnpack # Calls find...?
|
||||||
|
echo "Finished executing condaUnpackPhase"
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ -z "${unpackPhase-}" ]; then
|
||||||
|
echo "Using condaUnpackPhase"
|
||||||
|
unpackPhase=condaUnpackPhase
|
||||||
|
fi
|
|
@ -16,6 +16,21 @@ let
|
||||||
setuppy = ../run_setup.py;
|
setuppy = ../run_setup.py;
|
||||||
in rec {
|
in rec {
|
||||||
|
|
||||||
|
condaInstallHook = callPackage ({ gnutar, lbzip2 }:
|
||||||
|
makeSetupHook {
|
||||||
|
name = "conda-install-hook";
|
||||||
|
deps = [ gnutar lbzip2 ];
|
||||||
|
substitutions = {
|
||||||
|
inherit pythonSitePackages;
|
||||||
|
};
|
||||||
|
} ./conda-install-hook.sh) {};
|
||||||
|
|
||||||
|
condaUnpackHook = callPackage ({}:
|
||||||
|
makeSetupHook {
|
||||||
|
name = "conda-unpack-hook";
|
||||||
|
deps = [];
|
||||||
|
} ./conda-unpack-hook.sh) {};
|
||||||
|
|
||||||
eggBuildHook = callPackage ({ }:
|
eggBuildHook = callPackage ({ }:
|
||||||
makeSetupHook {
|
makeSetupHook {
|
||||||
name = "egg-build-hook.sh";
|
name = "egg-build-hook.sh";
|
||||||
|
|
|
@ -121,4 +121,37 @@ let
|
||||||
# in assert myPackages.foobar == myPackages.numpy; myPackages.python.withPackages(ps: with ps; [ foobar ]);
|
# in assert myPackages.foobar == myPackages.numpy; myPackages.python.withPackages(ps: with ps; [ foobar ]);
|
||||||
};
|
};
|
||||||
|
|
||||||
in lib.optionalAttrs (stdenv.hostPlatform == stdenv.buildPlatform ) (environmentTests // integrationTests // overrideTests)
|
condaTests = let
|
||||||
|
requests = callPackage ({
|
||||||
|
autoPatchelfHook,
|
||||||
|
fetchurl,
|
||||||
|
pythonCondaPackages,
|
||||||
|
}:
|
||||||
|
python.pkgs.buildPythonPackage {
|
||||||
|
pname = "requests";
|
||||||
|
version = "2.24.0";
|
||||||
|
format = "other";
|
||||||
|
src = fetchurl {
|
||||||
|
url = "https://repo.anaconda.com/pkgs/main/noarch/requests-2.24.0-py_0.tar.bz2";
|
||||||
|
sha256 = "02qzaf6gwsqbcs69pix1fnjxzgnngwzvrsy65h1d521g750mjvvp";
|
||||||
|
};
|
||||||
|
nativeBuildInputs = [ autoPatchelfHook ] ++ (with python.pkgs; [
|
||||||
|
condaUnpackHook condaInstallHook
|
||||||
|
]);
|
||||||
|
buildInputs = [
|
||||||
|
pythonCondaPackages.condaPatchelfLibs
|
||||||
|
];
|
||||||
|
propagatedBuildInputs = with python.pkgs; [
|
||||||
|
chardet idna urllib3 certifi
|
||||||
|
];
|
||||||
|
}
|
||||||
|
) {};
|
||||||
|
pythonWithRequests = requests.pythonModule.withPackages (ps: [ requests ]);
|
||||||
|
in
|
||||||
|
{
|
||||||
|
condaExamplePackage = runCommand "import-requests" {} ''
|
||||||
|
${pythonWithRequests.interpreter} -c "import requests" > $out
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
in lib.optionalAttrs (stdenv.hostPlatform == stdenv.buildPlatform ) (environmentTests // integrationTests // overrideTests // condaTests)
|
||||||
|
|
|
@ -12336,6 +12336,8 @@ in
|
||||||
|
|
||||||
pythonManylinuxPackages = callPackage ./../development/interpreters/python/manylinux { };
|
pythonManylinuxPackages = callPackage ./../development/interpreters/python/manylinux { };
|
||||||
|
|
||||||
|
pythonCondaPackages = callPackage ./../development/interpreters/python/conda { };
|
||||||
|
|
||||||
update-python-libraries = callPackage ../development/interpreters/python/update-python-libraries { };
|
update-python-libraries = callPackage ../development/interpreters/python/update-python-libraries { };
|
||||||
|
|
||||||
# Should eventually be moved inside Python interpreters.
|
# Should eventually be moved inside Python interpreters.
|
||||||
|
|
|
@ -112,6 +112,8 @@ in {
|
||||||
inherit buildSetupcfg;
|
inherit buildSetupcfg;
|
||||||
|
|
||||||
inherit (callPackage ../development/interpreters/python/hooks { })
|
inherit (callPackage ../development/interpreters/python/hooks { })
|
||||||
|
condaInstallHook
|
||||||
|
condaUnpackHook
|
||||||
eggUnpackHook
|
eggUnpackHook
|
||||||
eggBuildHook
|
eggBuildHook
|
||||||
eggInstallHook
|
eggInstallHook
|
||||||
|
|
Loading…
Reference in a new issue