Skip to main content

Python Distribution Example

This repository accompanies this series of articles about developing a portable Python application that can be installed and run without any external dependencies.

This is useful for distributing Python applications to users without a Python environment, or for distributing a Python application via package managers.

Setup

These steps only need to be completed on first-time setup.

Install Dependencies

  • Python >=3.8, <3.13

Refer to release.yaml for platform-specific installer dependencies. The installer builds for Windows, Linux, and MacOS run on GitHub runners, so you don't need to install the requirements unless you are troubleshooting a platform-specific installer build script.

Clone this Repository

If you'd like to track your own changes in GitHub, then you should fork this repository, and then clone your fork.

git clone git@github.com:JPHutchins/python-distribution-example.git

Install the Python venv

  • change directory to the root of the cloned repository:
    cd python-distribution-example
    
  • create the venv
    python3 -m venv .venv
    
    or, if python points to your desired Python 3 version:
    python -m venv .venv
    

    The venv is installed to .venv After the venv is activated, python is the preferred alias to the Python installed in the venv

  • activate the development environment
    . ./envr.ps1
    

    envr will activate your venv

  • install Python dependencies to the venv, including the optional dev dependencies
    pip install --require-virtualenv -e .[dev]
    

    You must instruct users to run this step whenever the Python dependencies change.

Build

Make sure to complete the setup first.

Activate the Development Environment

This step is required before running or building the app.

. ./envr.ps1

Now you can run the app within the Python venv:

jpsapp --help

Build the sdist and wheel

python -m build

The build output is at dist/.

Build the Portable App for Your Host Platform

python -m distribution.portable

The build output is at dist/jpsapp-<version>-<platform>-<arch>, e.g. dist/jpsapp-1.0.0-windows-amd64, as well is in a ZIP archive of the same name.

Tools Used

  • GitHub Actions: automate the build and release of the application on GitHub runners.
  • envr: manage environment variables, PATH, and Python venv.
  • build: A simple, correct Python packaging build frontend.
  • PyInstaller: create a "one-dir" portable "executable" of the Python application
  • WiX v4: create a Windows installer, *.msi, that creates a double-clickable version of the app, adds the app to the system PATH, adds an app folder to the Start Menu, and optionally adds a shortcut to the desktop.
  • FPM: create *.deb and *.rpm Linux packages that install the app to /usr/share/ and add a symlink to /usr/bin/*.

Metadata

Release files for jpsapp 1.1.10

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

Source distribution (sdist)

Source distribution for jpsapp 1.1.10
File Size Uploaded
jpsapp-1.1.10.tar.gz 12.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for jpsapp 1.1.10
File Interpreter ABI Platform
jpsapp-1.1.10-py3-none-any.whl Python 3 none any Details

Total release size: 24.8 kB

Release files / jpsapp-1.1.10.tar.gz

Download URL jpsapp-1.1.10.tar.gz
Size 12.5 kB
Tags Source
SHA-256 checksum
How to use checksums
5ac13e32e628579b1d167cfa949f0cc38c0ac62d5b07598cf89fe359fbf671a6
BLAKE2b-256 checksum
How to use checksums
bf4a3d020c3dd6db96205728665d72ac6cfb158d24057d73b9aca85fe1e6c303
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.0 CPython/3.12.4

Release files / jpsapp-1.1.10-py3-none-any.whl

Download URL jpsapp-1.1.10-py3-none-any.whl
Size 12.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8a1b0ec448df7a5b080eabcd027ab62979ad62aa5e3593a6e0d34b8b46190816
BLAKE2b-256 checksum
How to use checksums
bbc94635ac17ce5f26aa8b3f6bacacdda63217e33812cbfc64bcee16206bb4c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.0 CPython/3.12.4

Release history Release notifications | RSS feed

This release

1.1.10 This release

2 release files

1.1.6

2 release files

1.1.5

2 release files

1.1.4

2 release files

1.1.3

2 release files

1.1.0

2 release files

1.0.1

2 release files

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