Skip to main content

A toolset for distributing Python projects in a convenient way.

Project description

Python Distribution Tools

Installation

Note: the Python Distribution Tools require Python 3.9 or newer to run. But of course, the tools can translate code for older Python versions.

Recommended: Use pipx

# find your Python 3.9 binary and use that one for the following commands
python --version
python3 --version
python3.9 --version

# install pipx to be able to run pypi packages directly
python -m pip install pipx

# run pdistx
pipx run pdistx vendor --help
pipx run pdistx variant --help
pipx run pdistx pack --help

# in case pipx is not in the path, you can run it as module
python -m pipx run pdistx vendor --help
python -m pipx run pdistx variant --help
python -m pipx run pdistx pack --help

Alternative: Install pdistx and use it directly

# find your Python 3.9 binary and use that one for the following commands
python --version
python3 --version
python3.9 --version

# install pdistx
python -m pip install pdistx

# run pdistx
pvendor --help
pvariant --help
ppack --help

# in case pdistx is not in the path, you can run it as module
python -m pvendor --help
python -m pvariant --help
python -m ppack --help

Python Vendoring Tool

Vendor libraries in a subpackage, which can be placed anywhere in a project.

$ pvendor --help
$ pdistx vendor --help

usage: pvendor [-h] [-r requirements] [-s source] [-p pip] [-k keep] [-z zip] target

positional arguments:
  target           target folder (will be cleared, except for the ones to be kept)

optional arguments:
  -h, --help       show this help message and exit
  -r requirements  install packages from requirements.txt
  -s source        copy modules from source folder
  -p pip           pip command (defaults to pip)
  -k keep          files or folders to be kept in the target folder (defaults to requirements.txt and .gitignore)
  -z zip           zip file path (target becomes relative path within zip file)

Python Variant Exporter

Export a specific variant from a codebase.

$ pvariant --help
$ pdistx variant --help

usage: pvariant [-h] [-d name[:type]=value] [-f filter] [-z zip] source target

positional arguments:
  source                source path
  target                target path (will be cleared)

optional arguments:
  -h, --help            show this help message and exit
  -d name[:type]=value  define variables to be replaced, e.g. -d __VARIANT__=PRO -d __LICENSE_CHECK__:bool=True
  -f filter             defines files and folders to be filtered out (glob pattern)
  -z zip                zip file path (target becomes relative path within zip file)

Python Packer Tool

Pack a Python package into a single Python file.

$ ppack --help
$ pdistx pack --help

usage: ppack [-h] [-r] [-m] [-f filter] [-z zip] source target

positional arguments:
  source      source package path
  target      target python (will be cleared)

optional arguments:
  -h, --help  show this help message and exit
  -r          create a resources folder with all non-python files (it will be named <target>_resources and be cleared)
  -m          use __main__.py of the package as bootstrap code (default is to use the root __init__.py of the package)
  -f filter   defines files and folders to be filtered out (glob pattern)
  -z zip      zip file path (target becomes relative path within zip file)

Examples

Blender Addon

# vendor packages
pvendor examples/blender_addon/vendor

# generate PRO as zip
pvariant \
    -d __VARIANT__=PRO                 \
    -f '**/free.bip'                   \
    -z $HOME/Desktop/blender_addon.zip \
    examples/blender_addon             \
    blender_addon

# generate FREE as folder
pvariant \
    -d __VARIANT__=FREE    \
    -f '**/pro.bip'        \
    examples/blender_addon \
    $HOME/.config/blender/2.93/scripts/addons/blender_addon

# pack addon as single file
ppack \
    -r \
    -f 'vendor/requirements.txt' -f 'vendor/.gitignore' \
    examples/blender_addon \
    $HOME/.config/blender/2.93/scripts/addons/blender_addon.py

QT App

# vendor packages
pvendor examples/qt_app/vendor

# pack app as single file
ppack \
    -r \
    -f 'vendor/requirements.txt' -f 'vendor/.gitignore' \
    -m \
    examples/qt_app \
    $HOME/Desktop/qt_app.py

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

pdistx-0.2.10.tar.gz (25.2 kB view details)

Uploaded Source

Built Distribution

pdistx-0.2.10-py3-none-any.whl (31.6 kB view details)

Uploaded Python 3

File details

Details for the file pdistx-0.2.10.tar.gz.

File metadata

  • Download URL: pdistx-0.2.10.tar.gz
  • Upload date:
  • Size: 25.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.8.10

File hashes

Hashes for pdistx-0.2.10.tar.gz
Algorithm Hash digest
SHA256 1b2a4e0acd4f7cb3ce917ee8cce7d6f1e8cc479c8431e27504b8554e46dfd00d
MD5 6b5506ba2a16671e11e77118fbb0c7f5
BLAKE2b-256 7fa571b767a660c8ea0dbe48fb46c00c2976b390bffb256022135011ceb43cc7

See more details on using hashes here.

File details

Details for the file pdistx-0.2.10-py3-none-any.whl.

File metadata

  • Download URL: pdistx-0.2.10-py3-none-any.whl
  • Upload date:
  • Size: 31.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.8.10

File hashes

Hashes for pdistx-0.2.10-py3-none-any.whl
Algorithm Hash digest
SHA256 e94bb57306ce41189051328f872c2b3ecf26d673d1031d9e54bac61a5e4dd60d
MD5 240fb1ff0443eb7d4810e2f673e67729
BLAKE2b-256 e1ae796fb5cb3a846e66a677da260098b6575e6652f2a29992cbc72ea8d4f124

See more details on using hashes here.

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