nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1# Hooks for building Python packages.
2{ python
3, lib
4, makeSetupHook
5, disabledIf
6, isPy3k
7, ensureNewerSourcesForZipFilesHook
8, findutils
9}:
10
11let
12 callPackage = python.pythonForBuild.pkgs.callPackage;
13 pythonInterpreter = python.pythonForBuild.interpreter;
14 pythonSitePackages = python.sitePackages;
15 pythonCheckInterpreter = python.interpreter;
16 setuppy = ../run_setup.py;
17in rec {
18
19 condaInstallHook = callPackage ({ gnutar, lbzip2 }:
20 makeSetupHook {
21 name = "conda-install-hook";
22 deps = [ gnutar lbzip2 ];
23 substitutions = {
24 inherit pythonSitePackages;
25 };
26 } ./conda-install-hook.sh) {};
27
28 condaUnpackHook = callPackage ({}:
29 makeSetupHook {
30 name = "conda-unpack-hook";
31 deps = [];
32 } ./conda-unpack-hook.sh) {};
33
34 eggBuildHook = callPackage ({ }:
35 makeSetupHook {
36 name = "egg-build-hook.sh";
37 deps = [ ];
38 } ./egg-build-hook.sh) {};
39
40 eggInstallHook = callPackage ({ setuptools }:
41 makeSetupHook {
42 name = "egg-install-hook.sh";
43 deps = [ setuptools ];
44 substitutions = {
45 inherit pythonInterpreter pythonSitePackages;
46 };
47 } ./egg-install-hook.sh) {};
48
49 eggUnpackHook = callPackage ({ }:
50 makeSetupHook {
51 name = "egg-unpack-hook.sh";
52 deps = [ ];
53 } ./egg-unpack-hook.sh) {};
54
55 flitBuildHook = callPackage ({ flit }:
56 makeSetupHook {
57 name = "flit-build-hook";
58 deps = [ flit ];
59 substitutions = {
60 inherit pythonInterpreter;
61 };
62 } ./flit-build-hook.sh) {};
63
64 pipBuildHook = callPackage ({ pip, wheel }:
65 makeSetupHook {
66 name = "pip-build-hook.sh";
67 deps = [ pip wheel ];
68 substitutions = {
69 inherit pythonInterpreter pythonSitePackages;
70 };
71 } ./pip-build-hook.sh) {};
72
73 pipInstallHook = callPackage ({ pip }:
74 makeSetupHook {
75 name = "pip-install-hook";
76 deps = [ pip ];
77 substitutions = {
78 inherit pythonInterpreter pythonSitePackages;
79 };
80 } ./pip-install-hook.sh) {};
81
82 pytestCheckHook = callPackage ({ pytest }:
83 makeSetupHook {
84 name = "pytest-check-hook";
85 deps = [ pytest ];
86 substitutions = {
87 inherit pythonCheckInterpreter;
88 };
89 } ./pytest-check-hook.sh) {};
90
91 pythonCatchConflictsHook = callPackage ({ setuptools }:
92 makeSetupHook {
93 name = "python-catch-conflicts-hook";
94 deps = [ setuptools ];
95 substitutions = {
96 inherit pythonInterpreter;
97 catchConflicts=../catch_conflicts/catch_conflicts.py;
98 };
99 } ./python-catch-conflicts-hook.sh) {};
100
101 pythonImportsCheckHook = callPackage ({}:
102 makeSetupHook {
103 name = "python-imports-check-hook.sh";
104 substitutions = {
105 inherit pythonCheckInterpreter;
106 };
107 } ./python-imports-check-hook.sh) {};
108
109 pythonNamespacesHook = callPackage ({}:
110 makeSetupHook {
111 name = "python-namespaces-hook.sh";
112 substitutions = {
113 inherit pythonSitePackages findutils;
114 };
115 } ./python-namespaces-hook.sh) {};
116
117 pythonRecompileBytecodeHook = callPackage ({ }:
118 makeSetupHook {
119 name = "python-recompile-bytecode-hook";
120 substitutions = {
121 inherit pythonInterpreter pythonSitePackages;
122 compileArgs = lib.concatStringsSep " " (["-q" "-f" "-i -"] ++ lib.optionals isPy3k ["-j $NIX_BUILD_CORES"]);
123 bytecodeName = if isPy3k then "__pycache__" else "*.pyc";
124 };
125 } ./python-recompile-bytecode-hook.sh ) {};
126
127 pythonRelaxDepsHook = callPackage ({ wheel }:
128 makeSetupHook {
129 name = "python-relax-deps-hook";
130 deps = [ wheel ];
131 substitutions = {
132 inherit pythonInterpreter;
133 };
134 } ./python-relax-deps-hook.sh) {};
135
136 pythonRemoveBinBytecodeHook = callPackage ({ }:
137 makeSetupHook {
138 name = "python-remove-bin-bytecode-hook";
139 } ./python-remove-bin-bytecode-hook.sh) {};
140
141 pythonRemoveTestsDirHook = callPackage ({ }:
142 makeSetupHook {
143 name = "python-remove-tests-dir-hook";
144 substitutions = {
145 inherit pythonSitePackages;
146 };
147 } ./python-remove-tests-dir-hook.sh) {};
148
149 setuptoolsBuildHook = callPackage ({ setuptools, wheel }:
150 makeSetupHook {
151 name = "setuptools-setup-hook";
152 deps = [ setuptools wheel ];
153 substitutions = {
154 inherit pythonInterpreter pythonSitePackages setuppy;
155 };
156 } ./setuptools-build-hook.sh) {};
157
158 setuptoolsCheckHook = callPackage ({ setuptools }:
159 makeSetupHook {
160 name = "setuptools-check-hook";
161 deps = [ setuptools ];
162 substitutions = {
163 inherit pythonCheckInterpreter setuppy;
164 };
165 } ./setuptools-check-hook.sh) {};
166
167 venvShellHook = disabledIf (!isPy3k) (callPackage ({ }:
168 makeSetupHook {
169 name = "venv-shell-hook";
170 deps = [ ensureNewerSourcesForZipFilesHook ];
171 substitutions = {
172 inherit pythonInterpreter;
173 };
174 } ./venv-shell-hook.sh) {});
175
176 wheelUnpackHook = callPackage ({ wheel }:
177 makeSetupHook {
178 name = "wheel-unpack-hook.sh";
179 deps = [ wheel ];
180 } ./wheel-unpack-hook.sh) {};
181
182 sphinxHook = callPackage ({ sphinx }:
183 makeSetupHook {
184 name = "python${python.pythonVersion}-sphinx-hook";
185 deps = [ sphinx ];
186 } ./sphinx-hook.sh) {};
187}