XAR - eXecutable ARchive packaging toolchain

raw JSON →
20.12.2 verified Mon Apr 27 auth: no python maintenance

XAR is a toolchain for packaging Python applications into self-contained executables (XAR files). It creates a single-file, executable archive that bundles all dependencies and runs with the system Python. The current version is 20.12.2, released in December 2020. The project appears to be in maintenance mode with infrequent releases.

pip install xar
error ModuleNotFoundError: No module named 'xar'
cause The xar package is not installed.
fix
Install with: pip install xar
error OSError: Unable to run XAR file: not a valid XAR archive
cause The XAR file was corrupted or not created correctly.
fix
Recreate the XAR file using the XarFile API. Ensure all dependencies are included.
error AttributeError: module 'xar' has no attribute 'XarFile'
cause Incorrect import: importing xar instead of using from xar import XarFile.
fix
Use: from xar import XarFile
gotcha XAR files require Python 3.5+ on Linux or macOS. They do not work on Windows.
fix Ensure deployment targets are Linux or macOS with Python 3.5+.
gotcha The XAR format does not support cross-platform execution. Archives built on Linux will not run on macOS or vice versa.
fix Build XAR files on the target platform.
deprecated The 'xar' command-line tool is deprecated. Use the Python API instead.
fix Use the Python API from xar import XarFile instead of the xar CLI.

Creates a XAR file from a Python script and a directory.

from xar import XarFile

# Create a XAR archive from a Python script
with XarFile('hello.xar', 'w') as xf:
    xf.add('hello.py')
    xf.add_directory('mylib')

# To run: python xar hello.xar