On this page
  1. zipapp.create_archive
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

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

REPL Inspect

from zipapp import create_archive
help(create_archive)

Linked from

Related notes