On this page
zipapp.create_archive
Up: zipapp | Next: zipapp.get_interpreter
Rel: zipapp.get_interpreter, zipapp.ZipAppError
Ref: docs.python.org — zipapp.create_archive
Tags: #public #python3 #stdlib #zipapp
Import
import zipapp
from zipapp import create_archive
Signature & Overview
zipapp.create_archive(source, target=None, interpreter=None, main=None, filter=None, compressed=False)
Create an application archive from SOURCE.
Usage
from pathlib import Path
import tempfile, zipapp
with tempfile.TemporaryDirectory() as tmp:
src = Path(tmp) / 'app'
src.mkdir()
(src / '__main__.py').write_text('print("ok")\n', encoding='utf-8')
out = Path(tmp) / 'app.pyz'
zipapp.create_archive(src, target=out, interpreter='/usr/bin/env python3')
assert out.exists() and zipapp.get_interpreter(out) == '/usr/bin/env python3'
Gotchas
- Pure Python only: Cannot bundle native C extensions (
.so/.pyd) inside.pyzarchives.
REPL Inspect
from zipapp import create_archive
help(create_archive)
Linked from
Related notes
- tuts/python3/stdlib_module/zipapp/get_interpreter Linked here; links to this page; shared tags: #stdlib, #zipapp
- tuts/python3/stdlib_module/zipapp/ZipAppError Linked here; links to this page; shared tags: #stdlib, #zipapp
- tuts/python3/stdlib_module/zipapp Linked here; links to this page; shared tags: #stdlib
- tuts/c/stdlib shared tags: #stdlib
- tuts/c/stdlib/assert shared tags: #stdlib
- tuts/c/stdlib/assert/assert shared tags: #stdlib
- tuts/c/stdlib/assert/static_assert shared tags: #stdlib
- tuts/c/stdlib/ctype shared tags: #stdlib
- tuts/c/stdlib/ctype/isalpha shared tags: #stdlib
- tuts/c/stdlib/ctype/isdigit shared tags: #stdlib