GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — pythonVSCode/python_files/download_get_pip.py at main · zashed/pythonVSCode Expand file tree/ Copy pathdownload_get_pip.pyMore file actions 59 lines (48 loc) · 2.07 KB / Copy pathdownload_get_pip.pyFile metadata and controls59 lines (48 loc) · 2.07 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. import json import os import pathlib import urllib.request as url_lib from packaging.version import parse as version_parser EXTENSION_ROOT = pathlib.Path(__file__).parent.parent GET_PIP_DEST = EXTENSION_ROOT / "python_files" PIP_PACKAGE = "pip" PIP_VERSION = "latest" # Can be "latest", or specific version "23.1.2" def _get_package_data(): json_uri = "https://pypi.org/pypi/{0}/json".format(PIP_PACKAGE) # Response format: https://warehouse.readthedocs.io/api-reference/json/#project # Release metadata format: https://github.com/pypa/interoperability-peps/blob/master/pep-0426-core-metadata.rst with url_lib.urlopen(json_uri) as response: return json.loads(response.read()) def _download_and_save(root, version): root = os.getcwd() if root is None or root == "." else root url = f"https://raw.githubusercontent.com/pypa/get-pip/{version}/public/get-pip.py" print(url) with url_lib.urlopen(url) as response: data = response.read() get_pip_file = pathlib.Path(root) / "get-pip.py" get_pip_file.write_bytes(data) def main(root): data = _get_package_data() if PIP_VERSION == "latest": # Pick latest 5 versions to try and get-pip sorted_versions = sorted(data["releases"].keys(), key=version_parser, reverse=True)[:5] downloaded = False while sorted_versions: use_version = sorted_versions.pop(0) try: print(f"Trying version: get-pip == {use_version}") _download_and_save(root, use_version) downloaded = True break except Exception as e: print(f"Failed to download get-pip == {use_version}: {e}") print(f"NExt attempt(s) with versions: {sorted_versions}") if not downloaded: raise Exception("Failed to download get-pip.py") else: use_version = PIP_VERSION _download_and_save(root, use_version) if __name__ == "__main__": main(GET_PIP_DEST) |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |