mirror of
https://github.com/pyenv/pyenv.git
synced 2026-01-14 16:57:14 +09:00
CI: adjust CPython PR generation logic (#3392)
* For files retrieved through the GNU mirror load balancer, specify the load balancer URL * Explicitly `git mv` files on prerelease upgrade in case Git doesn't detect it * Add a trailing newline to a thunk
This commit is contained in:
parent
92c9ab5273
commit
94faa168cb
2
.github/workflows/add_version.yml
vendored
2
.github/workflows/add_version.yml
vendored
@ -34,7 +34,7 @@ jobs:
|
||||
versions=[l.rstrip() for l in open("added_versions.lst")]
|
||||
with open(os.environ['GITHUB_ENV'],'a') as f:
|
||||
f.write(f'branch_name=auto_add_version/{"_".join(versions)}\n')
|
||||
f.write(f'pr_name=Add {", ".join(versions)}\n')
|
||||
f.write(f'pr_name=Add CPython {", ".join(versions)}\n')
|
||||
os.remove("added_versions.lst")
|
||||
|
||||
- name: Create Pull Request
|
||||
|
||||
@ -13,9 +13,11 @@ import io
|
||||
import itertools
|
||||
import logging
|
||||
import operator
|
||||
import os.path
|
||||
import pathlib
|
||||
import pprint
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
import typing
|
||||
import urllib.parse
|
||||
@ -40,7 +42,8 @@ OUT_DIR: pathlib.Path = here.parent.parent / "share" / "python-build"
|
||||
|
||||
T_THUNK=\
|
||||
'''export PYTHON_BUILD_FREE_THREADING=1
|
||||
source "${BASH_SOURCE[0]%t}"'''
|
||||
source "${BASH_SOURCE[0]%t}"
|
||||
'''
|
||||
|
||||
|
||||
def adapt_script(version: packaging.version.Version,
|
||||
@ -120,7 +123,7 @@ def add_version(version: packaging.version.Version):
|
||||
return False
|
||||
VersionDirectory.existing.append(_CPythonExistingScriptInfo(version,str(new_path)))
|
||||
|
||||
cleanup_prerelease_upgrade(is_prerelease_upgrade, previous_version)
|
||||
cleanup_prerelease_upgrade(is_prerelease_upgrade, previous_version, version)
|
||||
|
||||
handle_t_thunks(version, previous_version, is_prerelease_upgrade)
|
||||
|
||||
@ -130,26 +133,55 @@ def add_version(version: packaging.version.Version):
|
||||
|
||||
def cleanup_prerelease_upgrade(
|
||||
is_prerelease_upgrade: bool,
|
||||
previous_version: packaging.version.Version)\
|
||||
previous_version: packaging.version.Version,
|
||||
new_version: packaging.version.Version)\
|
||||
-> None:
|
||||
if is_prerelease_upgrade:
|
||||
previous_version_path = OUT_DIR / str(previous_version)
|
||||
logger.info(f'Deleting {previous_version_path}')
|
||||
previous_version_path.unlink()
|
||||
del VersionDirectory.existing[previous_version]
|
||||
if not is_prerelease_upgrade:
|
||||
return
|
||||
|
||||
previous_version_filename = str(previous_version)
|
||||
new_version_filename = str(new_version)
|
||||
new_version_path = OUT_DIR / new_version_filename
|
||||
|
||||
logger.info(f'Git moving {previous_version_filename} '
|
||||
f'to {new_version_filename} (preserving new data)')
|
||||
|
||||
data = new_version_path.read_text()
|
||||
new_version_path.unlink()
|
||||
|
||||
subprocess.check_call(("git","-C",OUT_DIR,
|
||||
"mv",
|
||||
previous_version_filename,
|
||||
new_version_filename))
|
||||
|
||||
new_version_path.write_text(data)
|
||||
|
||||
del VersionDirectory.existing[previous_version]
|
||||
|
||||
|
||||
def handle_t_thunks(version, previous_version, is_prerelease_upgrade):
|
||||
if (version.major, version.minor) >= (3, 13):
|
||||
# an old thunk may have older version-specific code
|
||||
# so it's safer to write a known version-independent template
|
||||
thunk_path = OUT_DIR.joinpath(str(version) + "t")
|
||||
logger.info(f"Writing {thunk_path}")
|
||||
thunk_path.write_text(T_THUNK, encoding='utf-8')
|
||||
if is_prerelease_upgrade:
|
||||
previous_thunk_path = OUT_DIR.joinpath(str(previous_version) + "t")
|
||||
logger.info(f"Deleting {previous_thunk_path}")
|
||||
previous_thunk_path.unlink()
|
||||
if (version.major, version.minor) < (3, 13):
|
||||
return
|
||||
|
||||
# an old thunk may have older version-specific code
|
||||
# so it's safer to write a known version-independent template
|
||||
thunk_name = (str(version) + "t")
|
||||
thunk_path = OUT_DIR / thunk_name
|
||||
previous_thunk_name = str(previous_version) + "t"
|
||||
previous_thunk_path = OUT_DIR / previous_thunk_name
|
||||
if is_prerelease_upgrade:
|
||||
logger.info(f"Git moving {previous_thunk_name} to {thunk_name}")
|
||||
subprocess.check_call(("git","-C",OUT_DIR,
|
||||
"mv",
|
||||
previous_thunk_name,
|
||||
thunk_name))
|
||||
else:
|
||||
logger.info(f"Deleting {previous_thunk_path}")
|
||||
previous_thunk_path.unlink()
|
||||
|
||||
logger.info(f"Writing {thunk_path}")
|
||||
thunk_path.write_text(T_THUNK, encoding='utf-8')
|
||||
|
||||
|
||||
Arguments: argparse.Namespace
|
||||
|
||||
@ -468,10 +500,13 @@ class ReadlineVersionsDirectory(KeyedList[_ReadlineVersionInfo, packaging.versio
|
||||
max_item = candidates._latest_release()
|
||||
hash_ = Url.sha256_url(max_item.url, VersionDirectory.session)
|
||||
|
||||
permalink = 'https://ftpmirror.gnu.org/readline/' +\
|
||||
os.path.basename(urllib.parse.urlparse(max_item.url).path)
|
||||
|
||||
result = _ReadlineVersionInfo(
|
||||
max_item.version,
|
||||
max_item.package_name,
|
||||
max_item.url,
|
||||
permalink,
|
||||
hash_)
|
||||
self.append(result)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user