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 pythonRemoveBinBytecodeHook = callPackage ({ }:
128 makeSetupHook {
129 name = "python-remove-bin-bytecode-hook";
130 } ./python-remove-bin-bytecode-hook.sh) {};
131
132 pythonRemoveTestsDirHook = callPackage ({ }:
133 makeSetupHook {
134 name = "python-remove-tests-dir-hook";
135 substitutions = {
136 inherit pythonSitePackages;
137 };
138 } ./python-remove-tests-dir-hook.sh) {};
139
140 setuptoolsBuildHook = callPackage ({ setuptools, wheel }:
141 makeSetupHook {
142 name = "setuptools-setup-hook";
143 deps = [ setuptools wheel ];
144 substitutions = {
145 inherit pythonInterpreter pythonSitePackages setuppy;
146 };
147 } ./setuptools-build-hook.sh) {};
148
149 setuptoolsCheckHook = callPackage ({ setuptools }:
150 makeSetupHook {
151 name = "setuptools-check-hook";
152 deps = [ setuptools ];
153 substitutions = {
154 inherit pythonCheckInterpreter setuppy;
155 };
156 } ./setuptools-check-hook.sh) {};
157
158 venvShellHook = disabledIf (!isPy3k) (callPackage ({ }:
159 makeSetupHook {
160 name = "venv-shell-hook";
161 deps = [ ensureNewerSourcesForZipFilesHook ];
162 substitutions = {
163 inherit pythonInterpreter;
164 };
165 } ./venv-shell-hook.sh) {});
166
167 wheelUnpackHook = callPackage ({ wheel }:
168 makeSetupHook {
169 name = "wheel-unpack-hook.sh";
170 deps = [ wheel ];
171 } ./wheel-unpack-hook.sh) {};
172}