at 23.05-pre 9.6 kB view raw
1{ __splicedPackages 2, callPackage 3, config 4, darwin 5, db 6, lib 7, libffiBoot 8, newScope 9, pythonPackagesExtensions 10, splicePackages 11, stdenv 12}: 13 14(let 15 16 # Common passthru for all Python interpreters. 17 passthruFun = 18 { implementation 19 , libPrefix 20 , executable 21 , sourceVersion 22 , pythonVersion 23 , packageOverrides 24 , sitePackages 25 , hasDistutilsCxxPatch 26 , pythonOnBuildForBuild 27 , pythonOnBuildForHost 28 , pythonOnBuildForTarget 29 , pythonOnHostForHost 30 , pythonOnTargetForTarget 31 , pythonAttr ? null 32 , self # is pythonOnHostForTarget 33 }: let 34 pythonPackages = let 35 ensurePythonModules = items: let 36 exceptions = [ 37 stdenv 38 ]; 39 providesSetupHook = lib.attrByPath [ "provides" "setupHook"] false; 40 valid = value: !((lib.isDerivation value) && !((pythonPackages.hasPythonModule value) || (providesSetupHook value))) || (lib.elem value exceptions); 41 func = name: value: if (valid value) then value else throw "${name} should use `buildPythonPackage` or `toPythonModule` if it is to be part of the Python packages set."; 42 in lib.mapAttrs func items; 43 in ensurePythonModules (callPackage 44 # Function that when called 45 # - imports python-packages.nix 46 # - adds spliced package sets to the package set 47 # - applies overrides from `packageOverrides` and `pythonPackagesOverlays`. 48 ({ pkgs, stdenv, python, overrides }: let 49 pythonPackagesFun = import ./python-packages-base.nix { 50 inherit stdenv pkgs lib; 51 python = self; 52 }; 53 otherSplices = { 54 selfBuildBuild = pythonOnBuildForBuild.pkgs; 55 selfBuildHost = pythonOnBuildForHost.pkgs; 56 selfBuildTarget = pythonOnBuildForTarget.pkgs; 57 selfHostHost = pythonOnHostForHost.pkgs; 58 selfTargetTarget = pythonOnTargetForTarget.pkgs or {}; # There is no Python TargetTarget. 59 }; 60 hooks = import ./hooks/default.nix; 61 keep = lib.extends hooks pythonPackagesFun; 62 extra = _: {}; 63 optionalExtensions = cond: as: if cond then as else []; 64 pythonExtension = import ../../../top-level/python-packages.nix; 65 python2Extension = import ../../../top-level/python2-packages.nix; 66 extensions = lib.composeManyExtensions ([ 67 pythonExtension 68 ] ++ (optionalExtensions (!self.isPy3k) [ 69 python2Extension 70 ]) ++ pythonPackagesExtensions ++ [ 71 overrides 72 ]); 73 aliases = self: super: lib.optionalAttrs config.allowAliases (import ../../../top-level/python-aliases.nix lib self super); 74 in lib.makeScopeWithSplicing 75 splicePackages 76 newScope 77 otherSplices 78 keep 79 extra 80 (lib.extends (lib.composeExtensions aliases extensions) keep)) 81 { 82 overrides = packageOverrides; 83 python = self; 84 }); 85 in rec { 86 isPy27 = pythonVersion == "2.7"; 87 isPy35 = pythonVersion == "3.5"; 88 isPy36 = pythonVersion == "3.6"; 89 isPy37 = pythonVersion == "3.7"; 90 isPy38 = pythonVersion == "3.8"; 91 isPy39 = pythonVersion == "3.9"; 92 isPy310 = pythonVersion == "3.10"; 93 isPy311 = pythonVersion == "3.11"; 94 isPy2 = lib.strings.substring 0 1 pythonVersion == "2"; 95 isPy3 = lib.strings.substring 0 1 pythonVersion == "3"; 96 isPy3k = isPy3; 97 isPyPy = lib.hasInfix "pypy" interpreter; 98 99 buildEnv = callPackage ./wrapper.nix { python = self; inherit (pythonPackages) requiredPythonModules; }; 100 withPackages = import ./with-packages.nix { inherit buildEnv pythonPackages;}; 101 pkgs = pythonPackages; 102 interpreter = "${self}/bin/${executable}"; 103 inherit executable implementation libPrefix pythonVersion sitePackages; 104 inherit sourceVersion; 105 pythonAtLeast = lib.versionAtLeast pythonVersion; 106 pythonOlder = lib.versionOlder pythonVersion; 107 inherit hasDistutilsCxxPatch; 108 # TODO: rename to pythonOnBuild 109 # Not done immediately because its likely used outside Nixpkgs. 110 pythonForBuild = pythonOnBuildForHost.override { inherit packageOverrides; self = pythonForBuild; }; 111 112 tests = callPackage ./tests.nix { 113 python = self; 114 }; 115 116 inherit pythonAttr; 117 }; 118 119 sources = { 120 python39 = { 121 sourceVersion = { 122 major = "3"; 123 minor = "9"; 124 patch = "15"; 125 suffix = ""; 126 }; 127 sha256 = "sha256-Etr/aAlSjZ9hVCFpUEI8njDw5HM2y1fGqgtDh91etLI="; 128 }; 129 python310 = { 130 sourceVersion = { 131 major = "3"; 132 minor = "10"; 133 patch = "8"; 134 suffix = ""; 135 }; 136 sha256 = "sha256-ajDs3lnEcEgBPrWmWMm13sJ3ID0nk2Z/V433Zx9/A/M="; 137 }; 138 }; 139 140in { 141 142 python27 = callPackage ./cpython/2.7 { 143 self = __splicedPackages.python27; 144 sourceVersion = { 145 major = "2"; 146 minor = "7"; 147 patch = "18"; 148 suffix = ""; 149 }; 150 sha256 = "0hzgxl94hnflis0d6m4szjx0b52gah7wpmcg5g00q7am6xwhwb5n"; 151 inherit (darwin) configd; 152 inherit passthruFun; 153 }; 154 155 python37 = callPackage ./cpython { 156 self = __splicedPackages.python37; 157 sourceVersion = { 158 major = "3"; 159 minor = "7"; 160 patch = "15"; 161 suffix = ""; 162 }; 163 sha256 = "sha256-WRFHWgesK1PXRuiKBxavbStHNJQZGRNuoNM/ucdblxQ="; 164 inherit (darwin) configd; 165 inherit passthruFun; 166 }; 167 168 python38 = callPackage ./cpython { 169 self = __splicedPackages.python38; 170 sourceVersion = { 171 major = "3"; 172 minor = "8"; 173 patch = "15"; 174 suffix = ""; 175 }; 176 sha256 = "sha256-URT8eRiipeIOtarGlrMMNvQSxu8ksT9cnrngVpgtlVA="; 177 inherit (darwin) configd; 178 inherit passthruFun; 179 }; 180 181 python39 = callPackage ./cpython ({ 182 self = __splicedPackages.python39; 183 inherit (darwin) configd; 184 inherit passthruFun; 185 } // sources.python39); 186 187 python310 = callPackage ./cpython ({ 188 self = __splicedPackages.python310; 189 inherit (darwin) configd; 190 inherit passthruFun; 191 } // sources.python310); 192 193 python311 = callPackage ./cpython { 194 self = __splicedPackages.python311; 195 sourceVersion = { 196 major = "3"; 197 minor = "11"; 198 patch = "0"; 199 suffix = ""; 200 }; 201 sha256 = "sha256-pX3ILXc1hhe6ZbmEHO4eO0QfOGw3id3AZ27KB38pUcM="; 202 inherit (darwin) configd; 203 inherit passthruFun; 204 }; 205 206 # Minimal versions of Python (built without optional dependencies) 207 python3Minimal = (callPackage ./cpython ({ 208 self = __splicedPackages.python3Minimal; 209 inherit passthruFun; 210 pythonAttr = "python3Minimal"; 211 # strip down that python version as much as possible 212 openssl = null; 213 readline = null; 214 ncurses = null; 215 gdbm = null; 216 sqlite = null; 217 configd = null; 218 tzdata = null; 219 libffi = libffiBoot; # without test suite 220 stripConfig = true; 221 stripIdlelib = true; 222 stripTests = true; 223 stripTkinter = true; 224 rebuildBytecode = false; 225 stripBytecode = true; 226 includeSiteCustomize = false; 227 enableOptimizations = false; 228 enableLTO = false; 229 mimetypesSupport = false; 230 } // sources.python310)).overrideAttrs(old: { 231 # TODO(@Artturin): Add this to the main cpython expr 232 strictDeps = true; 233 pname = "python3-minimal"; 234 }); 235 236 pypy27 = callPackage ./pypy { 237 self = __splicedPackages.pypy27; 238 sourceVersion = { 239 major = "7"; 240 minor = "3"; 241 patch = "9"; 242 }; 243 244 sha256 = "sha256-ObCXKVb2VIzlgoAZ264SUDwy1svpGivs+I0+QsxSGXs="; 245 pythonVersion = "2.7"; 246 db = db.override { dbmSupport = !stdenv.isDarwin; }; 247 python = __splicedPackages.python27; 248 inherit passthruFun; 249 inherit (darwin) libunwind; 250 inherit (darwin.apple_sdk.frameworks) Security; 251 }; 252 253 pypy39 = callPackage ./pypy { 254 self = __splicedPackages.pypy39; 255 sourceVersion = { 256 major = "7"; 257 minor = "3"; 258 patch = "9"; 259 }; 260 261 sha256 = "sha256-Krqh6f4ewOIzyfvDd6DI6aBjQICo9PMOtomDAfZhjBI="; 262 pythonVersion = "3.9"; 263 db = db.override { dbmSupport = !stdenv.isDarwin; }; 264 python = __splicedPackages.python27; 265 inherit passthruFun; 266 inherit (darwin) libunwind; 267 inherit (darwin.apple_sdk.frameworks) Security; 268 }; 269 270 pypy38 = __splicedPackages.pypy39.override { 271 self = __splicedPackages.pythonInterpreters.pypy38; 272 pythonVersion = "3.8"; 273 sha256 = "sha256-W12dklbxKhKa+DhOL1gb36s7wPu+OgpIDZwdLpVJDrE="; 274 }; 275 pypy37 = __splicedPackages.pypy39.override { 276 self = __splicedPackages.pythonInterpreters.pypy37; 277 pythonVersion = "3.7"; 278 sha256 = "sha256-cEJhY7GU7kYAmYbuptlCYJij/7VS2c29PfqmSkc3P0k="; 279 }; 280 281 pypy27_prebuilt = callPackage ./pypy/prebuilt_2_7.nix { 282 # Not included at top-level 283 self = __splicedPackages.pythonInterpreters.pypy27_prebuilt; 284 sourceVersion = { 285 major = "7"; 286 minor = "3"; 287 patch = "9"; 288 }; 289 290 sha256 = "sha256-FyqSiwCWp+ALfVj1I/VzAMNcPef4IkkeKnvIRTdcI/g="; # linux64 291 pythonVersion = "2.7"; 292 inherit passthruFun; 293 }; 294 295 pypy39_prebuilt = callPackage ./pypy/prebuilt.nix { 296 # Not included at top-level 297 self = __splicedPackages.pythonInterpreters.pypy38_prebuilt; 298 sourceVersion = { 299 major = "7"; 300 minor = "3"; 301 patch = "9"; 302 }; 303 sha256 = "sha256-RoGMs9dLlrNHh1SDQ9Jm4lYrUx3brzMDg7qTD/GTDtU="; # linux64 304 pythonVersion = "3.9"; 305 inherit passthruFun; 306 }; 307 308 rustpython = callPackage ./rustpython/default.nix { 309 inherit (darwin.apple_sdk.frameworks) SystemConfiguration; 310 }; 311 312})