Wagon Archiver

1.0.3 · active · verified Fri Apr 17

Wagon is a Python library and command-line tool designed to create self-contained Python Wheel-based archives. It bundles packages along with their dependencies into 'wagons' (files with a .wgn extension), simplifying their distribution and offline installation. The current stable version is 1.0.3, with an irregular release cadence focusing on stability and broader compatibility.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to programmatically create a .wgn archive for a specified package (e.g., 'requests') using the `wagon.create` function. It creates the wagon in a temporary directory and then cleans up.

import os
import tempfile
import shutil
from wagon import create

# Define the package to create a wagon for
package_name = "requests"

# Create a temporary directory for the output wagon file
output_dir = tempfile.mkdtemp()

try:
    print(f"Creating wagon for '{package_name}' in '{output_dir}'...")
    # The 'create' function returns the path to the generated .wgn file
    created_wagon_path = create(
        source=package_name,
        output_path=output_dir,
        version=None, # Automatically fetches the latest version
        pip_args=None # Pass additional pip arguments if needed, e.g., ['--no-deps']
    )
    print(f"Wagon created successfully: {created_wagon_path}")
    print(f"You can now install it using: wagon install {created_wagon_path}")
except Exception as e:
    print(f"An error occurred during wagon creation: {e}")
finally:
    # Clean up the temporary directory
    print(f"Cleaning up temporary directory: {output_dir}")
    shutil.rmtree(output_dir)

view raw JSON →