Skip to content

Commit 700d715

Browse files
committed
buildenv: add API to get output archive
There's still room to improve this. But it is better than what we had.
1 parent 5191971 commit 700d715

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

cpython-unix/build.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ def process_setup_line(line, variant=None):
423423
# Extension variants are denoted by the presence of
424424
# Modules/VARIANT-<extension>-<variant>.data files that describe the
425425
# extension. Find those files and process them.
426-
tf = build_env.get_archive("/build/out/python/build/Modules", as_tar=True)
426+
tf = build_env.get_output_archive("python/build/Modules", as_tar=True)
427427

428428
for ti in tf:
429429
basename = os.path.basename(ti.name)
@@ -639,7 +639,7 @@ def build_cpython(
639639
dest_path = BUILD / basename
640640

641641
with dest_path.open("wb") as fh:
642-
fh.write(build_env.get_archive("/build/out/python"))
642+
fh.write(build_env.get_output_archive("python"))
643643

644644

645645
def main():

pythonbuild/buildenv.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ def get_tools_archive(self, dest, name):
7070
with open(dest, "wb") as fh:
7171
fh.write(data)
7272

73-
def get_archive(self, path, as_tar=False):
74-
data = container_get_archive(self.container, path)
73+
def get_output_archive(self, path, as_tar=False):
74+
data = container_get_archive(self.container, "/build/out/%s" % path)
7575
data = io.BytesIO(data)
7676

7777
if as_tar:
@@ -151,6 +151,17 @@ def get_tools_archive(self, dest, name):
151151
with dest.open("wb") as fh:
152152
create_tar_from_directory(fh, self.td / "out" / "tools")
153153

154+
def get_output_archive(self, path, as_tar=False):
155+
data = io.BytesIO()
156+
create_tar_from_directory(data, self.td / "out" / path)
157+
158+
data.seek(0)
159+
160+
if as_tar:
161+
return tarfile.open(fileobj=data)
162+
else:
163+
return data.getvalue()
164+
154165
def find_output_files(self, base_path, pattern):
155166
base = str(self.td / "out" / base_path)
156167

0 commit comments

Comments
 (0)