MCPcopy Index your code
hub / github.com/astral-sh/python-build-standalone / get_image

Function get_image

pythonbuild/docker.py:71–98  ·  view source on GitHub ↗
(
    client, source_dir: pathlib.Path, image_dir: pathlib.Path, name, host_platform
)

Source from the content-addressed store, hash-verified

69
70
71def get_image(
72 client, source_dir: pathlib.Path, image_dir: pathlib.Path, name, host_platform
73):
74 if client is None:
75 return None
76
77 image_name = f"image-{name}.{host_platform}"
78 image_path = image_dir / image_name
79 tar_path = image_path.with_suffix(".tar")
80
81 with image_path.open("r") as fh:
82 image_id = fh.read().strip()
83
84 try:
85 client.images.get(image_id)
86 return image_id
87 except docker.errors.ImageNotFound:
88 if tar_path.exists():
89 with tar_path.open("rb") as fh:
90 data = fh.read()
91 client.images.load(data)
92
93 return image_id
94
95 else:
96 return build_docker_image(
97 client, str(source_dir).encode(), image_dir, name, host_platform
98 )
99
100
101def copy_file_to_container(path, container, container_path, archive_path=None):

Callers 1

mainFunction · 0.90

Calls 1

build_docker_imageFunction · 0.85

Tested by

no test coverage detected