Skip to content

Commit 18348f5

Browse files
committed
use distlib inside the zipapp docker image
1 parent a0a7347 commit 18348f5

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

testing/zipapp/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ubuntu:focal
1+
FROM ubuntu:jammy
22
RUN : \
33
&& apt-get update \
44
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
@@ -11,4 +11,4 @@ RUN : \
1111
ENV LANG=C.UTF-8 PATH=/venv/bin:$PATH
1212
RUN : \
1313
&& python3 -mvenv /venv \
14-
&& pip install --no-cache-dir pip setuptools wheel no-manylinux --upgrade
14+
&& pip install --no-cache-dir pip distlib no-manylinux --upgrade

testing/zipapp/make

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ from __future__ import annotations
44
import argparse
55
import base64
66
import hashlib
7-
import importlib.resources
87
import io
98
import os.path
109
import shutil
@@ -42,10 +41,17 @@ def _add_shim(dest: str) -> None:
4241
with zipfile.ZipFile(bio, 'w') as zipf:
4342
zipf.write(shim, arcname='__main__.py')
4443

45-
with open(os.path.join(dest, 'python.exe'), 'wb') as f:
46-
f.write(importlib.resources.read_binary('distlib', 't32.exe'))
47-
f.write(b'#!py.exe -3\n')
48-
f.write(bio.getvalue())
44+
with tempfile.TemporaryDirectory() as tmpdir:
45+
_exit_if_retv(
46+
'podman', 'run', '--rm', '--volume', f'{tmpdir}:/out:rw', IMG,
47+
'cp', '/venv/lib/python3.10/site-packages/distlib/t32.exe', '/out',
48+
)
49+
50+
with open(os.path.join(dest, 'python.exe'), 'wb') as f:
51+
with open(os.path.join(tmpdir, 't32.exe'), 'rb') as t32:
52+
f.write(t32.read())
53+
f.write(b'#!py.exe -3\n')
54+
f.write(bio.getvalue())
4955

5056

5157
def _write_cache_key(version: str, wheeldir: str, dest: str) -> None:

0 commit comments

Comments
 (0)