Skip to content

Commit e7d4c1d

Browse files
committed
unix: tweak archive retrieval again
Hopefully this is the final time. With this change, we can now build a working distribution for macOS! The differences of the PYTHON.json are minimal.
1 parent c9383c2 commit e7d4c1d

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

cpython-unix/build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ def build_cpython(
651651
dest_path = BUILD / basename
652652

653653
with dest_path.open("wb") as fh:
654-
fh.write(build_env.get_output_archive())
654+
fh.write(build_env.get_output_archive("python"))
655655

656656

657657
def main():

pythonbuild/buildenv.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,11 @@ def get_tools_archive(self, dest, name):
155155
with dest.open("wb") as fh:
156156
create_tar_from_directory(fh, self.td / "out" / "tools")
157157

158-
def get_output_archive(self, path=None, as_tar=False):
159-
p = self.td / "out"
160-
if path:
161-
p = p / path
158+
def get_output_archive(self, path, as_tar=False):
159+
p = self.td / "out" / path
162160

163161
data = io.BytesIO()
164-
create_tar_from_directory(data, p)
162+
create_tar_from_directory(data, p, path_prefix=p.parts[-1])
165163

166164
data.seek(0)
167165

pythonbuild/utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,16 @@ def download_entry(key: str, dest_path: pathlib.Path, local_name=None) -> pathli
147147
return local_path
148148

149149

150-
def create_tar_from_directory(fh, base_path: pathlib.Path):
150+
def create_tar_from_directory(fh, base_path: pathlib.Path, path_prefix=None):
151151
with tarfile.open(name="", mode="w", fileobj=fh, dereference=True) as tf:
152152
for root, dirs, files in os.walk(base_path):
153153
dirs.sort()
154154

155155
for f in sorted(files):
156156
full = base_path / root / f
157157
rel = full.relative_to(base_path)
158+
if path_prefix:
159+
rel = pathlib.Path(path_prefix) / rel
158160
tf.add(full, rel)
159161

160162

0 commit comments

Comments
 (0)