From 2e4f6d555a249d81dc141a7f3cdd5f42f2e0f5ae Mon Sep 17 00:00:00 2001 From: Sam Yaple Date: Tue, 20 Sep 2022 11:36:46 -0400 Subject: [PATCH] Update fetch_wheels to add Accept header A private registry run from docker.io/registry:2 will use the Accept content type added. This allows private repos to work: WHEELS=192.168.1.50:5000/privateloci/requirements:ubuntu Also remove the simple distutils function we used ahead of its removal in python3.12 Change-Id: I7482e9097a7c0a5b332907c9e5849f2fe48af473 --- scripts/fetch_wheels.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/fetch_wheels.py b/scripts/fetch_wheels.py index b6969eb..46704f4 100755 --- a/scripts/fetch_wheels.py +++ b/scripts/fetch_wheels.py @@ -5,11 +5,11 @@ import os import platform import re import ssl -from distutils.util import strtobool from urllib import request as urllib2 DOCKER_REGISTRY='registry.hub.docker.com' +MANIFEST_V1 = 'application/vnd.oci.image.manifest.v1+json' MANIFEST_V2 = 'application/vnd.docker.distribution.manifest.v2+json' MANIFEST_V2_LIST = 'application/vnd.docker.distribution.manifest.list.v2+json' @@ -18,6 +18,10 @@ ARCH_MAP = { 'aarch64': 'arm64', } +# Clone from the now-deprecated distutils +def strtobool(v): + return str(v).lower() in ("yes", "true", "t", "1") + def registry_urlopen(r): if strtobool(os.environ.get('REGISTRY_INSECURE', "False")): resp = urllib2.urlopen(r, context=ssl._create_unverified_context()) @@ -52,7 +56,7 @@ def registry_request(r, token=None): def get_sha(repo, tag, registry, protocol): headers = { - 'Accept': ', '.join([MANIFEST_V2_LIST, MANIFEST_V2]) + 'Accept': ', '.join([MANIFEST_V2_LIST, MANIFEST_V2, MANIFEST_V1]) } url = "{}://{}/v2/{}/manifests/{}".format(protocol, registry, repo, tag) print(url)