2022-10-03 10:25:02 +00:00
|
|
|
self: super: with self;
|
2019-07-17 18:36:47 +00:00
|
|
|
|
|
|
|
let
|
2022-10-03 10:25:02 +00:00
|
|
|
pythonInterpreter = super.python.pythonForBuild.interpreter;
|
|
|
|
pythonSitePackages = super.python.sitePackages;
|
|
|
|
pythonCheckInterpreter = super.python.interpreter;
|
2019-07-17 18:36:47 +00:00
|
|
|
setuppy = ../run_setup.py;
|
2022-10-03 10:25:02 +00:00
|
|
|
in {
|
|
|
|
makePythonHook = args: pkgs.makeSetupHook ({passthru.provides.setupHook = true; } // args);
|
2019-07-17 18:36:47 +00:00
|
|
|
|
2022-10-03 10:25:02 +00:00
|
|
|
condaInstallHook = callPackage ({ makePythonHook, gnutar, lbzip2 }:
|
|
|
|
makePythonHook {
|
2021-05-16 08:13:39 +00:00
|
|
|
name = "conda-install-hook";
|
2023-01-01 20:10:24 +00:00
|
|
|
propagatedBuildInputs = [ gnutar lbzip2 ];
|
2021-05-16 08:13:39 +00:00
|
|
|
substitutions = {
|
|
|
|
inherit pythonSitePackages;
|
|
|
|
};
|
|
|
|
} ./conda-install-hook.sh) {};
|
|
|
|
|
2022-10-03 10:25:02 +00:00
|
|
|
condaUnpackHook = callPackage ({ makePythonHook }:
|
|
|
|
makePythonHook {
|
2021-05-16 08:13:39 +00:00
|
|
|
name = "conda-unpack-hook";
|
2023-01-01 20:10:24 +00:00
|
|
|
propagatedBuildInputs = [];
|
2021-05-16 08:13:39 +00:00
|
|
|
} ./conda-unpack-hook.sh) {};
|
|
|
|
|
2022-10-03 10:25:02 +00:00
|
|
|
eggBuildHook = callPackage ({ makePythonHook }:
|
|
|
|
makePythonHook {
|
2020-01-08 13:29:03 +00:00
|
|
|
name = "egg-build-hook.sh";
|
2023-01-01 20:10:24 +00:00
|
|
|
propagatedBuildInputs = [ ];
|
2020-01-08 13:29:03 +00:00
|
|
|
} ./egg-build-hook.sh) {};
|
|
|
|
|
2022-10-03 10:25:02 +00:00
|
|
|
eggInstallHook = callPackage ({ makePythonHook, setuptools }:
|
|
|
|
makePythonHook {
|
2020-01-08 13:29:03 +00:00
|
|
|
name = "egg-install-hook.sh";
|
2023-01-01 20:10:24 +00:00
|
|
|
propagatedBuildInputs = [ setuptools ];
|
2020-01-08 13:29:03 +00:00
|
|
|
substitutions = {
|
|
|
|
inherit pythonInterpreter pythonSitePackages;
|
|
|
|
};
|
|
|
|
} ./egg-install-hook.sh) {};
|
|
|
|
|
2022-10-03 10:25:02 +00:00
|
|
|
eggUnpackHook = callPackage ({ makePythonHook, }:
|
|
|
|
makePythonHook {
|
2020-01-08 13:29:03 +00:00
|
|
|
name = "egg-unpack-hook.sh";
|
2023-01-01 20:10:24 +00:00
|
|
|
propagatedBuildInputs = [ ];
|
2020-01-08 13:29:03 +00:00
|
|
|
} ./egg-unpack-hook.sh) {};
|
|
|
|
|
2022-10-03 10:25:02 +00:00
|
|
|
flitBuildHook = callPackage ({ makePythonHook, flit }:
|
|
|
|
makePythonHook {
|
2019-07-17 18:36:47 +00:00
|
|
|
name = "flit-build-hook";
|
2023-01-01 20:10:24 +00:00
|
|
|
propagatedBuildInputs = [ flit ];
|
2019-07-17 18:36:47 +00:00
|
|
|
substitutions = {
|
|
|
|
inherit pythonInterpreter;
|
|
|
|
};
|
|
|
|
} ./flit-build-hook.sh) {};
|
|
|
|
|
2022-10-03 10:25:02 +00:00
|
|
|
pipBuildHook = callPackage ({ makePythonHook, pip, wheel }:
|
|
|
|
makePythonHook {
|
2019-07-17 18:36:47 +00:00
|
|
|
name = "pip-build-hook.sh";
|
2023-01-01 20:10:24 +00:00
|
|
|
propagatedBuildInputs = [ pip wheel ];
|
2019-07-17 18:36:47 +00:00
|
|
|
substitutions = {
|
|
|
|
inherit pythonInterpreter pythonSitePackages;
|
|
|
|
};
|
|
|
|
} ./pip-build-hook.sh) {};
|
|
|
|
|
2022-10-03 10:25:02 +00:00
|
|
|
pipInstallHook = callPackage ({ makePythonHook, pip }:
|
|
|
|
makePythonHook {
|
2019-07-17 18:36:47 +00:00
|
|
|
name = "pip-install-hook";
|
2023-01-01 20:10:24 +00:00
|
|
|
propagatedBuildInputs = [ pip ];
|
2019-07-17 18:36:47 +00:00
|
|
|
substitutions = {
|
|
|
|
inherit pythonInterpreter pythonSitePackages;
|
|
|
|
};
|
|
|
|
} ./pip-install-hook.sh) {};
|
|
|
|
|
2022-10-03 10:25:02 +00:00
|
|
|
pytestCheckHook = callPackage ({ makePythonHook, pytest }:
|
|
|
|
makePythonHook {
|
2019-07-17 18:36:47 +00:00
|
|
|
name = "pytest-check-hook";
|
2023-01-01 20:10:24 +00:00
|
|
|
propagatedBuildInputs = [ pytest ];
|
2019-07-17 18:36:47 +00:00
|
|
|
substitutions = {
|
|
|
|
inherit pythonCheckInterpreter;
|
|
|
|
};
|
|
|
|
} ./pytest-check-hook.sh) {};
|
|
|
|
|
2022-10-03 10:25:02 +00:00
|
|
|
pythonCatchConflictsHook = callPackage ({ makePythonHook, setuptools }:
|
|
|
|
makePythonHook {
|
2019-07-17 18:36:47 +00:00
|
|
|
name = "python-catch-conflicts-hook";
|
|
|
|
substitutions = {
|
2022-09-20 07:49:27 +00:00
|
|
|
inherit pythonInterpreter pythonSitePackages setuptools;
|
2019-07-17 18:36:47 +00:00
|
|
|
catchConflicts=../catch_conflicts/catch_conflicts.py;
|
|
|
|
};
|
|
|
|
} ./python-catch-conflicts-hook.sh) {};
|
|
|
|
|
2022-10-03 10:25:02 +00:00
|
|
|
pythonImportsCheckHook = callPackage ({ makePythonHook }:
|
|
|
|
makePythonHook {
|
2019-07-17 18:36:47 +00:00
|
|
|
name = "python-imports-check-hook.sh";
|
|
|
|
substitutions = {
|
2022-05-29 03:35:59 +00:00
|
|
|
inherit pythonCheckInterpreter pythonSitePackages;
|
2019-07-17 18:36:47 +00:00
|
|
|
};
|
|
|
|
} ./python-imports-check-hook.sh) {};
|
|
|
|
|
2022-10-03 10:25:02 +00:00
|
|
|
pythonNamespacesHook = callPackage ({ makePythonHook, findutils }:
|
|
|
|
makePythonHook {
|
2020-03-17 21:29:47 +00:00
|
|
|
name = "python-namespaces-hook.sh";
|
|
|
|
substitutions = {
|
2020-11-20 18:51:07 +00:00
|
|
|
inherit pythonSitePackages findutils;
|
2020-03-17 21:29:47 +00:00
|
|
|
};
|
|
|
|
} ./python-namespaces-hook.sh) {};
|
|
|
|
|
2022-10-03 10:25:02 +00:00
|
|
|
pythonOutputDistHook = callPackage ({ makePythonHook }:
|
|
|
|
makePythonHook {
|
2022-09-20 07:49:55 +00:00
|
|
|
name = "python-output-dist-hook";
|
|
|
|
} ./python-output-dist-hook.sh ) {};
|
|
|
|
|
2022-10-03 10:25:02 +00:00
|
|
|
pythonRecompileBytecodeHook = callPackage ({ makePythonHook }:
|
|
|
|
makePythonHook {
|
2020-06-12 19:28:27 +00:00
|
|
|
name = "python-recompile-bytecode-hook";
|
|
|
|
substitutions = {
|
|
|
|
inherit pythonInterpreter pythonSitePackages;
|
|
|
|
compileArgs = lib.concatStringsSep " " (["-q" "-f" "-i -"] ++ lib.optionals isPy3k ["-j $NIX_BUILD_CORES"]);
|
|
|
|
bytecodeName = if isPy3k then "__pycache__" else "*.pyc";
|
|
|
|
};
|
|
|
|
} ./python-recompile-bytecode-hook.sh ) {};
|
|
|
|
|
2022-10-03 10:25:02 +00:00
|
|
|
pythonRelaxDepsHook = callPackage ({ makePythonHook, wheel }:
|
|
|
|
makePythonHook {
|
pythonRelaxDepsHook: init
We have a common pattern here in nixpkgs for Python applications: when a
Python package ships with either a requirements.txt or setup.py file, we
generally end up having to modify its version restriction, otherwise we have
build failures since we package only one specific version of each package
normally.
However, this end up being done in a completely ad-hoc way: some people
use substituteInPlace, some others use sed, others uses patches, etc.
In many cases, the code ends up being buggy, so it may work in one
version and breaks on the next one. We can instead implement one
standard way of doing this, and trying to be a correct as possible.
So this is what this commit does: it implements a new build hook, that
when called will automatically patch the wheel file. This is one of the
most generic ways to patch Python dependencies, and should work in
multiple cases.
2022-04-28 19:58:59 +00:00
|
|
|
name = "python-relax-deps-hook";
|
2023-01-01 20:10:24 +00:00
|
|
|
propagatedBuildInputs = [ wheel ];
|
pythonRelaxDepsHook: init
We have a common pattern here in nixpkgs for Python applications: when a
Python package ships with either a requirements.txt or setup.py file, we
generally end up having to modify its version restriction, otherwise we have
build failures since we package only one specific version of each package
normally.
However, this end up being done in a completely ad-hoc way: some people
use substituteInPlace, some others use sed, others uses patches, etc.
In many cases, the code ends up being buggy, so it may work in one
version and breaks on the next one. We can instead implement one
standard way of doing this, and trying to be a correct as possible.
So this is what this commit does: it implements a new build hook, that
when called will automatically patch the wheel file. This is one of the
most generic ways to patch Python dependencies, and should work in
multiple cases.
2022-04-28 19:58:59 +00:00
|
|
|
substitutions = {
|
|
|
|
inherit pythonInterpreter;
|
|
|
|
};
|
|
|
|
} ./python-relax-deps-hook.sh) {};
|
|
|
|
|
2022-10-03 10:25:02 +00:00
|
|
|
pythonRemoveBinBytecodeHook = callPackage ({ makePythonHook }:
|
|
|
|
makePythonHook {
|
2019-07-17 18:36:47 +00:00
|
|
|
name = "python-remove-bin-bytecode-hook";
|
|
|
|
} ./python-remove-bin-bytecode-hook.sh) {};
|
|
|
|
|
2022-10-03 10:25:02 +00:00
|
|
|
pythonRemoveTestsDirHook = callPackage ({ makePythonHook }:
|
|
|
|
makePythonHook {
|
2020-03-02 17:37:05 +00:00
|
|
|
name = "python-remove-tests-dir-hook";
|
|
|
|
substitutions = {
|
|
|
|
inherit pythonSitePackages;
|
|
|
|
};
|
|
|
|
} ./python-remove-tests-dir-hook.sh) {};
|
|
|
|
|
2022-10-03 10:25:02 +00:00
|
|
|
setuptoolsBuildHook = callPackage ({ makePythonHook, setuptools, wheel }:
|
|
|
|
makePythonHook {
|
2019-07-17 18:36:47 +00:00
|
|
|
name = "setuptools-setup-hook";
|
2023-01-01 20:10:24 +00:00
|
|
|
propagatedBuildInputs = [ setuptools wheel ];
|
2019-07-17 18:36:47 +00:00
|
|
|
substitutions = {
|
|
|
|
inherit pythonInterpreter pythonSitePackages setuppy;
|
|
|
|
};
|
|
|
|
} ./setuptools-build-hook.sh) {};
|
|
|
|
|
2022-10-03 10:25:02 +00:00
|
|
|
setuptoolsCheckHook = callPackage ({ makePythonHook, setuptools }:
|
|
|
|
makePythonHook {
|
2019-07-17 18:36:47 +00:00
|
|
|
name = "setuptools-check-hook";
|
2023-01-01 20:10:24 +00:00
|
|
|
propagatedBuildInputs = [ setuptools ];
|
2019-07-17 18:36:47 +00:00
|
|
|
substitutions = {
|
|
|
|
inherit pythonCheckInterpreter setuppy;
|
|
|
|
};
|
|
|
|
} ./setuptools-check-hook.sh) {};
|
|
|
|
|
2022-10-03 10:25:02 +00:00
|
|
|
unittestCheckHook = callPackage ({ makePythonHook }:
|
|
|
|
makePythonHook {
|
2022-08-06 16:31:53 +00:00
|
|
|
name = "unittest-check-hook";
|
|
|
|
substitutions = {
|
|
|
|
inherit pythonCheckInterpreter;
|
|
|
|
};
|
|
|
|
} ./unittest-check-hook.sh) {};
|
|
|
|
|
2022-10-03 10:25:02 +00:00
|
|
|
venvShellHook = disabledIf (!isPy3k) (callPackage ({ makePythonHook, ensureNewerSourcesForZipFilesHook }:
|
|
|
|
makePythonHook {
|
2020-01-13 20:45:24 +00:00
|
|
|
name = "venv-shell-hook";
|
2023-01-01 20:10:24 +00:00
|
|
|
propagatedBuildInputs = [ ensureNewerSourcesForZipFilesHook ];
|
2020-01-13 20:45:24 +00:00
|
|
|
substitutions = {
|
|
|
|
inherit pythonInterpreter;
|
pythonRelaxDepsHook: init
We have a common pattern here in nixpkgs for Python applications: when a
Python package ships with either a requirements.txt or setup.py file, we
generally end up having to modify its version restriction, otherwise we have
build failures since we package only one specific version of each package
normally.
However, this end up being done in a completely ad-hoc way: some people
use substituteInPlace, some others use sed, others uses patches, etc.
In many cases, the code ends up being buggy, so it may work in one
version and breaks on the next one. We can instead implement one
standard way of doing this, and trying to be a correct as possible.
So this is what this commit does: it implements a new build hook, that
when called will automatically patch the wheel file. This is one of the
most generic ways to patch Python dependencies, and should work in
multiple cases.
2022-04-28 19:58:59 +00:00
|
|
|
};
|
|
|
|
} ./venv-shell-hook.sh) {});
|
2020-01-13 20:45:24 +00:00
|
|
|
|
2022-10-03 10:25:02 +00:00
|
|
|
wheelUnpackHook = callPackage ({ makePythonHook, wheel }:
|
|
|
|
makePythonHook {
|
2019-07-17 18:36:47 +00:00
|
|
|
name = "wheel-unpack-hook.sh";
|
2023-01-01 20:10:24 +00:00
|
|
|
propagatedBuildInputs = [ wheel ];
|
2019-07-17 18:36:47 +00:00
|
|
|
} ./wheel-unpack-hook.sh) {};
|
2021-08-28 15:52:28 +00:00
|
|
|
|
2022-10-03 10:25:02 +00:00
|
|
|
wrapPython = callPackage ../wrap-python.nix {
|
|
|
|
inherit (pkgs.buildPackages) makeWrapper;
|
|
|
|
};
|
|
|
|
|
|
|
|
sphinxHook = callPackage ({ makePythonHook, sphinx, installShellFiles }:
|
|
|
|
makePythonHook {
|
2021-08-28 15:52:28 +00:00
|
|
|
name = "python${python.pythonVersion}-sphinx-hook";
|
2023-01-01 20:10:24 +00:00
|
|
|
propagatedBuildInputs = [ sphinx installShellFiles ];
|
2021-08-28 15:52:28 +00:00
|
|
|
} ./sphinx-hook.sh) {};
|
2019-07-17 18:36:47 +00:00
|
|
|
}
|