Skip to content
PyArmorDEMO

Chapter 04

PyArmor Setup

⏱ 5 minutes · You will check the PyArmor version, read its license status, and learn which features the free trial includes.

PyArmor is already installed

uv sync installed PyArmor from the protect dependency group in pyproject.toml:

TOML
[dependency-groups]
# The obfuscator. Needed on the build machine only, never in the runtime image.
protect = ["pyarmor==9.2.7"]

It is a separate group on purpose: PyArmor is a build tool. The machine that runs the protected app never needs it. (PyArmor's own docs say the same: do not install it on the target device.)

Installing it on its own, anywhere else:

Terminal
pip install pyarmor==9.2.7

Check the version

Terminal
uv run pyarmor --version

What it does: prints the PyArmor version and the license it runs under. Why: PyArmor's command line changed a lot between major versions, so always know which one you have. This workshop was written and tested with 9.2.7. Expected:

Output
Pyarmor 9.2.7 (trial), 000000, non-profits

License Type    : pyarmor-trial
License No.     : pyarmor-vax-000000
...
BCC Mode        : No
RFT Mode        : No
CI/CD Mode      : No

Notes
* Can't obfuscate big script and mix str

The commands you will use

Terminal
uv run pyarmor gen --help

What it does: shows the options of pyarmor gen, the command that generates protected scripts and their runtime. Why: almost everything in this workshop is one pyarmor gen call with different options. Expected: a usage line starting usage: pyarmor gen [-h] [-O PATH] ...

OptionMeaningChapter
-O PATHoutput folder (default dist/)05
-rrecurse into sub-packages05
--exclude PATTERNleave paths out05
-iput the runtime inside the package06
-e DATE / -e DAYSexpire the build06
-b DEVbind the build to a device06
--pack onedir|onefilebundle with PyInstaller08

Version-sensitive commands

The trial, and licensing

The trial never expires and covers everything in this workshop. Its limits, from PyArmor's license page and our own tests:

TrialPaid licenses
Obfuscate scripts and packages, runtime, expiry, device binding, PyInstaller packing✓✓
Big scripts (a module above a certain size)✗ out of licenseBasic and above
--mix-str (protect string constants)✗Basic and above
BCC mode (compile functions to C), RFT mode (rename names)✗Pro, Group, CI
CI/CD pipelines, local Docker builds✓ (fewer than 100 runs a month)depends on the plan

How big is "big"? PyArmor does not publish the threshold. In our tests on 9.2.7, a module with 30 realistic functions passed, and one with 200 tiny functions failed. The limit depends on the compiled code, not on the file size in bytes. That is one reason this app is split into small, focused modules (which is good design anyway).

If you have a license, register it on the build machine with pyarmor reg <regfile>. In CI, store the registration file as an encrypted secret, never in the repository (chapter 12).