@@ -358,40 +358,50 @@ def build_sqlite(env, dirs, logfp):
358358 runcmd (["make" , "install" ], env = env , stderr = logfp , stdout = logfp )
359359
360360
361- def update_ensurepip (source_dir ):
361+ def update_ensurepip (lib_dir ):
362362 """
363363 Update bundled dependencies for ensurepip (pip & setuptools).
364364 """
365365 # ensurepip bundle location
366- bundle_dir = source_dir / "Lib" / "ensurepip" / "_bundled"
366+ bundle_dir = lib_dir / "ensurepip" / "_bundled"
367367
368368 # Make sure the destination directory exists
369369 bundle_dir .mkdir (parents = True , exist_ok = True )
370370
371- # Remove existing whl files
371+ # Detect existing whl files and delete them. Later versions of python don't
372+ # include setuptools. We only want to update whl files that are a part of
373+ # python
374+ update_pip = False
375+ update_setuptools = False
372376 for file in bundle_dir .glob ("*.whl" ):
373- if file .is_file ():
377+ if "pip" in file :
378+ update_pip = True
379+ file .unlink ()
380+ if "setuptools" in file :
381+ update_setuptools = True
374382 file .unlink ()
375383
376384 # Download whl files
377385 # pip
378- pip_version = "25.2"
379- whl = f"pip-{ pip_version } -py3-none-any.whl"
380- whl_path = "b7/3f/945ef7ab14dc4f9d7f40288d2df998d1837ee0888ec3659c813487572faa"
381- url = f"https://files.pythonhosted.org/packages/{ whl_path } /{ whl } "
382- download_url (url = url , dest = bundle_dir )
383- assert (bundle_dir / whl ).exists ()
386+ if update_pip :
387+ pip_version = "25.2"
388+ whl = f"pip-{ pip_version } -py3-none-any.whl"
389+ whl_path = "b7/3f/945ef7ab14dc4f9d7f40288d2df998d1837ee0888ec3659c813487572faa"
390+ url = f"https://files.pythonhosted.org/packages/{ whl_path } /{ whl } "
391+ download_url (url = url , dest = bundle_dir )
392+ assert (bundle_dir / whl ).exists ()
384393
385394 # setuptools
386- setuptools_version = "80.9.0"
387- whl = f"setuptools-{ setuptools_version } -py3-none-any.whl"
388- whl_path = "a3/dc/17031897dae0efacfea57dfd3a82fdd2a2aeb58e0ff71b77b87e44edc772"
389- url = f"https://files.pythonhosted.org/packages/{ whl_path } /{ whl } "
390- download_url (url = url , dest = bundle_dir )
391- assert (bundle_dir / whl ).exists ()
395+ if update_setuptools :
396+ setuptools_version = "80.9.0"
397+ whl = f"setuptools-{ setuptools_version } -py3-none-any.whl"
398+ whl_path = "a3/dc/17031897dae0efacfea57dfd3a82fdd2a2aeb58e0ff71b77b87e44edc772"
399+ url = f"https://files.pythonhosted.org/packages/{ whl_path } /{ whl } "
400+ download_url (url = url , dest = bundle_dir )
401+ assert (bundle_dir / whl ).exists ()
392402
393403 # Update __init__.py
394- init_file = source_dir / "Lib" / "ensurepip" / "__init__.py"
404+ init_file = lib_dir / "ensurepip" / "__init__.py"
395405 # pip
396406 old = "^_PIP_VERSION.*"
397407 new = f'_PIP_VERSION = "{ pip_version } "'
@@ -425,7 +435,7 @@ def patch_file(path, old, new):
425435 new_content = ""
426436 for line in content .splitlines ():
427437 line = re .sub (old , new , line )
428- new_content += line + os . linesep
438+ new_content += line + " \n "
429439 with open (path , "w" ) as fp :
430440 fp .write (new_content )
431441
@@ -1521,6 +1531,9 @@ def finalize(env, dirs, logfp):
15211531 # Install relenv-sysconfigdata module
15221532 libdir = pathlib .Path (dirs .prefix ) / "lib"
15231533
1534+ # update ensurepip
1535+ update_ensurepip (libdir )
1536+
15241537 def find_pythonlib (libdir ):
15251538 for root , dirs , files in os .walk (libdir ):
15261539 for _ in dirs :
0 commit comments