Skip to main content

A PDM plugin that packs your packages into a zipapp

Project description

pdm-packer

Tests pypi version Code style: black pre-commit.ci status pdm-managed

A PDM plugin that packs your packages into a zipapp

Requirements

pdm-packer requires Python >=3.7

Installation

On PDM 1.6.4+, you can install the plugin directly by:

$ pdm plugin add pdm-packer

If you have installed PDM with the recommended tool pipx, add this plugin by:

$ pipx inject pdm pdm-packer

Or if you have installed PDM with pip install --user pdm, install with pip to the user site:

$ python -m pip install --user pdm-packer

Otherwise, install pdm-packer to the same place where PDM is located.

Usage

$ pdm pack [common-options] [pack-options]

Common Options:

-h, --help

show this help message and exit

-v, --verbose

-v for detailed output and -vv for more detailed

-g, --global

Use the global project, supply the project root with -p option

-p PROJECT_PATH, --project PROJECT_PATH

Specify another path as the project root, which changes the base of pyproject.toml and __pypackages__

Pack Options:

-m MAIN, --main MAIN

Specify the console script entry point for the zipapp

-o OUTPUT, --output OUTPUT

Specify the output filename. By default the file name will be inferred from the project name.

-c, --compress

Compress files with the deflate method, no compress by default

--pyc, --compile

Compile source into pyc files

--no-py

Remove the .py files in favor of .pyc files

-i INTERPRETER, --interpreter INTERPRETER

The Python interpreter path, default: the project interpreter

--exe

Create an executable file. If the output file isn't given, the file name will end with .exe(Windows) or no suffix(Posix)

See also: https://docs.python.org/3.9/library/zipapp.html

Examples

# Create with default name(<project_name>.pyz) and console_script as the __main__.py
pdm pack
# Create an executable file
pdm pack --exe
# Create with custom __main__.py and filename
pdm pack -o app.pyz -m app:main

Caveats

  1. If the result zipapp contains binaries, it can only be deployed to the platforms with the same abi, any cross-abi usage of that app might expect a failure.
  2. Any console scripts except for what is given to --main will be lost.
  3. The .exe file is different from what is produced by pyinstaller in the way that it doesn't embed a Python interpreter. This means you have to install a Python with exactly the same version on the deployment platform.
  4. If you have code to run in your project, the project itself should be installed into __pypackages__ as well. Make sure you have set a project name in pyproject.toml.

About executable zipapp

By default, zipapp is created with .pyz suffix. On Windows, if you have associted .pyz files with Python program, you can run the app by double-clicking the file in the explorer. But if you create the app with --exe turn on, you can have a .exe file on Windows and an executable file on Unix-like systems, so that the app can be executed without a python command prefixing it and no matter you assoicated the file exensition properly or not.

Changelog

See CHANGELOG.md

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pdm-packer-0.2.1.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

pdm_packer-0.2.1-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file pdm-packer-0.2.1.tar.gz.

File metadata

  • Download URL: pdm-packer-0.2.1.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.11

File hashes

Hashes for pdm-packer-0.2.1.tar.gz
Algorithm Hash digest
SHA256 2dc6597304e3dbee06b009b00e991eb2c56484f4cdfac23acc10b435efe3866d
MD5 6969b58e5f1372de4fb03d0491ac0f89
BLAKE2b-256 f12581a9ac9512db9e6567e153e09d23483180c578efc0972f37f97d31eb42aa

See more details on using hashes here.

Provenance

File details

Details for the file pdm_packer-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: pdm_packer-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.11

File hashes

Hashes for pdm_packer-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 73324c05773e344e7e2c9d8d1c615ae991e0bed3f3e1e9ff5c29609b04839a3c
MD5 be22288991a3d086e195ab0d6d5d0ad5
BLAKE2b-256 c0fe11a19e34c66d179db2fcf7b169c8ee2e2c7f41e0fffafe012e430d91d234

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page