SAMARTH ENC
A Python build tool that chains multiple protection strategies — PyArmor bytecode encryption, Nuitka native compilation, or both — into one command. It auto-detects your environment and picks the strongest strategy that actually works there, rather than silently producing output that won't run.
Platform support
| Platform | Universal | PyArmor | Nuitka | Combined |
|---|---|---|---|---|
| Linux x86_64 | ✓ | ✓ | ✓ | ✓ |
| Linux ARM64 | ✓ | ✓ | ✓ | ✓ |
| Windows x86_64 | ✓ | ✓ | ✓ | ✓ |
| macOS x86_64/ARM64 | ✓ | ✓ | ✓ | ✓ |
| Termux (ARM64) | ✓ | ✓ (linux.aarch64) | ✓ (module only, Nuitka 2.6.7+) | ✗ |
| Pydroid 3 | ✓ | Experimental | ✗ | ✗ |
Notes:
- Nuitka standalone/onefile builds don't work reliably on Termux due to Android's dynamic linker not matching standard Linux assumptions.
- Pydroid has no accessible C compiler. PyArmor works experimentally there (its Android runtime is built for Termux/NDK Python, not Pydroid's own build — test before shipping).
- Cross-compiled artifacts are never portable. Build on the target device or
use PyArmor's
--platformflag for cross-compilation.
Install
pip install samarth
If you want PyArmor and/or Nuitka protection (not just Universal mode):
pip install pyarmor nuitka
Nuitka requires a C compiler:
# Debian/Ubuntu/VPS
sudo apt install build-essential patchelf
# Termux
pkg install clang patchelf
# Windows — Nuitka will offer to download MinGW64 on first run
# macOS
xcode-select --install
Termux-specific PyArmor fix (if you get a .so load error):
patchelf --add-needed libpython3.11.so.0.1 \
$(python -c "import pyarmor; print(__import__('pathlib').Path(pyarmor.__file__).parent)")/cli/core/android/aarch64/pytransform3.so
Replace 3.11 with your actual Python version.
Usage
Interactive menu
samarth
SAMARTH ENC
[1] Universal Python Build
[2] PyArmor Protection
[3] Native Compilation
[4] PyArmor + Nuitka
[5] Termux Build
[6] Pydroid Compatibility Build
[7] Automatic Platform Detection
[8] Compatibility Checker
[9] Dependency Checker
[10] Integrity Checker
[11] Debug Protected File
[12] Build Diagnostics
[0] Exit
CLI subcommands
samarth build app.py # auto-select best mode
samarth build app.py --mode pyarmor # specific mode
samarth build mypackage/ --mode combined --output dist/
samarth detect # show OS/arch/tool report
samarth check # show which modes work here
samarth deps # check tool availability
samarth integrity app.py <sha256-hash> # verify file hasn't changed
samarth debug dist/app.py # run and show stdout/stderr
samarth diagnostics samarth_output/ # print build manifest
Build modes
universal — copies source and precompiles .pyc. No external tools
needed. Works on every CPython 3.10–3.13 environment including Pydroid.
Provides no meaningful protection, just bytecode instead of source.
pyarmor — PyArmor bytecode encryption. Output requires the
pyarmor_runtime_* package at runtime. Supports cross-compilation via
--platform (see PyArmor docs). The only practical option for Pydroid and
the safer Termux choice.
nuitka — Nuitka compiles source to native code. No PyArmor layer.
Requires a C compiler. On Termux, only --mode module is supported
(Nuitka 2.6.7+). Not available on Pydroid.
combined — PyArmor encrypts first, Nuitka compiles the result. Strongest desktop protection. Not supported on Android because Nuitka needs a full native toolchain Android doesn't provide in Termux/Pydroid.
termux-native — Must run inside Termux on the target device. Runs
PyArmor with the correct linux.* platform string (per PyArmor's own Termux
notes, issue #1674), then optionally compiles with Nuitka --module. Cross-
compiling from your VPS and copying the result to Termux will not work.
pydroid-compat — Falls back to Universal Python mode by default.
Optionally attempts PyArmor with --attempt-pyarmor, but this is unverified
against Pydroid's own Python build and may fail at runtime.
Build output
Every build creates samarth_output/ (or --output DIR) containing:
- The compiled/protected files
samarth_manifest.json— records what was built, on what machine, and explicitly notes which platforms have not been tested
The manifest is honest: a successful build on Linux x86_64 is not evidence the output runs on Termux ARM64. Test on each target separately.
Packaging for PyPI
pip install build twine
python -m build
twine upload dist/*
If shipping a PyArmor-protected extension, include the runtime folder:
[tool.setuptools.package-data]
"your_package" = ["*.so", "*.pyd", "pyarmor_runtime_*/**"]
First upload: create a PyPI account, generate an API token under Account
Settings → API tokens, then use __token__ as the username and the token
as the password when twine prompts.
Runtime checks
from samarth.guard import run_all
run_all(
min_python=(3, 10),
max_python=(3, 13),
allowed_platforms=("Linux", "Windows", "Darwin"),
)
For integrity verification, compute the hash once after your final build:
python -c "import hashlib; print(hashlib.sha256(open('app.py','rb').read()).hexdigest())"
Then pass it to run_all:
run_all(expected_sha256="<hash>", file_path=__file__)
Every check exits with status 1 and a message on failure. None of this resists a determined reverse engineer — it catches version mismatches and casual debugging.
Running tests
python -m unittest discover -v tests/
All 13 tests run without PyArmor or Nuitka installed. Tests that require
those tools or specific hardware (Termux, Pydroid, ARM64) are marked
with skipTest where the environment isn't detected.
Troubleshooting
'pyarmor' not found on PATH — pip install pyarmor, confirm
pyarmor --version works in the same shell.
'nuitka' not found on PATH — pip install nuitka, and confirm a C
compiler is installed (see Install section above).
pyarmor produced no output — run pyarmor gen directly on your
source to see the raw error. Usually a missing activation or empty input.
PyArmor .so load error in Termux — apply the patchelf fix shown
in the Install section above.
'<name>' not found in PyArmor output — PyArmor renamed the entry
file. Use samarth build ... --entry <actual-name>.
Output runs on build machine but not on target — compiled output is
tied to OS, architecture, and Python version. Build on each target, or
for PyArmor use cross-platform --platform flags.
License
MIT
Metadata
Release files for samarth 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| samarth-0.2.0.tar.gz | 14.8 kB | Without provenance | Details for samarth-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| samarth-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for samarth-0.2.0-py3-none-any.whl |
Total release size: 29.0 kB
Release files / samarth-0.2.0.tar.gz
| Download URL | samarth-0.2.0.tar.gz |
|---|---|
| Size | 14.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e69d3890ce193dfdeb1958619291be8f8515b28b08a0742b07e7cad3428464de
|
|
BLAKE2b-256 checksum How to use checksums |
b31fde00afce435cf816501b356f84ce7c055d9c1e070455678326dcae9334e3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.5
|
Release files / samarth-0.2.0-py3-none-any.whl
| Download URL | samarth-0.2.0-py3-none-any.whl |
|---|---|
| Size | 14.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ccba2c21a95cabf27afe441a5a267019c14dd503c245c2b5f905e2683f452884
|
|
BLAKE2b-256 checksum How to use checksums |
570b64cc20e014c4ed7c29488a21c40ff62634ba0df3a1a1f8c5007d2f2c492e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.5
|
Security for samarth 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.