A command-line tool for obfuscating Python scripts, binding obfuscated scripts to specific machines, and setting expiration dates
—
PyArmor provides both modern streamlined commands and legacy full-featured commands for comprehensive script obfuscation and management. The CLI is the primary interface for most users, offering intuitive commands for obfuscation, configuration, and license management.
Main obfuscation command supporting script obfuscation, runtime generation, and key creation with extensive customization options.
# Generate obfuscated scripts
pyarmor gen [options] <scripts>
# Generate runtime key only
pyarmor gen key [options]
# Generate runtime package only
pyarmor gen runtime [options]
# Common options:
# -O, --output PATH Output directory (default: dist)
# -r, --recursive Search scripts recursively
# --exclude PATTERN Exclude files/paths matching pattern
# --obf-module {0,1} Module obfuscation (default: 1)
# --obf-code {0,1,2} Code obfuscation (default: 1)
# --no-wrap Disable wrap mode
# --mix-str Protect string constants
# --enable {jit,bcc,rft,themida} Advanced protection features
# --private Private mode for scripts
# --restrict Restrict mode for packages
# --platform NAME Cross-platform obfuscation
# --pack {onefile,onedir} Pack with PyInstaller
# --use-runtime PATH Use existing runtime package
# --outer Enable outer runtime key
# -e, --expired DATE Set expiration date (YYYY-MM-DD)
# --period N Check runtime key every N days
# -b, --bind-device DEV Bind to hardware device
# --bind-data STRING Store user data in runtime keyManage PyArmor configuration settings at global, local, and project levels with hierarchical inheritance and interactive editing.
# Show all configuration options
pyarmor cfg
# Show specific option value
pyarmor cfg OPTION
# Set option value
pyarmor cfg OPTION=VALUE
# Configuration options:
# -p NAME Private settings for module/package
# -g, --global Global settings (default: local)
# -r, --reset Reset option to default value
# --encoding ENCODING Configuration file encodingHandle PyArmor license registration, upgrades, and device management for commercial usage and advanced features.
# Show current license information
pyarmor reg
# Register new license
pyarmor reg [options] <regfile>
# Registration options:
# -p, --product NAME Bind license to product name
# -u, --upgrade Upgrade old PyArmor license
# -g, --device ID Device ID for group license (1-100)
# --buy Open purchase link in browser
# -C, --CI Request CI pipeline license
# -y, --confirm Skip confirmation promptsLaunch interactive PyArmor Man shell for learning, troubleshooting, and getting help with PyArmor features and workflows.
# Start interactive help system
pyarmor man
# Features:
# - Interactive tutorials and guides
# - Problem diagnosis and solutions
# - Command examples and templates
# - Bug reporting assistanceInitialize a PyArmor project in the current directory with default configuration and project structure.
# Initialize project in current directory
pyarmor init [options]
# Options:
# --src PATH Source directory (default: src)
# --output PATH Output directory (default: dist)
# --entry SCRIPT Entry script nameCheck and configure PyArmor environment settings, platform support, and system dependencies.
# Check environment status
pyarmor env
# Set environment variables
pyarmor env OPTION=VALUE
# Environment options:
# --check Validate environment setup
# --platform Show platform information
# --runtime Check runtime library statusBuild entire project by obfuscating all configured scripts with project-specific settings and options.
# Build project with current settings
pyarmor build [options]
# Options:
# --force Force rebuild all scripts
# --clean Clean output directory first
# --exclude PATTERN Additional exclusion patternsObfuscate scripts directly without creating a project, suitable for one-time obfuscation tasks.
# Basic obfuscation
pyarmor-7 obfuscate [options] <scripts>
# Advanced obfuscation options:
# --src PATH Source directory
# --entry SCRIPT Entry script
# --output PATH Output directory
# --recursive Recursive mode
# --exclude PATTERN Exclude patterns
# --exact Exact match mode
# --no-bootstrap Skip bootstrap code
# --no-cross-protection Disable cross protection
# --plugin NAME Load plugin
# --platform NAME Target platform
# --advanced {0,1,2,3,4,5} Advanced mode level
# --restrict {0,1,2,3} Restriction mode# Initialize new project
pyarmor-7 init [options] <name>
# Configure project
pyarmor-7 config [options] <project>
# Build project
pyarmor-7 build [options] <project>
# Show project information
pyarmor-7 info <project>
# Check project consistency
pyarmor-7 check <project>Generate license files with hardware binding, expiration dates, and custom restrictions.
# Generate license file
pyarmor-7 licenses [options] <code>
# License options:
# --output PATH Output directory
# --expired DATE Expiration date
# --bind-disk SERIAL Bind to disk serial number
# --bind-mac ADDR Bind to MAC address
# --bind-ipv4 ADDR Bind to IPv4 address
# --bind-domain NAME Bind to domain name
# --enable-period-mode Enable periodic checkingPackage obfuscated scripts with PyInstaller, py2exe, cx_Freeze, or py2app for distribution.
# Pack with PyInstaller
pyarmor-7 pack [options] <script>
# Packaging options:
# --type {auto,pyinstaller,py2exe,cx_Freeze,py2app}
# --options "OPTS" Additional packer options
# --clean Clean temporary files
# --debug Enable debug modeDisplay hardware information for device binding configuration and license generation.
# Show all hardware information
pyarmor-7 hdinfo
# Show specific hardware info
pyarmor-7 hdinfo --disk
pyarmor-7 hdinfo --mac
pyarmor-7 hdinfo --ipv4
pyarmor-7 hdinfo --domainDownload platform-specific runtime libraries for cross-platform obfuscation support.
# Download platform libraries
pyarmor-7 download <platform>
# List available platforms
pyarmor-7 download --list
# Update platform index
pyarmor-7 download --updateRun performance benchmarks to measure obfuscation overhead and optimization effectiveness.
# Run benchmark tests
pyarmor-7 benchmark [options]
# Benchmark options:
# --timeout SECONDS Test timeout
# --debug Verbose output
# --mode {1,2,3,4,5} Protection mode# Simple obfuscation
pyarmor gen hello.py
# Recursive obfuscation with string protection
pyarmor gen --recursive --mix-str src/
# Cross-platform obfuscation
pyarmor gen --platform linux.x86_64,windows.x86_64 src/# Maximum protection with hardware binding
pyarmor gen --enable bcc --enable rft --bind-device "00:11:22:33:44:55" \
--expired "2024-12-31" --private src/
# Themida protection (Windows only)
pyarmor gen --enable themida --restrict src/# Initialize and configure project
pyarmor init --src myapp --entry main.py
pyarmor cfg obf_code=2
pyarmor cfg mix_str=1
# Build project
pyarmor build# Register PyArmor license
pyarmor reg -p "MyProduct" pyarmor-regcode-xxxx.txt
# Generate restricted licenses
pyarmor-7 licenses --expired 2024-12-31 --bind-mac "00:11:22:33:44:55" \
MYAPP-001# Pack with PyInstaller
pyarmor gen --pack onefile main.py
# Legacy packing
pyarmor-7 pack --type pyinstaller --options "--noconsole" main.pyclass Commander:
"""
Modern CLI command architecture and management system.
"""
def init_parser(self, subparsers) -> None:
"""
Initialize project command parser.
Args:
subparsers: Argument parser subparsers object
"""
def env_parser(self, subparsers) -> None:
"""
Initialize environment command parser.
Args:
subparsers: Argument parser subparsers object
"""
def build_parser(self, subparsers) -> None:
"""
Initialize build command parser.
Args:
subparsers: Argument parser subparsers object
"""Install with Tessl CLI
npx tessl i tessl/pypi-pyarmor