def test_reversion(tmp_path: Path) -> None: # Download an input whl. name_template = "virtualenv-{}-py2.py3-none-any.whl" input_name = name_template.format("15.1.0") url = ("https://files.pythonhosted.org/packages/6f/86/" "3dc328ee7b1a6419ebfac7896d882fba83c48e3561d22ddddf38294d3e83/{}". format(input_name)) input_whl_file = tmp_path / input_name with input_whl_file.open(mode="wb") as f: shutil.copyfileobj(requests.get(url, stream=True).raw, f) # Rewrite it. output_version = "9.1.9" output_name = name_template.format(output_version) output_whl_file = tmp_path / output_name reversion( whl_file=input_whl_file.as_posix(), dest_dir=tmp_path.as_posix(), target_version=output_version, ) assert output_whl_file.is_file() is True # Confirm that it can be consumed. output_pex_file = tmp_path / "out.pex" pex_main.main([ "--disable-cache", "-o", output_pex_file.as_posix(), output_whl_file.as_posix() ]) assert output_pex_file.is_file() is True
def test_reversion() -> None: with temporary_dir() as dest_dir: # Download an input whl. name_template = "virtualenv-{}-py2.py3-none-any.whl" input_name = name_template.format("15.1.0") url = ( "https://files.pythonhosted.org/packages/6f/86/" "3dc328ee7b1a6419ebfac7896d882fba83c48e3561d22ddddf38294d3e83/{}". format(input_name)) input_whl_file = os.path.join(dest_dir, input_name) with open(input_whl_file, "wb") as f: shutil.copyfileobj(requests.get(url, stream=True).raw, f) # Rewrite it. output_version = "9.1.9" output_name = name_template.format(output_version) output_whl_file = os.path.join(dest_dir, output_name) reversion(whl_file=input_whl_file, dest_dir=dest_dir, target_version=output_version) assert os.path.isfile(output_whl_file) is True # Confirm that it can be consumed. output_pex_file = os.path.join(dest_dir, "out.pex") pex_main.main( ["--disable-cache", "-o", output_pex_file, output_whl_file]) assert os.path.isfile(output_pex_file) is True
def reversion_prebuilt_wheels() -> None: # First, rewrite to manylinux. See https://www.python.org/dev/peps/pep-0599/. We build on # Centos7, so use manylinux2014. source_platform = "linux_x86_64" dest_platform = "manylinux2014_x86_64" unstable_wheel_dir = CONSTANTS.deploy_pants_wheel_dir / CONSTANTS.pants_unstable_version for whl in unstable_wheel_dir.glob(f"*{source_platform}.whl"): whl.rename(str(whl).replace(source_platform, dest_platform)) # Now, reversion to use the STABLE_VERSION. stable_wheel_dir = CONSTANTS.deploy_pants_wheel_dir / CONSTANTS.pants_stable_version stable_wheel_dir.mkdir(parents=True, exist_ok=True) for whl in unstable_wheel_dir.glob("*.whl"): reversion( whl_file=str(whl), dest_dir=str(stable_wheel_dir), target_version=CONSTANTS.pants_stable_version, extra_globs=["pants/VERSION"], )