def analyse_global_requirement_pins(): """Check a package list file for updates on PyPI or on upper constraints""" parser = argparse.ArgumentParser() parser.add_argument( "--requirements_sha", help="Sha used for fetching the upper constraints file in requirements", ) parser.add_argument( "--file", help="path to global requirements pin file", default="global-requirement-pins.txt", ) args = parser.parse_args() with open(args.file, "r") as global_req_file: pins = { pin.name: pin.specs for pin in releasing.parse_requirements(global_req_file.read()) } latest_versions = releasing.get_pypi_versions(pins.keys()) if not args.requirements_sha: sha = releasing.discover_requirements_sha() else: sha = args.requirements_sha constraints_versions = { pin.name: pin.specs for pin in releasing.parse_upper_constraints(sha) } releasing.print_requirements_state(pins, latest_versions, constraints_versions)
def test_print_requirements_state_in_uc(capsys): pins = {"pip": [("==", "18.0")]} latest_versions = {"pip": "18.0"} constraints_versions = {"pip": [("==", "30.3.0")]} releasing.print_requirements_state(pins, latest_versions, constraints_versions) out, err = capsys.readouterr() reftable = PrettyTable([ "Package", "Current Version Spec", "Latest version on PyPI", "Constrained to" ]) reftable.add_row(["pip", "== 18.0", "18.0", "[('==', '30.3.0')]"]) print(reftable) out2, err2 = capsys.readouterr() assert out == out2 assert err == err2 assert err == ""
def analyse_global_requirement_pins(global_ctx, **kwargs): """ Check a package list file for updates on PyPI or in upper constraints """ debug = global_ctx["debug"] pins = { pin.name: pin.specs for pin in releasing.parse_requirements(kwargs["file"]) } if debug: print(pins) latest_versions = releasing.get_pypi_versions(pins.keys()) if not kwargs["requirements_sha"]: sha = releasing.discover_requirements_sha() else: sha = kwargs["requirements_sha"] constraints_versions = { pin.name: pin.specs for pin in releasing.parse_upper_constraints(sha) } releasing.print_requirements_state(pins, latest_versions, constraints_versions)