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