Skip to main content

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 works with Python >=3.9 and PDM >=2.19

Installation

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

Metadata

Release files for pdm-packer 0.8.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pdm-packer 0.8.2
File Size Uploaded Provenance Actions
pdm_packer-0.8.2.tar.gz 9.0 kB Without provenance Details for pdm_packer-0.8.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pdm-packer 0.8.2
File Interpreter ABI Platform Actions
pdm_packer-0.8.2-py3-none-any.whl Python 3 none any Details for pdm_packer-0.8.2-py3-none-any.whl

Total release size: 16.2 kB

Release files / pdm_packer-0.8.2.tar.gz

Download URL pdm_packer-0.8.2.tar.gz
Size 9.0 kB
Tags Source
SHA-256 checksum
How to use checksums
a0eec5aa9e3d2cee35a24ee8afadc405dc08377d29d3e78dad24636599234485
BLAKE2b-256 checksum
How to use checksums
c669814597da1d7f3ef4d9c72c737e690b215fc76d37b5eeac02cab31f22eb8b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release files / pdm_packer-0.8.2-py3-none-any.whl

Download URL pdm_packer-0.8.2-py3-none-any.whl
Size 7.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1e362f0e3cd4eec92b2c236dd3eda982735b1ba6d1ce6a455a134db7553fb340
BLAKE2b-256 checksum
How to use checksums
408e2b8eb7dfe69a68587c6fed39f8a6abc96841ba7e84b486fcfe8e2b22f28e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Security for pdm-packer 0.8.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page