mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
use distlib inside the zipapp docker image
This commit is contained in:
parent
a0a734750e
commit
18348f5d0d
2 changed files with 13 additions and 7 deletions
|
|
@ -4,7 +4,6 @@ from __future__ import annotations
|
|||
import argparse
|
||||
import base64
|
||||
import hashlib
|
||||
import importlib.resources
|
||||
import io
|
||||
import os.path
|
||||
import shutil
|
||||
|
|
@ -42,10 +41,17 @@ def _add_shim(dest: str) -> None:
|
|||
with zipfile.ZipFile(bio, 'w') as zipf:
|
||||
zipf.write(shim, arcname='__main__.py')
|
||||
|
||||
with open(os.path.join(dest, 'python.exe'), 'wb') as f:
|
||||
f.write(importlib.resources.read_binary('distlib', 't32.exe'))
|
||||
f.write(b'#!py.exe -3\n')
|
||||
f.write(bio.getvalue())
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
_exit_if_retv(
|
||||
'podman', 'run', '--rm', '--volume', f'{tmpdir}:/out:rw', IMG,
|
||||
'cp', '/venv/lib/python3.10/site-packages/distlib/t32.exe', '/out',
|
||||
)
|
||||
|
||||
with open(os.path.join(dest, 'python.exe'), 'wb') as f:
|
||||
with open(os.path.join(tmpdir, 't32.exe'), 'rb') as t32:
|
||||
f.write(t32.read())
|
||||
f.write(b'#!py.exe -3\n')
|
||||
f.write(bio.getvalue())
|
||||
|
||||
|
||||
def _write_cache_key(version: str, wheeldir: str, dest: str) -> None:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue