Example #1
0
def update_python_versions():
    install.ensure_python(PYMAIN)  # ensures pyenv is installed
    pyenv_dir = os.path.expanduser("~/.cache/hypothesis-build-runtimes/pyenv")
    subprocess.run("git pull", shell=True, cwd=pyenv_dir)
    result = subprocess.run(
        pyenv_dir + "/bin/pyenv install --list", shell=True, stdout=subprocess.PIPE
    ).stdout.decode()
    # pyenv reports available versions in chronological order, so we keep the newest
    # *unless* our current ends with a digit (is stable) and the candidate does not.
    digits = tuple("0123456789")
    best = {}
    for line in map(str.strip, result.splitlines()):
        m = re.match(r"(?:pypy)?3\.\d+", line)
        if m:
            key = m.group()
            if key.endswith(digits) or not best.get(key, key).endswith(digits):
                best[key] = line
    print(best)
    thisfile = pathlib.Path(__file__)
    before = after = thisfile.read_text()
    for key, version in best.items():
        var = key.upper().replace(".", "")
        after = re.sub(rf'({var} = .*?"){key}[^"]+', rf"\g<1>{version}", after)
    if before != after:
        thisfile.write_text(after)
Example #2
0
def update_python_versions():
    install.ensure_python(PYMAIN)  # ensures pyenv is installed and up to date
    cmd = "~/.cache/hypothesis-build-runtimes/pyenv/bin/pyenv install --list"
    result = subprocess.run(cmd, shell=True, stdout=subprocess.PIPE).stdout.decode()
    # pyenv reports available versions in chronological order, so we keep the newest
    # *unless* our current ends with a digit (is stable) and the candidate does not.
    digits = tuple("0123456789")
    best = {}
    for line in map(str.strip, result.splitlines()):
        m = re.match(r"(?:pypy)?3\.(?:[6-9]|\d\d)", line)
        if m:
            key = m.group()
            if key.endswith(digits) or not best.get(key, key).endswith(digits):
                best[key] = line
    print(best)
    thisfile = pathlib.Path(__file__)
    before = after = thisfile.read_text()
    for key, version in best.items():
        var = key.upper().replace(".", "")
        after = re.sub(rf'({var} = .*?"){key}[^"]+', rf"\g<1>{version}", after)
    if before != after:
        thisfile.write_text(after)

    # Automatically sync PYMAIN with the version in build.sh
    build_sh = pathlib.Path(tools.ROOT) / "build.sh"
    sh_before = build_sh.read_text()
    new_pymain = re.search(r'PYMAIN = "(3\.\d\d?\.\d\d?)"', after).group(1)
    sh_after = re.sub(r"3\.\d\d?\.\d\d?", new_pymain, sh_before)
    if sh_before != sh_after:
        build_sh.unlink()  # so bash doesn't reload a modified file
        build_sh.write_text(sh_after)
Example #3
0
def update_python_versions():
    install.ensure_python(PYMAIN)  # ensures pyenv is installed and up to date
    cmd = "~/.cache/hypothesis-build-runtimes/pyenv/bin/pyenv install --list"
    result = subprocess.run(cmd, shell=True, stdout=subprocess.PIPE).stdout.decode()
    # pyenv reports available versions in chronological order, so we keep the newest
    # *unless* our current ends with a digit (is stable) and the candidate does not.
    stable = re.compile(r".*3\.\d+.\d+$")
    best = {}
    for line in map(str.strip, result.splitlines()):
        if m := re.match(r"(?:pypy)?3\.(?:[6-9]|\d\d)", line):
            key = m.group()
            if stable.match(line) or not stable.match(best.get(key, line)):
                best[key] = line