Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at domenkozar-patch-1 324 lines 9.9 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 isPy37 = pythonVersion == "3.7"; 88 isPy38 = pythonVersion == "3.8"; 89 isPy39 = pythonVersion == "3.9"; 90 isPy310 = pythonVersion == "3.10"; 91 isPy311 = pythonVersion == "3.11"; 92 isPy312 = pythonVersion == "3.12"; 93 isPy2 = lib.strings.substring 0 1 pythonVersion == "2"; 94 isPy3 = lib.strings.substring 0 1 pythonVersion == "3"; 95 isPy3k = isPy3; 96 isPyPy = lib.hasInfix "pypy" interpreter; 97 98 buildEnv = callPackage ./wrapper.nix { python = self; inherit (pythonPackages) requiredPythonModules; }; 99 withPackages = import ./with-packages.nix { inherit buildEnv pythonPackages;}; 100 pkgs = pythonPackages; 101 interpreter = "${self}/bin/${executable}"; 102 inherit executable implementation libPrefix pythonVersion sitePackages; 103 inherit sourceVersion; 104 pythonAtLeast = lib.versionAtLeast pythonVersion; 105 pythonOlder = lib.versionOlder pythonVersion; 106 inherit hasDistutilsCxxPatch; 107 # TODO: rename to pythonOnBuild 108 # Not done immediately because its likely used outside Nixpkgs. 109 pythonForBuild = pythonOnBuildForHost.override { inherit packageOverrides; self = pythonForBuild; }; 110 111 tests = callPackage ./tests.nix { 112 python = self; 113 }; 114 115 inherit pythonAttr; 116 }; 117 118 sources = { 119 python39 = { 120 sourceVersion = { 121 major = "3"; 122 minor = "9"; 123 patch = "16"; 124 suffix = ""; 125 }; 126 sha256 = "sha256-It3cCZJG3SdgZlVh6K23OU6gzEOnJoTGSA+TgPd4ZDk="; 127 }; 128 python310 = { 129 sourceVersion = { 130 major = "3"; 131 minor = "10"; 132 patch = "9"; 133 suffix = ""; 134 }; 135 sha256 = "sha256-WuA+MIJgFkuro5kh/bTb+ObQPYI1qTnUWCsz8LXkaoM="; 136 }; 137 }; 138 139in { 140 141 python27 = callPackage ./cpython/2.7 { 142 self = __splicedPackages.python27; 143 sourceVersion = { 144 major = "2"; 145 minor = "7"; 146 patch = "18"; 147 suffix = ".5"; # ActiveState's Python 2 extended support 148 }; 149 sha256 = "sha256-f5A0go0mUEv8cXuXo0ZRNfGwNPjnDhP7KqhkETOoqsw="; 150 inherit (darwin) configd; 151 inherit passthruFun; 152 }; 153 154 python37 = callPackage ./cpython { 155 self = __splicedPackages.python37; 156 sourceVersion = { 157 major = "3"; 158 minor = "7"; 159 patch = "16"; 160 suffix = ""; 161 }; 162 sha256 = "sha256-gzjwwiIthH6QTJVTaRVdwb7u7YBujV7wSwDvR4cji/0="; 163 inherit (darwin) configd; 164 inherit passthruFun; 165 }; 166 167 python38 = callPackage ./cpython { 168 self = __splicedPackages.python38; 169 sourceVersion = { 170 major = "3"; 171 minor = "8"; 172 patch = "16"; 173 suffix = ""; 174 }; 175 sha256 = "sha256-2F27N3QTJHPYCB3LFY80oQzK16kLlsflDqS7YfXORWI="; 176 inherit (darwin) configd; 177 inherit passthruFun; 178 }; 179 180 python39 = callPackage ./cpython ({ 181 self = __splicedPackages.python39; 182 inherit (darwin) configd; 183 inherit passthruFun; 184 } // sources.python39); 185 186 python310 = callPackage ./cpython ({ 187 self = __splicedPackages.python310; 188 inherit (darwin) configd; 189 inherit passthruFun; 190 } // sources.python310); 191 192 python311 = callPackage ./cpython { 193 self = __splicedPackages.python311; 194 sourceVersion = { 195 major = "3"; 196 minor = "11"; 197 patch = "1"; 198 suffix = ""; 199 }; 200 sha256 = "sha256-hYeRkvLP/VbLFsCSkFlJ6/Pl45S392RyNSljeQHftY8="; 201 inherit (darwin) configd; 202 inherit passthruFun; 203 }; 204 205 python312 = callPackage ./cpython { 206 self = __splicedPackages.python312; 207 sourceVersion = { 208 major = "3"; 209 minor = "12"; 210 patch = "0"; 211 suffix = "a3"; 212 }; 213 sha256 = "sha256-G2SzB14KkkGXTlgOCbCckRehxOK+aYA5IB7x2Kc0U9E="; 214 inherit (darwin) configd; 215 inherit passthruFun; 216 }; 217 218 # Minimal versions of Python (built without optional dependencies) 219 python3Minimal = (callPackage ./cpython ({ 220 self = __splicedPackages.python3Minimal; 221 inherit passthruFun; 222 pythonAttr = "python3Minimal"; 223 # strip down that python version as much as possible 224 openssl = null; 225 readline = null; 226 ncurses = null; 227 gdbm = null; 228 sqlite = null; 229 configd = null; 230 tzdata = null; 231 libffi = libffiBoot; # without test suite 232 stripConfig = true; 233 stripIdlelib = true; 234 stripTests = true; 235 stripTkinter = true; 236 rebuildBytecode = false; 237 stripBytecode = true; 238 includeSiteCustomize = false; 239 enableOptimizations = false; 240 enableLTO = false; 241 mimetypesSupport = false; 242 } // sources.python310)).overrideAttrs(old: { 243 # TODO(@Artturin): Add this to the main cpython expr 244 strictDeps = true; 245 pname = "python3-minimal"; 246 }); 247 248 pypy27 = callPackage ./pypy { 249 self = __splicedPackages.pypy27; 250 sourceVersion = { 251 major = "7"; 252 minor = "3"; 253 patch = "9"; 254 }; 255 256 sha256 = "sha256-ObCXKVb2VIzlgoAZ264SUDwy1svpGivs+I0+QsxSGXs="; 257 pythonVersion = "2.7"; 258 db = db.override { dbmSupport = !stdenv.isDarwin; }; 259 python = __splicedPackages.python27; 260 inherit passthruFun; 261 inherit (darwin) libunwind; 262 inherit (darwin.apple_sdk.frameworks) Security; 263 }; 264 265 pypy39 = callPackage ./pypy { 266 self = __splicedPackages.pypy39; 267 sourceVersion = { 268 major = "7"; 269 minor = "3"; 270 patch = "9"; 271 }; 272 273 sha256 = "sha256-Krqh6f4ewOIzyfvDd6DI6aBjQICo9PMOtomDAfZhjBI="; 274 pythonVersion = "3.9"; 275 db = db.override { dbmSupport = !stdenv.isDarwin; }; 276 python = __splicedPackages.python27; 277 inherit passthruFun; 278 inherit (darwin) libunwind; 279 inherit (darwin.apple_sdk.frameworks) Security; 280 }; 281 282 pypy38 = __splicedPackages.pypy39.override { 283 self = __splicedPackages.pythonInterpreters.pypy38; 284 pythonVersion = "3.8"; 285 sha256 = "sha256-W12dklbxKhKa+DhOL1gb36s7wPu+OgpIDZwdLpVJDrE="; 286 }; 287 pypy37 = __splicedPackages.pypy39.override { 288 self = __splicedPackages.pythonInterpreters.pypy37; 289 pythonVersion = "3.7"; 290 sha256 = "sha256-cEJhY7GU7kYAmYbuptlCYJij/7VS2c29PfqmSkc3P0k="; 291 }; 292 293 pypy27_prebuilt = callPackage ./pypy/prebuilt_2_7.nix { 294 # Not included at top-level 295 self = __splicedPackages.pythonInterpreters.pypy27_prebuilt; 296 sourceVersion = { 297 major = "7"; 298 minor = "3"; 299 patch = "9"; 300 }; 301 302 sha256 = "sha256-FyqSiwCWp+ALfVj1I/VzAMNcPef4IkkeKnvIRTdcI/g="; # linux64 303 pythonVersion = "2.7"; 304 inherit passthruFun; 305 }; 306 307 pypy39_prebuilt = callPackage ./pypy/prebuilt.nix { 308 # Not included at top-level 309 self = __splicedPackages.pythonInterpreters.pypy38_prebuilt; 310 sourceVersion = { 311 major = "7"; 312 minor = "3"; 313 patch = "9"; 314 }; 315 sha256 = "sha256-RoGMs9dLlrNHh1SDQ9Jm4lYrUx3brzMDg7qTD/GTDtU="; # linux64 316 pythonVersion = "3.9"; 317 inherit passthruFun; 318 }; 319 320 rustpython = callPackage ./rustpython/default.nix { 321 inherit (darwin.apple_sdk.frameworks) SystemConfiguration; 322 }; 323 324})