Man Page

PyArmor is a command line tool used to obfuscate python scripts, bindobfuscated scripts to fixed machine or expire obfuscated scripts.

The syntax of thepyarmor command is:

pyarmor<command>[options]

The most commonly used pyarmor commands are:

obfuscateObfuscatepythonscriptslicensesGeneratenewlicensesforobfuscatedscriptspackObfuscatescriptsthenpackthemtoonebundlehdinfoShowhardwareinformation

The commands for project:

initCreateaprojecttomanageobfuscatedscriptsconfigUpdateprojectsettingsbuildObfuscateallthescriptsintheprojectinfoShowprojectinformationcheckCheckconsistencyofproject

The other commands:

benchmarkRunbenchmarktestincurrentmachineregisterMakeregistrationfileworkdownloadDownloadplatform-dependentdynamiclibrariesruntimeGenerateruntimepackageseparately

Seepyarmor <command> -h for more information on a specific command.

Note

From v5.7.1, the first character is command alias for most usage commands:

obfuscate,licenses,pack,init,config,build

For example:

pyarmoro=>pyarmorobfuscate

Common Options

-v,--versionShow version information
-q,--silentSuppress all normal output
-d,--debugPrint exception traceback and debugging message
--homePATHSelect home path, generally for multiple registerred pyarmor
--bootPLATIDSet boot platform, only for special usage

These options can be used afterpyarmor, before sub-command. For example,print debug information to locate the error:

pyarmor-dobfuscatefoo.py

Do not print log in the console:

pyarmor--silentobfuscatefoo.py

Obfuscate scripts with another purchased license:

pyarmor--home~/.pyarmor-2registerpyarmor-keyfile-2.zippyarmor--home~/.pyarmor-2obfuscatefoo.py

obfuscate

Obfuscate python scripts.

SYNOPSIS:

pyarmorobfuscate<options>SCRIPT...

OPTIONS

-O,--outputPATH
 Output path, default isdist
-r,--recursive
 Search scripts in recursive mode
-s,--srcPATHSpecify source path if entry script is not in the top most path
--excludePATHExclude the path in recusrive mode. Multiple paths are allowed, separated by “,”, or use this option multiple times
--exactOnly obfuscate list scripts
--no-bootstrapDo not insert bootstrap code to entry script
--bootstrap<0,1,2,3>
 How to insert bootstrap code to entry script
--no-cross-protection
 Do not insert protection code to entry script
--pluginNAMEInsert extra code to entry script, it could be used multiple times
--platformNAME
 Distribute obfuscated scripts to other platform
--advanced<0,1,2,3,4>
 Enable advanced mode1, super mode2, vm mode3 and4
--restrict<0,1,2,3,4>
 Set restrict mode
-n,--no-runtime
 DO NOT generate runtime files
--runtimePATHUse prebuilt runtime package
--package-runtime<0,1>
 Save the runtime files as package or not
--enable-suffix
 Generate the runtime package with unique name
--obf-mod<0,1,2>
 Disable or enable to obfuscate module
--obf-code<0,1,2>
 Disable or enable to obfuscate function
--wrap-mode<0,1>
 Disable or enable wrap mode
--with-licenseFILENAME
 Use this licese, special valueouter means no license
--cross-protectionFILENAME
 Specify customized protection script
--mix-strObfuscate the string value

DESCRIPTION

PyArmor first checks whetherGlobal Capsule exists in theHOMEpath. If not, make it.

Then find all the scripts to be obfuscated. There are 3 modes to search thescripts:

  • Normal: find all the.py files in the same path of entry script
  • Recursive: find all the.py files in the path of entry script recursively
  • Exact: only these scripts list in the command line

The default mode isNormal, option--recursive and--exact enable thecorresponding mode.

Note that only the.py files are touched by this command, all the other filesaren’t copied to output path. If there are many data files in the package, firstcopy the whole package to the output path, then obfuscate the.py files, thusall the.py files in the output path are overwritten by the obfuscated ones.

If there is an entry script, PyArmor will modify it, insert cross protectioncode into the entry script. Refer toSpecial Handling of Entry Script

If there is any plugin specified in the command line, PyArmor will scan all thesource scripts and inject the plugin code into them before obfuscating. Refer toHow to Deal With Plugins

Next obfuscate all found scripts, save them in the default output pathdist.

After that make theRuntime Package in thedist path.

Finally insert theBootstrap Code into entry script.

Option--src used to specify source path if entry script is not in the topmost path. For example:

# if no option --src, the "./mysite" is the source pathpyarmorobfuscate--src"."--recursivemysite/wsgi.py

Option--plugin is used to extend license type of obfuscated scripts, itwill inject the content of plugin script into the obfuscated scripts. Thecorresponding filename of plugin isNAME.py. More information about plugin,refer toHow to Deal With Plugins, and here is a real example to showusage of pluginUsing Plugin to Extend License Type

Option--platform is used to specify the target platform of obfuscatedscripts if target platform is different from build platform. Use this optionmultiple times if the obfuscated scripts are being to run many platforms. Fromv5.7.5, the platform names are standardized, commanddownload could list allthe available platform names.

Option--restrict is used to set restrict mode,Restrict Mode

Option--advanced is used to enable some advanced features to improve thesecurity. The available value for this option

For usage of option--runtime, refer to commandruntime

RUNTIME FILES

IfSuper Mode is enabled, there is only one extension module:

pytransform.pyd/.so

For all the others, the runtime files will be saved in the separated folderpytransform as package:

pytransform/__init__.py_pytransform.so/.dll/.dylib

But if--package-runtime is0, they will be saved in the same path withobfuscated scripts as four separated files:

pytransform.py_pytransform.so/.dll/.dylib

If the option--enable-suffix is set, the runtime package or module namewill bepytransform_xxx, herexxx is unique suffix based on theregistration code of PyArmor.

BOOTSTRAP CODE

IfSuper Mode is enabled, all the obfuscated scripts will import theruntime module at the first line, this is super modeBootstrap Code:

frompytransformimportpyarmor

For non-super mode, the followingBootstrap Code will be inserted intothe entry script only:

frompytransformimportpyarmor_runtimepyarmor_runtime()

If the entry script is__init__.py, theBootstrap Code will make arelative import by using leading dots like this:

from.pytransformimportpyarmor_runtimepyarmor_runtime()

But the option--bootstrap is set to2, theBootstrap Code alwaysmakes absolute import without leading dots. If it is set to3, theBootstrap Code always makes relative import with leading dots.

If the option--enable-suffix is set, the bootstrap code may like this:

frompytransform_vax_000001importpyarmor_runtimepyarmor_runtime(suffix='vax_000001')

If--no-bootstrap is set, or--bootstrap is0, then no bootstrap codewill be inserted into the entry scripts.

EXAMPLES

  • Obfuscate all the.py only in the current path:

    pyarmorobfuscatefoo.py
  • Obfuscate all the.py only in the current path and multiple entry scripts:

    pyarmorobfuscatefoo.pyfoo-svr.pyfoo-client.py
  • Obfuscate all the.py in the current path recursively:

    pyarmorobfuscate--recursivefoo.py
  • Obfuscate all the.py in the current path recursively, but entry script notin top most path:

    pyarmorobfuscate--src"."--recursivemysite/wsgi.py
  • Obfuscate a scriptfoo.py only, no runtime files:

    pyarmorobfuscate--no-runtime--exactfoo.py
  • Obfuscate all the.py in a path recursive, no entry script, no generateruntime package:

    pyarmorobfuscate--recursive--no-runtime.pyarmorobfuscate--recursive--no-runtimesrc/
  • Obfuscate all the.py in the current path recursively, exclude allthe.py in the pathbuild andtests:

    pyarmorobfuscate--recursive--excludebuild,testsfoo.pypyarmorobfuscate--recursive--excludebuild--excludetestsfoo.py
  • Obfuscate only two scriptsfoo.py,moda.py exactly:

    pyarmorobfuscate--exactfoo.pymoda.py
  • Obfuscate all the.py file in the pathmypkg/:

    pyarmorobfuscate--outputdist/mypkgmypkg/__init__.py
  • Obfuscate all the.py files in the current path, but do not insertcross protection code into obfuscated scriptdist/foo.py:

    pyarmorobfuscate--no-cross-protectionfoo.py
  • Obfuscate all the.py files in the current path, but do not insertbootstrap code at the beginning of obfuscated scriptdist/foo.py:

    pyarmorobfuscate--no-bootstrapfoo.py
  • Insert the content ofcheck_ntp_time.py intofoo.py, thenobfuscatingfoo.py:

    pyarmorobfuscate--plugincheck_ntp_timefoo.py
  • Only pluginassert_armored is called then inject it into thefoo.py:

    pyarmorobfuscate--plugin@assert_armoredfoo.py
  • If the scriptfoo.py includes internal plugin, obfuscate it with specialplugin nameon:

    pyarmorobfuscate--pluginonfoo.py
  • Obfuscate the scripts in Macos and run obfuscated scripts in Ubuntu:

    pyarmorobfuscate--platformlinux.x86_64foo.py
  • Obfuscate the scripts in advanced mode:

    pyarmorobfuscate--advanced1foo.py
  • Obfuscate the scripts with restrict mode 2:

    pyarmorobfuscate--restrict2foo.py
  • Obfuscate all the.py files in the current path except__init__.py withrestrice mode 4:

    pyarmorobfuscate--restrict4--exclude__init__.py--recursive.
  • Obfuscate a package with unique runtime package name:

    cd/path/to/mypkgpyarmorobfuscate-r--enable-suffix--outputdist/mypkg__init__.py
  • Obfuscate scripts by super mode with expired license:

    pyarmorlicenses-e2020-10-05regcode-01pyarmorobfuscate--with-licenselicenses/regcode-01/license.lic \--advanced2foo.py
  • Obfuscate scripts by super mode with customized cross protection scripts, anddon’t embed license file to extension module, but use outerlicense.lic:

    pyarmorobfuscate--cross-protectionbuild/pytransform_protection.py \--with-licenseouter--advanced2foo.py
  • Use prebuilt runtime package to obfuscate scripts:

    pyarmorruntime--advanced2--with-licenseouter-Omyruntime-1pyarmorobfuscate--runtimemyruntime-1--with-licenselicenses/r001/license.licfoo.pypyarmorobfuscate--runtime@myruntime-1--exactfoo-2.pyfoo-3.py

licenses

Generate new licenses for obfuscated scripts.

SYNOPSIS:

pyarmorlicenses<options>CODE

OPTIONS

-O,--outputOUTPUT
 Output path,stdout is supported
-e,--expiredYYYY-MM-DD
 Expired date for this license
-d,--bind-diskSN
 Bind license to serial number of harddisk
-4,--bind-ipv4IPV4
 Bind license to ipv4 addr
-m,--bind-macMACADDR
 Bind license to mac addr
-x,--bind-dataDATA
 Pass extra data to license, used to extend license type
--disable-restrict-mode
 Disable all the restrict modes
--enable-period-mode
 Check license per hour when the obfuscated script is running
--fixedKEYBind license to Python interpreter

DESCRIPTION

In order to run obfuscated scripts, it’s necessarey to hava alicense.lic. Asobfuscating the scripts, there is a defaultlicense.lic created at the sametime. In this license the obfuscated scripts can run on any machine and neverexpired.

This command is used to generate new licenses for obfuscated scripts. Forexample:

pyarmorlicenses--expired2019-10-10mycode

An expired license will be generated in the default output path plus code namelicenses/mycode, then overwrite the old one in the same path of obfuscatedscript:

cplicenses/mycode/license.licdist/pytransform/

Since v6.3.0, thelicense.lic has been embedded into binary libraries bydefault, so the copy mode doesn’t work. Instead of using option--with-license when obfuscating the scripts, for example:

pyarmorobfuscate--with-licenselicenses/mycode/license.licfoo.py

If you prefer the tradional way, refer toHow to use outer license file

Another example, bind obfuscated scripts to mac address and expired on2019-10-10:

pyarmorlicenses--expired2019-10-10--bind-macf8:ff:c2:27:00:7fr001

Before this, run commandhdinfo to get hardware information:

pyarmorhdinfoHardwareinformationsgotbyPyArmor:Serialnumberoffirstharddisk:"FV994730S6LLF07AY"DefaultMacaddress:"f8:ff:c2:27:00:7f"Ipaddress:"192.168.121.100"

If there are many network cards in the machine, pyarmor only checks the defaultmac address which is printed by commandhdinfo. For example:

pyarmorlicenses--bind-mac"f8:ff:c2:27:00:7f"r002

If binding to other network card, wrap the mac address with angle brackets. Forexample:

pyarmorlicenses--bind-mac"<2a:33:50:46:8f>"r002

It’s possible to bind all of mac addresses or some of them in same machine, forexample:

pyarmorlicenses--bind-mac"<2a:33:50:46:8f,f0:28:69:c0:24:3a>"r003

In Linux, it’s possible to bind mac address with ifname, for example:

pyarmorlicenses--bind-mac"eth1/fa:33:50:46:8f:3d"r004

If there are many hard disks in the machine, pyarmor only checks the defaulthard disk which is printed by commandhdinfo. For example:

pyarmorlicenses--bind-disk"FV994730S6LLF07AY"r005

For binding other hard disk card, specify a name for it. For example:

# In Windows, bind to the first, the second diskpyarmorlicenses--bind-disk"/0:FV994730S6LLF07AY"r006pyarmorlicenses--bind-disk"/1:KDX3298FS6P5AX380"r007# In Linux, bind to "/dev/vda2"pyarmorlicenses--bind-disk"/dev/vda2:KDX3298FS6P5AX380"r008

By option-x any data could be saved into the license file, it’s mainly usedto extend license type. For example:

pyarmorlicenses-x"2019-02-15"r005

In the obfuscated scripts, the data passed by-x could be got by this way:

frompytransfromimportget_license_infoinfo=get_license_info()print(info['DATA'])

It also could output the license key in the stdout other than a file:

pyarmor--silentlicenses--outputstdout-x"2019-05-20"reg-0001

By option--fixed, the license could be bind to Python interpreter. Forexample, use special key1 to bind the license to current Python interpreter:

pyarmorlicenses--fixed1

It also could bind the license to many Python interpreters by passing multiplekeys separated by comma:

pyarmorlicenses--fixed4265050,5386060

How to get bind key of Python interpreter, refer toBinding obfuscated scripts to Python interpreter

Do not use this feature in 32-bit Windows, because the bind key is different indifferent machine, it may be changed even if python is restarted in the samemachine.

Note

Here is a real exampleUsing Plugin to Extend License Type

pack

Obfuscate the scripts or project and pack them into one bundle.

SYNOPSIS:

pyarmorpack<options>SCRIPT|PROJECT

OPTIONS

-O,--outputPATH
 Directory to put final built distributions in.
-e,--optionsOPTIONS
 Pass these extra options topyinstaller
-x,--xoptionsOPTIONS
 Pass these extra options topyarmor obfuscate
-sFILEUse external .spec file to pack the scripts
--without-license
 Do not generate license for obfuscated scripts
--with-licenseFILE
 Use this license file other than default one
--cleanRemove cached files before packing
--debugDo not remove build files after packing
--nameName to assign to the bundled (default: the script’s basename)

DESCRIPTION

The commandpack first callsPyInstaller to generate.spec file whichname is same as entry script. The options specified by--e will be pass toPyInstaller to generate.spec file. It could be any option accepted byPyInstaller except-y,--noconfirm,-n,--name,--distpath,--specpath.

If there is in trouble, make sure the script could be bundled byPyInstallerdirectly. For example:

pyinstallerfoo.py

So long asPyInstaller could work, just pass those options by-e, thecommandpack should work either.

Thenpack will obfuscates all the.py files in the same path of entryscript recursively. It will call commandobfuscate with options-r,--output,--package-runtime0 and the options specified by-x. However if packing a project,pack will obfuscate the project bycommandbuild with option-B, and all the options specifed by-x willbe ignored. In this case config the project to control how to obfuscate thescripts.

Nextpack patches the.spec file so that the original scripts could bereplaced with the obfuscated ones.

Finallypack callPyInstaller with this pacthed.spec file to generatethe output bundle with obfuscated scripts. Refer toHow To Pack Obfuscated Scripts.

If the option--debug is set, for example:

pyarmorpack--debugfoo.py

The following generated files will be kept, generally all of them are removedafter packing end:

foo.specfoo-patched.specdist/obf/temp/hook-pytransform.pydist/obf/*.py# All the obfuscated scripts

The patchedfoo-patched.spec could be used by pyinstaller to pack theobfuscated scripts directly, for example:

pyinstaller-y--cleanfoo-patched.spec

If some scripts are modified, just obfuscate them again, then run this commandto pack them quickly. All the options for commandobfuscate could be got fromthe output of commandpack.

If you’d like to change the final bundle name, specify the option--namedirectly, do not pass it by the option-e, it need some special handling.

If you have a worked.spec file, just specify it by option-s (in thiscase the option-e will be ignored), for example:

pyarmorpack-sfoo.specfoo.py

The main script (here it’sfoo.py) must be list in the command line, otherwisepack doesn’t know where to find the scripts to be obfuscated. More refer toBundle obfuscated scripts with customized spec file

If there are many data files or hidden imports, it’s better to write a hook fileto find them easily. For example, create a hook file namedhook-sys.py:

fromPyInstaller.utils.hooksimportcollect_data_files,collect_alldatas,binaries,hiddenimports=collect_all('my_module_name')datas+=collect_data_files('submodule')hiddenimports+=['_gdbm','socket','h5py.defs']datas+=[('/usr/share/icons/education_*.png','icons')]

Then callpack with extra option--additional-hooks-dir. to tellpyinstaller find the hook in the current path:

pyarmorpack-e" --additional-hooks-dir ."foo.py

More information about pyinstaller hook, refer tohttps://pyinstaller.readthedocs.io/en/stable/hooks.html#understanding-pyinstaller-hooks

When something is wrong, turn on PyArmor debug flag to print traceback:

pyarmor-dpack...

Important

For option-e and-x, it need an extra whitespace in option value,otherwise it will complain oferror: unrecognized arguments. For exmaple:

# Wrong, no heading whitespace before --advanced 2pyarmorpack-x"--advanced 2"...# Rightpyarmorpack-x" --advanced 2"...

EXAMPLES

  • Obfuscatefoo.py and pack them into the bundledist/foo:

    pyarmorpackfoo.py
  • Remove the build folder, and start a clean pack:

    pyarmorpack--cleanfoo.py
  • Pack the obfuscated scripts by an existsmyfoo.spec:

    pyarmorpack-smyfoo.specfoo.py
  • Pass extra options to runPyInstaller:

    pyarmorpack-e" -w --icon app.ico"foo.pypyarmorpack-e" --icon images\\app.ico"foo.py
  • Pass extra options to obfuscate scripts:

    pyarmorpack-x" --exclude venv --exclude test"foo.py
  • Pack the obfuscated script to one file and in advanced mode:

    pyarmorpack-e" --onefile"-x" --advanced 1"foo.py
  • Pack the obfuscated scripts and expired on 2020-12-25:

    pyarmorlicenses-e2020-12-25cy2020pyarmorpack--with-licenselicenses/cy2020/license.licfoo.py
  • Change the final bundle name tomy_app other thanfoo:

    pyarmorpack--namemy_appfoo.py
  • Pack a project with advanced mode:

    pyarmorinit--entrymain.pypyarmorconfig--advanced1pyarmorpack.

Note

Since v5.9.0, possible pack one project directly by specify the project pathin the command line. For example, create a project in the current path, thenpack it:

pyarmorinit--entrymain.pypyarmorpack.

By this way the obfuscated scripts could be fully controlled.

Note

In Windows, use double black splash in extra options. For example:

pyarmorpack-e" --icon images\\app.ico"foo.py

Note

For option-e and-x, pass an extra leading whitespace to avoidcommand line error:

pyarmorpack-e" --onefile"-x" --advanced 2"foo.py

Important

The commandpack will obfuscate the entry script automatically, DO NOTobfuscate the entry script before pack.

By default the commandpack obfuscates all the.py files only in theentry script’s path recursively. It won’t obfuscate all the dependencies outof this path.

hdinfo

Show hardware information of this machine, such as serial number of hard disk,mac address of network card etc. The information got here could be as input datato generate license file for obfuscated scripts.

SYNOPSIS:

pyarmorhdinfo

Without argument, this command displays all available hardware information.

In Windows, it also supports to query named hard disk, for example, get serialnumber from the first and third hard disk:

pyarmorhdinfo/0/2

In Linux, query named hard disk or network card, for example:

pyarmorhdinfo/dev/vda2pyarmorhdinfoeth2

Ifpyarmor isn’t installed, downlad this toolhdinfo

And run it directly:

hdinfo

It will print the same hardware information aspyarmor hdinfo

init

Create a project to manage obfuscated scripts.

SYNOPSIS:

pyarmorinit<options>PATH

OPTIONS

-t,--type<auto,app,pkg>
 Project type, default value isauto
-s,--srcSRCBase path of python scripts, default is current path
-e,--entryENTRY
 Entry script of this project

DESCRIPTION

This command will create a project in the specifyPATH, and a file.pyarmor_config will be created at the same time, which is projectconfiguration of JSON format.

If the option--type is set toauto, which is the default value, theproject type will set topkg if the entry script is__init__.py, otherwisetoapp.

Theinit command will setis_package to1 if the new project is configuredaspkg, otherwise it’s set to0.

After project is created, use commandconfig to change the project settings.

EXAMPLES

  • Create a project in the current path:

    pyarmorinit--entryfoo.py
  • Create a project in the build pathobf:

    pyarmorinit--entryfoo.pyobf
  • Create a project for package:

    pyarmorinit--entry__init__.py
  • Create a project in the pathobf, manage the scripts in the path/path/to/src:

    pyarmorinit--src/path/to/src--entryfoo.pyobf

config

Update project settings.

SYNOPSIS:

pyarmorconfig<options>[PATH]

OPTIONS

--nameNAMEProject name
--titleTITLEProject title
--srcSRCProject src, base path for matching scripts
--outputPATHOutput path for obfuscated scripts
--manifestTEMPLATE
 Manifest template string
--entrySCRIPTEntry script of this project
--is-package<0,1>
 Set project as package or not
--restrict<0,1,2,3,4>
 Set restrict mode
--obf-mod<0,1,2>
 Disable or enable to obfuscate module
--obf-code<0,1,2>
 Disable or enable to obfuscate function
--wrap-mode<0,1>
 Disable or enable wrap mode
--advanced<0,1,2,3,4>
 Enable advanced mode1, super mode2, vm mode3 or4
--cross-protection<0,1>
 Disable or enable to insert cross protection code into entry script,it also could be a filename to specify customized protection script
--rpathRPATHSet the path of runtime files in target machine
--pluginNAMEInsert extra code to entry script, it could be used multiple times
--package-runtime<0,1>
 Save the runtime files as package or not
--bootstrap<0,1,2,3>
 How to insert bootstrap code to entry script
--enable-suffix<0,1>
 Generate the runtime package with unique name
--with-licenseFILENAME
 Use this license file, special valueouter means no license
--mixinNAMEAvailable mixinstr, used to obfuscate string value

DESCRIPTION

Run this command in project path to change project settings:

pyarmorconfig--optionnew-value

Or specify the project path at the end:

pyarmorconfig--optionnew-value/path/to/project

Option--manifest is comma-separated list of manifest template command, sameas MANIFEST.in of Python Distutils.

Option--entry is comma-separated list of entry scripts, relative to srcpath of project.

If option--plugin is set to empty string, all the plugins will be removed.

For the details of each option, refer toProject Configuration File

EXAMPLES

  • Change project name and title:

    pyarmorconfig--name"project-1"--title"My PyArmor Project"
  • Change project entries:

    pyarmorconfig--entryfoo.py,hello.py
  • Exclude pathbuild anddist, do not search.py file from thesepaths:

    pyarmorconfig--manifest"global-include *.py, prune build, prune dist"
  • Copy all the.json files in the src path to output path:

    pyarmorconfig--manifest"include *.py, include *.json"
  • Obfuscate script with wrap mode off:

    pyarmorconfig--wrap-mode0
  • Obfuscate all string value in the scripts:

    pyarmorconfig--mixinstr# Restore default value, no obfuscating stringspyarmorconfig--mixin''
  • Set plugin for entry script. The content ofcheck_ntp_time.py willbe insert into entry script as building project:

    pyarmorconfig--plugincheck_ntp_time
  • Remove all plugins:

    pyarmorconfig--plugin''

build

Build project, obfuscate all scripts in the project.

SYNOPSIS:

pyarmorconfig<options>[PATH]

OPTIONS

-B,--forceForce to obfuscate all scripts
-r,--only-runtime
 Generate extra runtime files only
-n,--no-runtime
 DO NOT generate runtime files
-O,--outputOUTPUT
 Output path, override project configuration
--platformNAME
 Distribute obfuscated scripts to other platform
--package-runtime<0,1>
 Save the runtime files as package or not
--runtimePATHUse prebuilt runtime package

DESCRIPTION

Run this command in project path:

pyarmorbuild

Or specify the project path at the end:

pyarmorbuild/path/to/project

The option--no-runtime may impact on theBootstrap Code, thebootstrap code will make absolute import without leading dots in entry script.

About option--platform and--package-runtime, refer to commandobfuscate

About option--runtime, refer to commandruntime

EXAMPLES

  • Only obfuscate the scripts which have been changed since lastbuild:

    pyarmorbuild
  • Force build all the scripts:

    pyarmorbuild-B
  • Generate runtime files only, do not try to obfuscate any script:

    pyarmorbuild-r
  • Obfuscate the scripts only, do not generate runtime files:

    pyarmorbuild-n
  • Save the obfuscated scripts to other path, it doesn’t change theoutput path of project settings:

    pyarmorbuild-B-O/path/to/other
  • Build project in Macos and run obfuscated scripts in Ubuntu:

    pyarmorbuild-B--platformlinux.x86_64

info

Show project information.

SYNOPSIS:

pyarmorinfo[PATH]

DESCRIPTION

Run this command in project path:

pyarmorinfo

Or specify the project path at the end:

pyarmorinfo/path/to/project

check

Check consistency of project.

SYNOPSIS:

pyarmorcheck[PATH]

DESCRIPTION

Run this command in project path:

pyarmorcheck

Or specify the project path at the end:

pyarmorcheck/path/to/project

benchmark

Check the performance of obfuscated scripts.

SYNOPSIS:

pyarmorbenchmark<options>

OPTIONS:

-m,--obf-mod<0,1,2>
 Whether to obfuscate the whole module
-c,--obf-code<0,1,2>
 Whether to obfuscate each function
-w,--wrap-mode<0,1>
 Whether to obfuscate each function with wrap mode
-a,--advanced<0,1,2,3,4>
 Set advanced mode, super mode and vm mode
--debugDo not remove test path

DESCRIPTION

This command will generate a test script, obfuscate it and run it, then outputthe elapsed time to initialize, import obfuscated module, run obfuscatedfunctions etc.

EXAMPLES

  • Test performance with default mode:

    pyarmorbenchmark
  • Test performance with no wrap mode:

    pyarmorbenchmark--wrap-mode0
  • Check the test scripts which saved in the path.benchtest:

    pyarmorbenchmark--debug

register

Make registration keyfile effect, or show registration information.

SYNOPSIS:

pyarmorregister[KEYFILE]

DESCRIPTION

This command is used to register the purchased key file or code fileto take it effects:

pyarmorregister/path/to/pyarmor-regfile-1.zippyarmorregister/path/to/pyarmor-keycode-1.txt

Show registration information:

pyarmorregister

Purchase one registration code:

pyarmorregister--buy

download

List and download platform-dependent dynamic libraries.

SYNOPSIS:

pyarmordownload<options>NAME

OPTIONS:

--help-platform
 Display all available standard platform names
-L,--listFILTER
 List available dynamic libraries in different platforms
-O,--outputPATH
 Save downloaded library to this path
--updateUpdate all the downloaded dynamic libraries

DESCRIPTION

This command mainly used to download available dynamic libraries for crossplatform.

List all available standard platform names. For examples:

pyarmordownloadpyarmordownload--help-platformpyarmordownload--help-platformwindowspyarmordownload--help-platformlinux.x86_64

Then download one from the list. For example:

pyarmordownloadlinux.armv7pyarmordownloadlinux.x86_64

By default the download file will be saved in the path~/.pyarmor/platformswith different platform names.

Option--list could filter the platform by name, arch, features, and displaythe information in details. For examples:

pyarmordownload--listpyarmordownload--listwindowspyarmordownload--listwindows.x86_64pyarmordownload--listJITpyarmordownload--listarmv7

Afterpyarmor is upgraded, however these downloaded dynamic libraries won’t beupgraded. The option--update could be used to update all these downloadedfiles. For example:

pyarmordownload--update

runtime

GeneateRuntime Package separately.

SYNOPSIS:

pyarmorruntime<options>

OPTIONS:

-O,--outputPATH
 Output path, default isdist
-n,--no-package
 Generate runtime files without package
-i,--insideGenerate bootstrap script which is used inside one package
-L,--with-licenseFILE
 Replace default license with this file, special valueouter meansno license
--platformNAME
 Generate runtime package for specified platform
--enable-suffix
 Generate the runtime package with unique name
--advanced<0,1,2,3,4>
 Generate advanced runtime package

DESCRIPTION

This command is used to generate the runtime package separately.

TheRuntime Package could be shared if the scripts are obufscated by sameGlobal Capsule. So generate it once, then need not generate the runtimefiles when obfuscating the scripts later.

It also generates a bootstrap scriptpytransform_bootstrap.py in the outputpath. This script is obfuscated from an empty script, and there isBootstrap Code in it. It’s mainly used to runBootstrap Code inthe plain script. For example, once it’s imported, all the other obfuscatedmodules could be imported in one plain script:

importpytransform_bootstrapimportobf_foo

If option--inside is specified, it will generate bootstrap packagepytransform_bootstrap other than one single script.

The option--advanced is used to generate advanced runtime package, forexample,Super Mode etc.

About option--platform and--enable-suffix, refer to commandobfuscate

Since v6.2.0, it also generates protection scriptpytransform_protection.py,which is used to patch entry scripts. Refer toCustomizing cross protection code

Since v6.3.7, the runtime package will remember the option–advanced,–platform,–enable-suffix, and save them to cross protection scriptpytransform_protection.py as leading comment. The advantage is whenobfuscating the scripts with option--runtime, it could get these settingsautomatically and use the same cross protection script. For example:

pyarmorruntime--platformlinux.armv7--enable-suffix--advanced1-Omyruntime-1pyarmorobfuscate--runtimemyruntime-1foo.py

The second command is same as:

pyarmorobfuscate--platformlinux.armv7--enable-suffix--advanced1foo.py

With a leading@ in the runtime path, it will not copy any runtime file, butread the settings of runtime package. It’s useful if there are multiple entryscripts need to be obufscated. For example:

pyarmorobfuscate--runtime@myruntime-1--exactfoo-2.pyfoo-3.py

For project, set option--runtime for commandbuild. For example:

pyarmorbuild--runtime@myruntime-1

EXAMPLES

  • GenerateRuntime Packagepytransform in the default pathdist:

    pyarmorruntime
  • Not generate a package, but four separate filesRuntime Files:

    pyarmorruntime-n
  • Generate bootstrap packagedist/pytransform_boostrap:

    pyarmorruntime-i
  • GenerateRuntime Package for platformarmv7 with expired license:

    pyarmorlicenses--expired2020-01-01code-001pyarmorruntime--with-licenselicenses/code-001/license.lic--platformlinux.armv7
  • Generate runtime module for super mode:

    pyarmorruntime--advanced2
  • Generate runtime module for super mode but with outer license:

    pyarmorruntime--advanced2--with-licenseouter