at 22.05-pre 8.5 kB view raw
1{ pkgs }: 2 3with pkgs; 4 5(let 6 7 # Common passthru for all Python interpreters. 8 passthruFun = 9 { implementation 10 , libPrefix 11 , executable 12 , sourceVersion 13 , pythonVersion 14 , packageOverrides 15 , sitePackages 16 , hasDistutilsCxxPatch 17 , pythonOnBuildForBuild 18 , pythonOnBuildForHost 19 , pythonOnBuildForTarget 20 , pythonOnHostForHost 21 , pythonOnTargetForTarget 22 , self # is pythonOnHostForTarget 23 }: let 24 pythonPackages = callPackage 25 ({ pkgs, stdenv, python, overrides }: let 26 pythonPackagesFun = import ../../../top-level/python-packages.nix { 27 inherit stdenv pkgs lib; 28 python = self; 29 }; 30 otherSplices = { 31 selfBuildBuild = pythonOnBuildForBuild.pkgs; 32 selfBuildHost = pythonOnBuildForHost.pkgs; 33 selfBuildTarget = pythonOnBuildForTarget.pkgs; 34 selfHostHost = pythonOnHostForHost.pkgs; 35 selfTargetTarget = pythonOnTargetForTarget.pkgs or {}; # There is no Python TargetTarget. 36 }; 37 keep = self: { 38 # TODO maybe only define these here so nothing is needed to be kept in sync. 39 inherit (self) 40 isPy27 isPy35 isPy36 isPy37 isPy38 isPy39 isPy310 isPy3k isPyPy pythonAtLeast pythonOlder 41 python bootstrapped-pip buildPythonPackage buildPythonApplication 42 fetchPypi 43 hasPythonModule requiredPythonModules makePythonPath disabledIf 44 toPythonModule toPythonApplication 45 buildSetupcfg 46 47 condaInstallHook 48 condaUnpackHook 49 eggUnpackHook 50 eggBuildHook 51 eggInstallHook 52 flitBuildHook 53 pipBuildHook 54 pipInstallHook 55 pytestCheckHook 56 pythonCatchConflictsHook 57 pythonImportsCheckHook 58 pythonNamespacesHook 59 pythonRecompileBytecodeHook 60 pythonRemoveBinBytecodeHook 61 pythonRemoveTestsDirHook 62 setuptoolsBuildHook 63 setuptoolsCheckHook 64 venvShellHook 65 wheelUnpackHook 66 67 wrapPython 68 69 pythonPackages 70 71 recursivePthLoader 72 ; 73 }; 74 extra = _: {}; 75 optionalExtensions = cond: as: if cond then as else []; 76 python2Extension = import ../../../top-level/python2-packages.nix; 77 extensions = lib.composeManyExtensions ((optionalExtensions (!self.isPy3k) [python2Extension]) ++ [ overrides ]); 78 aliases = self: super: lib.optionalAttrs (config.allowAliases or true) (import ../../../top-level/python-aliases.nix lib self super); 79 in lib.makeScopeWithSplicing 80 pkgs.splicePackages 81 pkgs.newScope 82 otherSplices 83 keep 84 extra 85 (lib.extends (lib.composeExtensions aliases extensions) pythonPackagesFun)) 86 { 87 overrides = packageOverrides; 88 python = self; 89 }; 90 in rec { 91 isPy27 = pythonVersion == "2.7"; 92 isPy35 = pythonVersion == "3.5"; 93 isPy36 = pythonVersion == "3.6"; 94 isPy37 = pythonVersion == "3.7"; 95 isPy38 = pythonVersion == "3.8"; 96 isPy39 = pythonVersion == "3.9"; 97 isPy310 = pythonVersion == "3.10"; 98 isPy2 = lib.strings.substring 0 1 pythonVersion == "2"; 99 isPy3 = lib.strings.substring 0 1 pythonVersion == "3"; 100 isPy3k = isPy3; 101 isPyPy = lib.hasInfix "pypy" interpreter; 102 103 buildEnv = callPackage ./wrapper.nix { python = self; inherit (pythonPackages) requiredPythonModules; }; 104 withPackages = import ./with-packages.nix { inherit buildEnv pythonPackages;}; 105 pkgs = pythonPackages; 106 interpreter = "${self}/bin/${executable}"; 107 inherit executable implementation libPrefix pythonVersion sitePackages; 108 inherit sourceVersion; 109 pythonAtLeast = lib.versionAtLeast pythonVersion; 110 pythonOlder = lib.versionOlder pythonVersion; 111 inherit hasDistutilsCxxPatch; 112 # TODO: rename to pythonOnBuild 113 # Not done immediately because its likely used outside Nixpkgs. 114 pythonForBuild = pythonOnBuildForHost.override { inherit packageOverrides; self = pythonForBuild; }; 115 116 tests = callPackage ./tests.nix { 117 python = self; 118 }; 119 }; 120 121 sources = { 122 python38 = { 123 sourceVersion = { 124 major = "3"; 125 minor = "8"; 126 patch = "12"; 127 suffix = ""; 128 }; 129 sha256 = "1si8hw2xpagh4iji89zdx69p3dv5mjqwwbx2x2sl6lrp41jaglxi"; 130 }; 131 python39 = { 132 sourceVersion = { 133 major = "3"; 134 minor = "9"; 135 patch = "6"; 136 suffix = ""; 137 }; 138 sha256 = "12hhw2685i68pwfx5hdkqngzhbji4ccyjmqb5rzvkigg6fpj0y9r"; 139 }; 140 }; 141 142in { 143 144 python27 = callPackage ./cpython/2.7 { 145 self = python27; 146 sourceVersion = { 147 major = "2"; 148 minor = "7"; 149 patch = "18"; 150 suffix = ""; 151 }; 152 sha256 = "0hzgxl94hnflis0d6m4szjx0b52gah7wpmcg5g00q7am6xwhwb5n"; 153 inherit (darwin) configd; 154 inherit passthruFun; 155 }; 156 157 python37 = callPackage ./cpython { 158 self = python37; 159 sourceVersion = { 160 major = "3"; 161 minor = "7"; 162 patch = "12"; 163 suffix = ""; 164 }; 165 sha256 = "041jqjl5wf7gsw84zd3jgvg91skq20l2fy5zbhz237w38zxzfyzp"; 166 inherit (darwin) configd; 167 inherit passthruFun; 168 }; 169 170 python38 = callPackage ./cpython ({ 171 self = python38; 172 inherit (darwin) configd; 173 inherit passthruFun; 174 } // sources.python38); 175 176 python39 = callPackage ./cpython ({ 177 self = python39; 178 inherit (darwin) configd; 179 inherit passthruFun; 180 } // sources.python39); 181 182 python310 = callPackage ./cpython { 183 self = python310; 184 sourceVersion = { 185 major = "3"; 186 minor = "10"; 187 patch = "0"; 188 suffix = ""; 189 }; 190 sha256 = "00mhn6kj4qkvkkv6hh2klnnjr0yk0c9hspp7njc7n6m1lvkzi6as"; 191 inherit (darwin) configd; 192 inherit passthruFun; 193 }; 194 195 # Minimal versions of Python (built without optional dependencies) 196 python3Minimal = (callPackage ./cpython ({ 197 self = python3Minimal; 198 inherit passthruFun; 199 pythonAttr = "python3Minimal"; 200 # strip down that python version as much as possible 201 openssl = null; 202 readline = null; 203 ncurses = null; 204 gdbm = null; 205 sqlite = null; 206 configd = null; 207 tzdata = null; 208 stripConfig = true; 209 stripIdlelib = true; 210 stripTests = true; 211 stripTkinter = true; 212 rebuildBytecode = false; 213 stripBytecode = true; 214 includeSiteCustomize = false; 215 enableOptimizations = false; 216 enableLTO = false; 217 mimetypesSupport = false; 218 } // sources.python39)).overrideAttrs(old: { 219 pname = "python3-minimal"; 220 meta = old.meta // { 221 maintainers = []; 222 }; 223 }); 224 225 pypy27 = callPackage ./pypy { 226 self = pypy27; 227 sourceVersion = { 228 major = "7"; 229 minor = "3"; 230 patch = "5"; 231 }; 232 sha256 = "sha256-wERP2YcwWMHA2Z4TqTTpIoXLBZksmWi/Ujwyv5vsCp0="; 233 pythonVersion = "2.7"; 234 db = db.override { dbmSupport = !stdenv.isDarwin; }; 235 python = python27; 236 inherit passthruFun; 237 inherit (darwin) libunwind; 238 inherit (darwin.apple_sdk.frameworks) Security; 239 }; 240 241 pypy37 = callPackage ./pypy { 242 self = pypy37; 243 sourceVersion = { 244 major = "7"; 245 minor = "3"; 246 patch = "5"; 247 }; 248 sha256 = "sha256-2SD+QJqeytnQdKqFaMpfPtNYG+ZvZuXYmIt+xm5tmaI="; 249 pythonVersion = "3.7"; 250 db = db.override { dbmSupport = !stdenv.isDarwin; }; 251 python = python27; 252 inherit passthruFun; 253 inherit (darwin) libunwind; 254 inherit (darwin.apple_sdk.frameworks) Security; 255 }; 256 257 pypy27_prebuilt = callPackage ./pypy/prebuilt.nix { 258 # Not included at top-level 259 self = pythonInterpreters.pypy27_prebuilt; 260 sourceVersion = { 261 major = "7"; 262 minor = "3"; 263 patch = "3"; 264 }; 265 sha256 = "1cfpdyvbvzwc0ynjr7248jhwgcpl7073wlp7w3g2v4fnrh1bc4pl"; # linux64 266 pythonVersion = "2.7"; 267 inherit passthruFun; 268 }; 269 270 pypy36_prebuilt = callPackage ./pypy/prebuilt.nix { 271 # Not included at top-level 272 self = pythonInterpreters.pypy36_prebuilt; 273 sourceVersion = { 274 major = "7"; 275 minor = "3"; 276 patch = "3"; 277 }; 278 sha256 = "02lys9bjky9bqg6ggv8djirbd3zzcsq7755v4yvwm0k4a7fmzf2g"; # linux64 279 pythonVersion = "3.6"; 280 inherit passthruFun; 281 }; 282 283 graalpython37 = callPackage ./graalpython/default.nix { 284 self = pythonInterpreters.graalpython37; 285 inherit passthruFun; 286 }; 287 288})