diff --git a/scripts/get_pypi_hashes.py b/scripts/get_pypi_hashes.py index aabe9ece0a..cd11312932 100755 --- a/scripts/get_pypi_hashes.py +++ b/scripts/get_pypi_hashes.py @@ -3,7 +3,7 @@ import argparse from pathlib import Path -def get_package_wheel_hashes(package, version): +def get_package_wheel_hashes(package, version, os): url = f"https://pypi.org/pypi/{package}/{version}/json" data = requests.get(url).json() @@ -12,7 +12,8 @@ def get_package_wheel_hashes(package, version): print(f" hashes:") for url in data["urls"]: - print(f" - sha256:{url['digests']['sha256']}") + if os is None or os in url["filename"]: + print(f" - sha256:{url['digests']['sha256']}") if __name__ == "__main__": @@ -20,5 +21,6 @@ if __name__ == "__main__": description="Display the hashes of the wheel files to be inserted in pip_requirements") parser.add_argument("package", type=Path, help="Name of the target package") parser.add_argument("version", type=Path, help="Version of the target package") + parser.add_argument('--os', type=str, help='Specific package OS', choices=['win', 'macosx', 'manylinux', 'musllinux']) args = parser.parse_args() - get_package_wheel_hashes(args.package, args.version) + get_package_wheel_hashes(args.package, args.version, args.os)