about summary refs log tree commit diff
path: root/pkgs/development/interpreters/python
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/interpreters/python')
-rw-r--r--pkgs/development/interpreters/python/cpython/3.12/0001-Fix-build-with-_PY_SHORT_FLOAT_REPR-0.patch53
-rw-r--r--pkgs/development/interpreters/python/cpython/default.nix19
-rw-r--r--pkgs/development/interpreters/python/cpython/docs/2.7-html.nix2
-rw-r--r--pkgs/development/interpreters/python/cpython/docs/2.7-pdf-a4.nix2
-rw-r--r--pkgs/development/interpreters/python/cpython/docs/2.7-pdf-letter.nix2
-rw-r--r--pkgs/development/interpreters/python/cpython/docs/2.7-text.nix2
-rw-r--r--pkgs/development/interpreters/python/cpython/docs/3.10-html.nix2
-rw-r--r--pkgs/development/interpreters/python/cpython/docs/3.10-pdf-a4.nix2
-rw-r--r--pkgs/development/interpreters/python/cpython/docs/3.10-pdf-letter.nix2
-rw-r--r--pkgs/development/interpreters/python/cpython/docs/3.10-texinfo.nix2
-rw-r--r--pkgs/development/interpreters/python/cpython/docs/3.10-text.nix2
-rw-r--r--pkgs/development/interpreters/python/cpython/docs/template-info.nix2
-rw-r--r--pkgs/development/interpreters/python/cpython/docs/template.nix2
-rw-r--r--pkgs/development/interpreters/python/default.nix34
-rw-r--r--pkgs/development/interpreters/python/hooks/python-imports-check-hook.sh9
-rw-r--r--pkgs/development/interpreters/python/hooks/python-relax-deps-hook.sh6
-rw-r--r--pkgs/development/interpreters/python/mk-python-derivation.nix5
-rw-r--r--pkgs/development/interpreters/python/python-packages-base.nix6
-rw-r--r--pkgs/development/interpreters/python/python2/mk-python-derivation.nix2
-rw-r--r--pkgs/development/interpreters/python/tests/test_cpython_gdb/default.nix2
-rwxr-xr-xpkgs/development/interpreters/python/update-python-libraries/update-python-libraries.py38
21 files changed, 134 insertions, 62 deletions
diff --git a/pkgs/development/interpreters/python/cpython/3.12/0001-Fix-build-with-_PY_SHORT_FLOAT_REPR-0.patch b/pkgs/development/interpreters/python/cpython/3.12/0001-Fix-build-with-_PY_SHORT_FLOAT_REPR-0.patch
new file mode 100644
index 0000000000000..a978413a676a6
--- /dev/null
+++ b/pkgs/development/interpreters/python/cpython/3.12/0001-Fix-build-with-_PY_SHORT_FLOAT_REPR-0.patch
@@ -0,0 +1,53 @@
+From 04bfb877c8ccbd431dcae429abb487c1e3390801 Mon Sep 17 00:00:00 2001
+From: Yureka <yuka@yuka.dev>
+Date: Sun, 30 Jun 2024 09:37:49 +0200
+Subject: [PATCH] Fix build with _PY_SHORT_FLOAT_REPR == 0
+
+---
+ Include/internal/pycore_dtoa.h | 10 +++-------
+ 1 file changed, 3 insertions(+), 7 deletions(-)
+
+diff --git a/Include/internal/pycore_dtoa.h b/Include/internal/pycore_dtoa.h
+index 4d9681d59a..899d413b05 100644
+--- a/Include/internal/pycore_dtoa.h
++++ b/Include/internal/pycore_dtoa.h
+@@ -11,8 +11,6 @@ extern "C" {
+ #include "pycore_pymath.h"        // _PY_SHORT_FLOAT_REPR
+ 
+ 
+-#if _PY_SHORT_FLOAT_REPR == 1
+-
+ typedef uint32_t ULong;
+ 
+ struct
+@@ -22,15 +20,15 @@ Bigint {
+     ULong x[1];
+ };
+ 
+-#ifdef Py_USING_MEMORY_DEBUGGER
++#if defined(Py_USING_MEMORY_DEBUGGER) || _PY_SHORT_FLOAT_REPR == 0
+ 
+ struct _dtoa_state {
+     int _not_used;
+ };
+-#define _dtoa_interp_state_INIT(INTERP) \
++#define _dtoa_state_INIT(INTERP) \
+     {0}
+ 
+-#else  // !Py_USING_MEMORY_DEBUGGER
++#else  // !Py_USING_MEMORY_DEBUGGER && _PY_SHORT_FLOAT_REPR != 0
+ 
+ /* The size of the Bigint freelist */
+ #define Bigint_Kmax 7
+@@ -65,8 +63,6 @@ PyAPI_FUNC(char *) _Py_dg_dtoa(double d, int mode, int ndigits,
+                         int *decpt, int *sign, char **rve);
+ PyAPI_FUNC(void) _Py_dg_freedtoa(char *s);
+ 
+-#endif // _PY_SHORT_FLOAT_REPR == 1
+-
+ #ifdef __cplusplus
+ }
+ #endif
+-- 
+2.45.1
+
diff --git a/pkgs/development/interpreters/python/cpython/default.nix b/pkgs/development/interpreters/python/cpython/default.nix
index ab5960b5ea610..dd569db153582 100644
--- a/pkgs/development/interpreters/python/cpython/default.nix
+++ b/pkgs/development/interpreters/python/cpython/default.nix
@@ -70,8 +70,7 @@
 , enableNoSemanticInterposition ? true
 
 # enabling LTO on 32bit arch causes downstream packages to fail when linking
-# enabling LTO on *-darwin causes python3 to fail when linking.
-, enableLTO ? stdenv.is64bit && stdenv.isLinux
+, enableLTO ? stdenv.isDarwin || (stdenv.is64bit && stdenv.isLinux)
 
 # enable asserts to ensure the build remains reproducible
 , reproducibleBuild ? false
@@ -367,7 +366,11 @@ in with passthru; stdenv.mkDerivation (finalAttrs: {
     };
   in [
     "${mingw-patch}/*.patch"
-  ]);
+  ]) ++ optionals isPy312 [
+    # backport fix for various platforms; armv7l, riscv64, s390
+    # https://github.com/python/cpython/pull/121178
+    ./3.12/0001-Fix-build-with-_PY_SHORT_FLOAT_REPR-0.patch
+  ];
 
   postPatch = optionalString (!stdenv.hostPlatform.isWindows) ''
     substituteInPlace Lib/subprocess.py \
@@ -397,9 +400,6 @@ in with passthru; stdenv.mkDerivation (finalAttrs: {
   configureFlags = [
     "--without-ensurepip"
     "--with-system-expat"
-  ] ++ optionals (!(stdenv.isDarwin && pythonAtLeast "3.12")) [
-    #  ./Modules/_decimal/_decimal.c:4673:6: error: "No valid combination of CONFIG_64, CONFIG_32 and _PyHASH_BITS"
-    # https://hydra.nixos.org/build/248410479/nixlog/2/tail
     "--with-system-libmpdec"
   ] ++ optionals (openssl != null) [
     "--with-openssl=${openssl.dev}"
@@ -417,6 +417,9 @@ in with passthru; stdenv.mkDerivation (finalAttrs: {
     (enableFeature enableGIL "gil")
   ] ++ optionals enableOptimizations [
     "--enable-optimizations"
+  ] ++ optionals (stdenv.isDarwin && configd == null) [
+    # Make conditional on Darwin for now to avoid causing Linux rebuilds.
+    "py_cv_module__scproxy=n/a"
   ] ++ optionals (sqlite != null) [
     "--enable-loadable-sqlite-extensions"
   ] ++ optionals (libxcrypt != null) [
@@ -468,6 +471,10 @@ in with passthru; stdenv.mkDerivation (finalAttrs: {
     export PYTHON_DECIMAL_WITH_MACHINE=${if stdenv.isAarch64 then "uint128" else "x64"}
     # Ensure that modern platform features are enabled on Darwin in spite of having no version suffix.
     sed -E -i -e 's|Darwin/\[12\]\[0-9\]\.\*|Darwin/*|' configure
+  '' + optionalString (pythonAtLeast "3.11") ''
+    # Also override the auto-detection in `configure`.
+    substituteInPlace configure \
+      --replace-fail 'libmpdec_machine=universal' 'libmpdec_machine=${if stdenv.isAarch64 then "uint128" else "x64"}'
   '' + optionalString (stdenv.isDarwin && x11Support && pythonAtLeast "3.11") ''
     export TCLTK_LIBS="-L${tcl}/lib -L${tk}/lib -l${tcl.libPrefix} -l${tk.libPrefix}"
     export TCLTK_CFLAGS="-I${tcl}/include -I${tk}/include"
diff --git a/pkgs/development/interpreters/python/cpython/docs/2.7-html.nix b/pkgs/development/interpreters/python/cpython/docs/2.7-html.nix
index a15bca1e013ea..ab712cb734ea5 100644
--- a/pkgs/development/interpreters/python/cpython/docs/2.7-html.nix
+++ b/pkgs/development/interpreters/python/cpython/docs/2.7-html.nix
@@ -1,6 +1,6 @@
 # This file was generated and will be overwritten by ./generate.sh
 
-{ stdenv, fetchurl, lib }:
+{ stdenv, lib, fetchurl }:
 
 stdenv.mkDerivation {
   pname = "python27-docs-html";
diff --git a/pkgs/development/interpreters/python/cpython/docs/2.7-pdf-a4.nix b/pkgs/development/interpreters/python/cpython/docs/2.7-pdf-a4.nix
index 54b28992d4724..0ae044db37c93 100644
--- a/pkgs/development/interpreters/python/cpython/docs/2.7-pdf-a4.nix
+++ b/pkgs/development/interpreters/python/cpython/docs/2.7-pdf-a4.nix
@@ -1,6 +1,6 @@
 # This file was generated and will be overwritten by ./generate.sh
 
-{ stdenv, fetchurl, lib }:
+{ stdenv, lib, fetchurl }:
 
 stdenv.mkDerivation {
   pname = "python27-docs-pdf-a4";
diff --git a/pkgs/development/interpreters/python/cpython/docs/2.7-pdf-letter.nix b/pkgs/development/interpreters/python/cpython/docs/2.7-pdf-letter.nix
index 84cf35f385a18..85593000d421e 100644
--- a/pkgs/development/interpreters/python/cpython/docs/2.7-pdf-letter.nix
+++ b/pkgs/development/interpreters/python/cpython/docs/2.7-pdf-letter.nix
@@ -1,6 +1,6 @@
 # This file was generated and will be overwritten by ./generate.sh
 
-{ stdenv, fetchurl, lib }:
+{ stdenv, lib, fetchurl }:
 
 stdenv.mkDerivation {
   pname = "python27-docs-pdf-letter";
diff --git a/pkgs/development/interpreters/python/cpython/docs/2.7-text.nix b/pkgs/development/interpreters/python/cpython/docs/2.7-text.nix
index 5d25344e4bdcf..24a22dd146752 100644
--- a/pkgs/development/interpreters/python/cpython/docs/2.7-text.nix
+++ b/pkgs/development/interpreters/python/cpython/docs/2.7-text.nix
@@ -1,6 +1,6 @@
 # This file was generated and will be overwritten by ./generate.sh
 
-{ stdenv, fetchurl, lib }:
+{ stdenv, lib, fetchurl }:
 
 stdenv.mkDerivation {
   pname = "python27-docs-text";
diff --git a/pkgs/development/interpreters/python/cpython/docs/3.10-html.nix b/pkgs/development/interpreters/python/cpython/docs/3.10-html.nix
index 6efe8d571a772..0cbe633c63b10 100644
--- a/pkgs/development/interpreters/python/cpython/docs/3.10-html.nix
+++ b/pkgs/development/interpreters/python/cpython/docs/3.10-html.nix
@@ -1,6 +1,6 @@
 # This file was generated and will be overwritten by ./generate.sh
 
-{ stdenv, fetchurl, lib }:
+{ stdenv, lib, fetchurl }:
 
 stdenv.mkDerivation {
   pname = "python310-docs-html";
diff --git a/pkgs/development/interpreters/python/cpython/docs/3.10-pdf-a4.nix b/pkgs/development/interpreters/python/cpython/docs/3.10-pdf-a4.nix
index 1cbbf179a2e23..bb98fdffb0056 100644
--- a/pkgs/development/interpreters/python/cpython/docs/3.10-pdf-a4.nix
+++ b/pkgs/development/interpreters/python/cpython/docs/3.10-pdf-a4.nix
@@ -1,6 +1,6 @@
 # This file was generated and will be overwritten by ./generate.sh
 
-{ stdenv, fetchurl, lib }:
+{ stdenv, lib, fetchurl }:
 
 stdenv.mkDerivation {
   pname = "python310-docs-pdf-a4";
diff --git a/pkgs/development/interpreters/python/cpython/docs/3.10-pdf-letter.nix b/pkgs/development/interpreters/python/cpython/docs/3.10-pdf-letter.nix
index 6b24450855b2f..8bd6298fe1512 100644
--- a/pkgs/development/interpreters/python/cpython/docs/3.10-pdf-letter.nix
+++ b/pkgs/development/interpreters/python/cpython/docs/3.10-pdf-letter.nix
@@ -1,6 +1,6 @@
 # This file was generated and will be overwritten by ./generate.sh
 
-{ stdenv, fetchurl, lib }:
+{ stdenv, lib, fetchurl }:
 
 stdenv.mkDerivation {
   pname = "python310-docs-pdf-letter";
diff --git a/pkgs/development/interpreters/python/cpython/docs/3.10-texinfo.nix b/pkgs/development/interpreters/python/cpython/docs/3.10-texinfo.nix
index 694ed0e9ad942..35664e17cd685 100644
--- a/pkgs/development/interpreters/python/cpython/docs/3.10-texinfo.nix
+++ b/pkgs/development/interpreters/python/cpython/docs/3.10-texinfo.nix
@@ -1,6 +1,6 @@
 # This file was generated and will be overwritten by ./generate.sh
 
-{ stdenv, fetchurl, lib }:
+{ stdenv, lib, fetchurl }:
 
 stdenv.mkDerivation {
   pname = "python310-docs-texinfo";
diff --git a/pkgs/development/interpreters/python/cpython/docs/3.10-text.nix b/pkgs/development/interpreters/python/cpython/docs/3.10-text.nix
index 4ada4e2b704d4..eec0bf140961a 100644
--- a/pkgs/development/interpreters/python/cpython/docs/3.10-text.nix
+++ b/pkgs/development/interpreters/python/cpython/docs/3.10-text.nix
@@ -1,6 +1,6 @@
 # This file was generated and will be overwritten by ./generate.sh
 
-{ stdenv, fetchurl, lib }:
+{ stdenv, lib, fetchurl }:
 
 stdenv.mkDerivation {
   pname = "python310-docs-text";
diff --git a/pkgs/development/interpreters/python/cpython/docs/template-info.nix b/pkgs/development/interpreters/python/cpython/docs/template-info.nix
index 4f5d4b3e37ab1..f1551e1f61eff 100644
--- a/pkgs/development/interpreters/python/cpython/docs/template-info.nix
+++ b/pkgs/development/interpreters/python/cpython/docs/template-info.nix
@@ -1,6 +1,6 @@
 # This file was generated and will be overwritten by ./generate.sh
 
-{ stdenv, fetchurl, lib }:
+{ stdenv, fetchurl }:
 
 stdenv.mkDerivation {
   pname = "pythonMAJORMINOR-docs-TYPE";
diff --git a/pkgs/development/interpreters/python/cpython/docs/template.nix b/pkgs/development/interpreters/python/cpython/docs/template.nix
index fff6e0bedb18e..adf64ddd62244 100644
--- a/pkgs/development/interpreters/python/cpython/docs/template.nix
+++ b/pkgs/development/interpreters/python/cpython/docs/template.nix
@@ -1,6 +1,6 @@
 # This file was generated and will be overwritten by ./generate.sh
 
-{ stdenv, fetchurl, lib }:
+{ stdenv, fetchurl }:
 
 stdenv.mkDerivation {
   pname = "pythonMAJORMINOR-docs-TYPE";
diff --git a/pkgs/development/interpreters/python/default.nix b/pkgs/development/interpreters/python/default.nix
index 08e017fb06e8f..eb859dcb958c7 100644
--- a/pkgs/development/interpreters/python/default.nix
+++ b/pkgs/development/interpreters/python/default.nix
@@ -16,14 +16,14 @@
   passthruFun = import ./passthrufun.nix args;
 
   sources = {
-    python311 = {
+    python312 = {
       sourceVersion = {
         major = "3";
-        minor = "11";
-        patch = "9";
+        minor = "12";
+        patch = "4";
         suffix = "";
       };
-      hash = "sha256-mx6JZSP8UQaREmyGRAbZNgo9Hphqy9pZzaV7Wr2kW4c=";
+      hash = "sha256-9tQZpth0OrJnAIAbSQjSbZfouYbhT5XeMbMt4rDnlVQ=";
     };
   };
 
@@ -68,34 +68,34 @@ in {
     inherit passthruFun;
   };
 
-  python311 = callPackage ./cpython ({
+  python311 = callPackage ./cpython {
     self = __splicedPackages.python311;
-    inherit (darwin) configd;
-    inherit passthruFun;
-  } // sources.python311);
-
-  python312 = callPackage ./cpython {
-    self = __splicedPackages.python312;
     sourceVersion = {
       major = "3";
-      minor = "12";
-      patch = "3";
+      minor = "11";
+      patch = "9";
       suffix = "";
     };
-    hash = "sha256-Vr/vH9/BIhzmcg5DpmHj60F4XdkUzplpjYx4lq9L2qE=";
+    hash = "sha256-mx6JZSP8UQaREmyGRAbZNgo9Hphqy9pZzaV7Wr2kW4c=";
     inherit (darwin) configd;
     inherit passthruFun;
   };
 
+  python312 = callPackage ./cpython ({
+    self = __splicedPackages.python312;
+    inherit (darwin) configd;
+    inherit passthruFun;
+  } // sources.python312);
+
   python313 = callPackage ./cpython {
     self = __splicedPackages.python313;
     sourceVersion = {
       major = "3";
       minor = "13";
       patch = "0";
-      suffix = "b3";
+      suffix = "b4";
     };
-    hash = "sha256-O+CUrQixHcKgZUY1JCOceNyfKzQrAdzU4eYG27xceKU=";
+    hash = "sha256-sqpVfDyHUjOr2vGxJChOXVD2uyONYqi1XxLcks6hlT8=";
     inherit (darwin) configd;
     inherit passthruFun;
   };
@@ -123,7 +123,7 @@ in {
     enableOptimizations = false;
     enableLTO = false;
     mimetypesSupport = false;
-  } // sources.python311)).overrideAttrs(old: {
+  } // sources.python312)).overrideAttrs(old: {
     # TODO(@Artturin): Add this to the main cpython expr
     strictDeps = true;
     pname = "python3-minimal";
diff --git a/pkgs/development/interpreters/python/hooks/python-imports-check-hook.sh b/pkgs/development/interpreters/python/hooks/python-imports-check-hook.sh
index 7172ac4985451..b65d6e745247e 100644
--- a/pkgs/development/interpreters/python/hooks/python-imports-check-hook.sh
+++ b/pkgs/development/interpreters/python/hooks/python-imports-check-hook.sh
@@ -6,8 +6,13 @@ pythonImportsCheckPhase () {
 
     if [ -n "$pythonImportsCheck" ]; then
         echo "Check whether the following modules can be imported: $pythonImportsCheck"
-        export PYTHONPATH="$out/@pythonSitePackages@:$PYTHONPATH"
-        ( cd $out && eval "@pythonCheckInterpreter@ -c 'import os; import importlib; list(map(lambda mod: importlib.import_module(mod), os.environ[\"pythonImportsCheck\"].split()))'" )
+        pythonImportsCheckOutput=$out
+        if [ -n "$python" ]; then
+            echo "Using python specific output \$python for imports check"
+            pythonImportsCheckOutput=$python
+        fi
+        export PYTHONPATH="$pythonImportsCheckOutput/@pythonSitePackages@:$PYTHONPATH"
+        ( cd $pythonImportsCheckOutput && eval "@pythonCheckInterpreter@ -c 'import os; import importlib; list(map(lambda mod: importlib.import_module(mod), os.environ[\"pythonImportsCheck\"].split()))'" )
     fi
 }
 
diff --git a/pkgs/development/interpreters/python/hooks/python-relax-deps-hook.sh b/pkgs/development/interpreters/python/hooks/python-relax-deps-hook.sh
index 16df000139255..7fd1b52a04bf0 100644
--- a/pkgs/development/interpreters/python/hooks/python-relax-deps-hook.sh
+++ b/pkgs/development/interpreters/python/hooks/python-relax-deps-hook.sh
@@ -4,12 +4,10 @@
 #
 # Example usage in a derivation:
 #
-#   { …, pythonPackages, … }:
+#   { …, python3Packages, … }:
 #
-#   pythonPackages.buildPythonPackage {
+#   python3Packages.buildPythonPackage {
 #     …
-#     nativeBuildInputs = [ pythonPackages.pythonRelaxDepsHook ];
-#
 #     # This will relax the dependency restrictions
 #     # e.g.: abc>1,<=2 -> abc
 #     pythonRelaxDeps = [ "abc" ];
diff --git a/pkgs/development/interpreters/python/mk-python-derivation.nix b/pkgs/development/interpreters/python/mk-python-derivation.nix
index 4c45d9603be82..0d6ab22249916 100644
--- a/pkgs/development/interpreters/python/mk-python-derivation.nix
+++ b/pkgs/development/interpreters/python/mk-python-derivation.nix
@@ -17,6 +17,7 @@
 , pythonImportsCheckHook
 , pythonNamespacesHook
 , pythonOutputDistHook
+, pythonRelaxDepsHook
 , pythonRemoveBinBytecodeHook
 , pythonRemoveTestsDirHook
 , pythonRuntimeDepsCheckHook
@@ -144,7 +145,7 @@ in
 
 , meta ? {}
 
-, doCheck ? config.doCheckByDefault or false
+, doCheck ? true
 
 , disabledTestPaths ? []
 
@@ -252,6 +253,8 @@ let
       #    because the hook that checks for conflicts uses setuptools.
       #
       pythonCatchConflictsHook
+    ] ++ optionals (attrs ? pythonRelaxDeps || attrs ? pythonRemoveDeps) [
+      pythonRelaxDepsHook
     ] ++ optionals removeBinBytecode [
       pythonRemoveBinBytecodeHook
     ] ++ optionals (hasSuffix "zip" (attrs.src.name or "")) [
diff --git a/pkgs/development/interpreters/python/python-packages-base.nix b/pkgs/development/interpreters/python/python-packages-base.nix
index 2306292eb8c8f..e4be95bb3a100 100644
--- a/pkgs/development/interpreters/python/python-packages-base.nix
+++ b/pkgs/development/interpreters/python/python-packages-base.nix
@@ -99,6 +99,8 @@ in {
   inherit toPythonModule toPythonApplication;
 
   python = toPythonModule python;
-  # Dont take pythonPackages from "global" pkgs scope to avoid mixing python versions
-  pythonPackages = self;
+
+  # Don't take pythonPackages from "global" pkgs scope to avoid mixing python versions.
+  # Prevent `pkgs/top-level/release-attrpaths-superset.nix` from recursing more than one level here.
+  pythonPackages = self // { __attrsFailEvaluation = true; };
 }
diff --git a/pkgs/development/interpreters/python/python2/mk-python-derivation.nix b/pkgs/development/interpreters/python/python2/mk-python-derivation.nix
index 1a6f9c784cf67..d0d8a9d0dca8f 100644
--- a/pkgs/development/interpreters/python/python2/mk-python-derivation.nix
+++ b/pkgs/development/interpreters/python/python2/mk-python-derivation.nix
@@ -92,7 +92,7 @@
 
 , passthru ? {}
 
-, doCheck ? config.doCheckByDefault or false
+, doCheck ? true
 
 , disabledTestPaths ? []
 
diff --git a/pkgs/development/interpreters/python/tests/test_cpython_gdb/default.nix b/pkgs/development/interpreters/python/tests/test_cpython_gdb/default.nix
index 0254d843a4cfe..3d3bf549d91c1 100644
--- a/pkgs/development/interpreters/python/tests/test_cpython_gdb/default.nix
+++ b/pkgs/development/interpreters/python/tests/test_cpython_gdb/default.nix
@@ -1,4 +1,4 @@
-{ interpreter, lib, gdb, writeText, runCommand }:
+{ interpreter, gdb, writeText, runCommand }:
 
 let
   crashme-py = writeText "crashme.py" ''
diff --git a/pkgs/development/interpreters/python/update-python-libraries/update-python-libraries.py b/pkgs/development/interpreters/python/update-python-libraries/update-python-libraries.py
index fbc096502fa7e..57153383fc189 100755
--- a/pkgs/development/interpreters/python/update-python-libraries/update-python-libraries.py
+++ b/pkgs/development/interpreters/python/update-python-libraries/update-python-libraries.py
@@ -275,16 +275,17 @@ def _get_latest_version_github(attr_path, package, extension, current_version, t
     release = next(filter(lambda x: strip_prefix(x["tag_name"]) == version, releases))
     prefix = get_prefix(release["tag_name"])
 
-    # some attributes require using the fetchgit
-    git_fetcher_args = []
-    if _get_attr_value(f"{attr_path}.src.fetchSubmodules"):
-        git_fetcher_args.append("--fetch-submodules")
-    if _get_attr_value(f"{attr_path}.src.fetchLFS"):
-        git_fetcher_args.append("--fetch-lfs")
-    if _get_attr_value(f"{attr_path}.src.leaveDotGit"):
-        git_fetcher_args.append("--leave-dotGit")
-
-    if git_fetcher_args or _get_attr_value(f"{attr_path}.src.fetcher").endswith("nix-prefetch-git"):
+    fetcher = _get_attr_value(f"{attr_path}.src.fetcher")
+    if fetcher is not None and fetcher.endswith("nix-prefetch-git"):
+        # some attributes require using the fetchgit
+        git_fetcher_args = []
+        if _get_attr_value(f"{attr_path}.src.fetchSubmodules"):
+            git_fetcher_args.append("--fetch-submodules")
+        if _get_attr_value(f"{attr_path}.src.fetchLFS"):
+            git_fetcher_args.append("--fetch-lfs")
+        if _get_attr_value(f"{attr_path}.src.leaveDotGit"):
+            git_fetcher_args.append("--leave-dotGit")
+
         algorithm = "sha256"
         cmd = [
             "nix-prefetch-git",
@@ -319,14 +320,17 @@ def _get_latest_version_github(attr_path, package, extension, current_version, t
             tag_url = str(release["tarball_url"]).replace(
                 "tarball", "tarball/refs/tags"
             )
-            hash = (
-                subprocess.check_output(
-                    ["nix-prefetch-url", "--type", "sha256", "--unpack", tag_url],
-                    stderr=subprocess.DEVNULL,
+            try:
+                hash = (
+                    subprocess.check_output(
+                        ["nix-prefetch-url", "--type", "sha256", "--unpack", tag_url],
+                        stderr=subprocess.DEVNULL,
+                    )
+                    .decode("utf-8")
+                    .strip()
                 )
-                .decode("utf-8")
-                .strip()
-            )
+            except subprocess.CalledProcessError:
+                raise ValueError("nix-prefetch-url failed")
 
     return version, hash, prefix