@@ -210,7 +210,7 @@ def _parse_versions(versions):
210210 return (max (sorted (versions ))).raw_version
211211
212212
213- def _get_latest_version_pypi (package , extension , current_version , target ):
213+ def _get_latest_version_pypi (attr_path , package , extension , current_version , target ):
214214 """Get latest version and hash from PyPI."""
215215 url = "{}/{}/json" .format (INDEX , package )
216216 json = _fetch_page (url )
@@ -234,17 +234,14 @@ def _get_latest_version_pypi(package, extension, current_version, target):
234234 return version , sha256 , None
235235
236236
237- def _get_latest_version_github (package , extension , current_version , target ):
237+ def _get_latest_version_github (attr_path , package , extension , current_version , target ):
238238 def strip_prefix (tag ):
239239 return re .sub ("^[^0-9]*" , "" , tag )
240240
241241 def get_prefix (string ):
242242 matches = re .findall (r"^([^0-9]*)" , string )
243243 return next (iter (matches ), "" )
244244
245- # when invoked as an updateScript, UPDATE_NIX_ATTR_PATH will be set
246- # this allows us to work with packages which live outside of python-modules
247- attr_path = os .environ .get ("UPDATE_NIX_ATTR_PATH" , f"python3Packages.{ package } " )
248245 try :
249246 homepage = subprocess .check_output (
250247 [
@@ -421,13 +418,17 @@ def _update_package(path, target):
421418 # Attempt a fetch using each pname, e.g. backports-zoneinfo vs backports.zoneinfo
422419 successful_fetch = False
423420 for pname in pnames :
424- if BULK_UPDATE and _skip_bulk_update (f"python3Packages.{ pname } " ):
421+ # when invoked as an updateScript, UPDATE_NIX_ATTR_PATH will be set
422+ # this allows us to work with packages which live outside of python-modules
423+ attr_path = os .environ .get ("UPDATE_NIX_ATTR_PATH" , f"python3Packages.{ pname } " )
424+
425+ if BULK_UPDATE and _skip_bulk_update (attr_path ):
425426 raise ValueError (f"Bulk update skipped for { pname } " )
426- elif _get_attr_value (f"python3Packages. { pname } .cargoDeps" ) is not None :
427+ elif _get_attr_value (f"{ attr_path } .cargoDeps" ) is not None :
427428 raise ValueError (f"Cargo dependencies are unsupported, skipping { pname } " )
428429 try :
429430 new_version , new_sha256 , prefix = FETCHERS [fetcher ](
430- pname , extension , version , target
431+ attr_path , pname , extension , version , target
431432 )
432433 successful_fetch = True
433434 break
@@ -452,7 +453,7 @@ def _update_package(path, target):
452453 sri_hash = _hash_to_sri ("sha256" , new_sha256 )
453454
454455 # retrieve the old output hash for a more precise match
455- if old_hash := _get_attr_value (f"python3Packages. { pname } .src.outputHash" ):
456+ if old_hash := _get_attr_value (f"{ attr_path } .src.outputHash" ):
456457 # fetchers can specify a sha256, or a sri hash
457458 try :
458459 text = _replace_value ("hash" , sri_hash , text , old_hash )
0 commit comments