def _update_with_gh(tool, dry_run): repo = { "libxcrypt": "besser82/libxcrypt", } dockerfile = Path(__file__).parent / "docker" / "Dockerfile" lines = dockerfile.read_text().splitlines() re_ = re.compile( f"^RUN export {tool.upper()}_VERSION=(?P<version>\\S+) && \\\\$") for i in range(len(lines)): match = re_.match(lines[i]) if match is None: continue current_version = Version(match["version"]) latest_tag = latest(repo[tool], output_format="tag") latest_version = Version(latest_tag) if latest_version > current_version: url = re.match( f"^ export {tool.upper()}_DOWNLOAD_URL=(?P<url>\\S+) && \\\\$", lines[i + 2])["url"] sha256 = _sha256(f"{url}/{latest_tag}.tar.gz") lines[ i + 0] = f"RUN export {tool.upper()}_VERSION={latest_version} && \\" lines[i + 1] = f" export {tool.upper()}_HASH={sha256} && \\" message = f"Bump {tool} {current_version} → {latest_version}" print(message) if not dry_run: dockerfile.write_text("\n".join(lines) + "\n") subprocess.check_call(["git", "commit", "-am", message]) break
def _update_sqlite(dry_run): dockerfile = Path(__file__).parent / "docker" / "Dockerfile" lines = dockerfile.read_text().splitlines() re_ = re.compile( f"^RUN export SQLITE_AUTOCONF_ROOT=sqlite-autoconf-(?P<version>\\S+) && \\\\$" ) for i in range(len(lines)): match = re_.match(lines[i]) if match is None: continue version_int = int(match["version"]) major = version_int // 1000000 version_int -= major * 1000000 minor = version_int // 10000 version_int -= minor * 10000 patch = version_int // 100 current_version = Version(f"{major}.{minor}.{patch}") latest_dict = latest("sqlite/sqlite", output_format="dict") latest_version = latest_dict["version"] if latest_version > current_version: version_int = latest_version.major * 1000000 + latest_version.minor * 10000 + latest_version.micro * 100 root = f"sqlite-autoconf-{version_int}" url = f"https://www.sqlite.org/{latest_dict['tag_date'].year}" sha256 = _sha256(f"{url}/{root}.tar.gz") lines[i + 0] = f"RUN export SQLITE_AUTOCONF_ROOT={root} && \\" lines[i + 1] = f" export SQLITE_AUTOCONF_HASH={sha256} && \\" lines[i + 2] = f" export SQLITE_AUTOCONF_DOWNLOAD_URL={url} && \\" message = f"Bump sqlite {current_version} → {latest_version}" print(message) if not dry_run: dockerfile.write_text("\n".join(lines) + "\n") subprocess.check_call(["git", "commit", "-am", message]) break
def _update_with_root(tool): repo = { "autoconf": "autotools-mirror/autoconf", "automake": "autotools-mirror/automake", "libtool": "autotools-mirror/libtool", "git": "git/git", "swig": "swig/swig", "openssl": "openssl/openssl", "curl": "curl/curl", } build_env = Path(__file__).parent / "docker" / "build_scripts" / "build_env.sh" lines = build_env.read_text().splitlines() re_ = re.compile(f"^{tool.upper()}_ROOT={tool}-(?P<version>\\S+)$") for i in range(len(lines)): match = re_.match(lines[i]) if match is None: continue current_version = Version(match["version"], char_fix_required=tool=="openssl") latest_version = latest(repo[tool]) if latest_version > current_version: root = f"{tool}-{latest_version}" url = re.match(f"^{tool.upper()}_DOWNLOAD_URL=(?P<url>\\S+)$", lines[i + 2])["url"] url = url.replace(f"${{{tool.upper()}_ROOT}}", root) sha256 = _sha256(f"{url}/{root}.tar.gz") lines[i + 0] = f"{tool.upper()}_ROOT={root}" lines[i + 1] = f"{tool.upper()}_HASH={sha256}" build_env.write_text("\n".join(lines) + "\n") message = f"Bump {tool} {current_version} → {latest_version}" print(message) subprocess.check_call(["git", "commit", "-am", message]) break
def _update_with_gh(tool): repo = { "patchelf": "NixOS/patchelf", "libxcrypt": "besser82/libxcrypt", } build_env = Path(__file__).parent / "docker" / "build_scripts" / "build_env.sh" lines = build_env.read_text().splitlines() re_ = re.compile(f"^{tool.upper()}_VERSION=(?P<version>\\S+)$") for i in range(len(lines)): match = re_.match(lines[i]) if match is None: continue current_version = Version(match["version"]) latest_tag = latest(repo[tool], output_format="tag") latest_version = Version(latest_tag) if latest_version > current_version: url = re.match(f"^{tool.upper()}_DOWNLOAD_URL=(?P<url>\\S+)$", lines[i + 2])["url"] sha256 = _sha256(f"{url}/{latest_tag}.tar.gz") lines[i + 0] = f"{tool.upper()}_VERSION={latest_version}" lines[i + 1] = f"{tool.upper()}_HASH={sha256}" build_env.write_text("\n".join(lines) + "\n") message = f"Bump {tool} {current_version} → {latest_version}" print(message) subprocess.check_call(["git", "commit", "-am", message]) break
def __call__(self, parser, namespace, values, option_string=None): version = '%(prog)s {version}'.format(version=__version__) last_version = lastversion.latest(lastversion.__self__) if __version__ == str(last_version): version += ', up to date' else: version += ', newer version {} available'.format(last_version) formatter = parser._get_formatter() formatter.add_text(version) parser._print_message(formatter.format_help(), _sys.stdout) parser.exit()
def _update_cpython(): build_env = Path(__file__).parent / "docker" / "build_scripts" / "build_env.sh" lines = build_env.read_text().splitlines() re_ = re.compile(r'^CPYTHON_VERSIONS="(?P<versions>.*)"$') for i in range(len(lines)): match = re_.match(lines[i]) if match is None: continue versions = match["versions"].split() for version in versions: current_version = Version(version) latest_version = latest("python/cpython", major=f'{current_version.major}.{current_version.minor}', pre_ok=current_version.is_prerelease) if latest_version > current_version: root = f"Python-{latest_version}" url = f"https://www.python.org/ftp/python/{latest_version.major}.{latest_version.minor}.{latest_version.micro}" _sha256(f"{url}/{root}.tgz") lines[i] = lines[i].replace(version, str(latest_version)) build_env.write_text("\n".join(lines) + "\n") message = f"Bump CPython {current_version} → {latest_version}" print(message) subprocess.check_call(["git", "commit", "-am", message]) break
def _update_cpython(dry_run): dockerfile = Path(__file__).parent / "docker" / "Dockerfile" lines = dockerfile.read_text().splitlines() re_ = re.compile(r"^RUN.*/build-cpython.sh (?P<version>.*)$") for i in range(len(lines)): match = re_.match(lines[i]) if match is None: continue current_version = Version(match["version"]) latest_version = latest( "python/cpython", major=f'{current_version.major}.{current_version.minor}', pre_ok=current_version.is_prerelease) if latest_version > current_version: root = f"Python-{latest_version}" url = f"https://www.python.org/ftp/python/{latest_version.major}.{latest_version.minor}.{latest_version.micro}" _sha256(f"{url}/{root}.tgz") lines[i] = lines[i].replace(match["version"], str(latest_version)) message = f"Bump CPython {current_version} → {latest_version}" print(message) if not dry_run: dockerfile.write_text("\n".join(lines) + "\n") subprocess.check_call(["git", "commit", "-am", message])
def _update_with_root(tool, dry_run): repo = { "autoconf": "autotools-mirror/autoconf", "automake": "autotools-mirror/automake", "libtool": "autotools-mirror/libtool", "git": "git/git", "swig": "swig/swig", "openssl": "openssl/openssl", } major = {"openssl": "1.1"} dockerfile = Path(__file__).parent / "docker" / "Dockerfile" lines = dockerfile.read_text().splitlines() re_ = re.compile( f"^RUN export {tool.upper()}_ROOT={tool}-(?P<version>\\S+) && \\\\$") for i in range(len(lines)): match = re_.match(lines[i]) if match is None: continue current_version = Version(match["version"], char_fix_required=tool == "openssl") latest_version = latest(repo[tool], major=major.get(tool, None)) if latest_version > current_version: root = f"{tool}-{latest_version}" url = re.match( f"^ export {tool.upper()}_DOWNLOAD_URL=(?P<url>\\S+) && \\\\$", lines[i + 2])["url"] url = url.replace(f"${{{tool.upper()}_ROOT}}", root) sha256 = _sha256(f"{url}/{root}.tar.gz") lines[i + 0] = f"RUN export {tool.upper()}_ROOT={root} && \\" lines[i + 1] = f" export {tool.upper()}_HASH={sha256} && \\" message = f"Bump {tool} {current_version} → {latest_version}" print(message) if not dry_run: dockerfile.write_text("\n".join(lines) + "\n") subprocess.check_call(["git", "commit", "-am", message]) break
def get_last_version(url): print(lastversion.latest(url))
for idx, line in enumerate(lines): if "cp[auto]" in line: lines[idx] = line.replace( "[auto]", "".join(str(v) for v in sys.version_info[:2]) ) for idx, line in enumerate(lines): if "version = [auto]" in line: lines[idx] = line.replace( "[auto]", ".".join(str(v) for v in sys.version_info[:3]) ) for idx, line in enumerate(lines): if "==[auto]" in line: name = line.split()[-1].split("==")[0] version = lastversion.latest(name, at="pip") lines[idx] = line.replace("[auto]", str(version)) with open("make_hydpy_installer.cfg", "w") as file_: file_.writelines(lines) wheeldir = "extra_wheel_sources" if os.path.exists(wheeldir): shutil.rmtree(wheeldir) os.makedirs(wheeldir) os.system(f"{sys.executable} -m pip wheel retrying --wheel-dir={wheeldir}") this_path = os.path.abspath(os.getcwd()) for folderpath in sys.path: if os.path.isdir(folderpath) and (os.path.abspath(folderpath) != this_path):