Open Source Python Compiler for Commercial Software: MIT Core
You have a decision to make, and it’s a purchasing decision, not just a technical one.
You want to ship proprietary Python as a compiled binary. The moment you start comparing options, the real question isn’t “which compiler produces the smallest binary” — it’s “how much of my build pipeline do I hand over to a vendor, and what happens if that vendor changes terms, raises prices, or disappears?”
That’s why the licensing model of a Python compiler matters as much as its output. An open source core with a permissive license changes the risk profile of the whole purchase. Py2Native is built that way: the compiler is MIT-licensed, and a separate proprietary plugin adds commercial licensing features when — and only when — you need them.
This article is a buying guide: what each tier gives you, where the ROI comes from, how the upgrade path works, and how to decide.
The Purchase Decision: Why an Open Source Core Matters for Commercial Software
Almost every Python code-protection tool on the market is closed source. You get a binary, a license server, and a black box. That has three consequences for a commercial vendor:
- You can’t audit what happens to your code. Your source passes through a tool you cannot inspect.
- You can’t fix or fork it. If a build breaks on a new CPython release, you wait for the vendor.
- The pricing model can change under you. Per-seat and per-build fees turn your build minutes into a recurring liability.
Py2Native’s core compiler, the py2native package, is MIT-licensed. MIT permits commercial use, modification, and distribution. You can read the source, patch it, self-host it in your own CI, and ship compiled proprietary binaries without paying royalties or asking permission.
The core is also deliberately narrow in what it asks of you. You write plain Python — no .pyx/.pxd authoring workflow, no manual cythonize step, no hand-written C extension. You run one command:
uv run py2native build main.py *.py --wheel dist
Behind that command, Py2Native globs your sources, generates its own Cython bootstrap, compiles everything to C, compiles the C with your platform toolchain, and links it — on Windows with MSVC, on Linux with GCC, on macOS with Clang. Cython is an implementation detail you never touch. (If you want the background on what’s happening underneath, see What Is Cython, and Do You Need It to Compile Python? — but you don’t need to know it to use Py2Native.)
Equally important for a purchase: third-party Python libraries are left unmodified. They keep working as they are, with minimal or no configuration. Many protection tools require you to restructure imports, annotate modules, or maintain a build manifest per dependency. That integration work is the hidden cost of the “cheap” tool.
What You Get at Each Tier: Community vs. Pro
| Tier | Package | License | What it adds |
|---|---|---|---|
| Community | py2native |
MIT | Full compilation, uv embedding, cross-platform builds |
| Pro | py2nativepro |
Proprietary | JWT license verification, string compression, keygen/sign/show CLI commands |
Community tier: the compiler, complete
The MIT core is not a crippled teaser. It performs the full compilation pipeline:
- Source globbing and build orchestration
- Cython → C generation via an internal bootstrap template
- C compilation and linking with platform-specific flags
- Shared library mode (
--library) producing.pyd/.so/.dylib - PEP 427 wheel output via
--wheel <dir> uv-managed deployment directories via--embed <dir>
In library mode the wheel ships one compiled shared library containing all your modules, plus two generated files: __init__.py (a meta-path finder that redirects import mypkg.submodule into the shared library) and __main__.py (so python -m mypkg works). Both are required, and both are generated for you.
That’s a complete, self-hosted, cross-platform compilation product under a license you can read in a minute.
Pro tier: revenue protection on top
The Pro plugin (py2nativepro) is a closed-source add-on. It hooks into the build through the plugin lifecycle (extendBuildParser(), extendBuild(), extendCompiler(), extendTemplate(), getCompileLibArgs(), getLinkerArgs(), getExecutableName(), getRuntimeLibraries(), auditWheel()), so it adds capability without replacing your build.
It brings three things:
- JWT license verification —
--license <file>onbuildrequires a valid Pro license, and your application can verify end-user license tokens at runtime. - String compression — further obfuscation of string literals in the compiled output.
- Key management CLI —
keygen,sign, andshow.
The security model is the interesting part for a buyer: the plugin bakes the ES256 signature verification code and the public key into the executable. Only the public key is stored in the binary. Elliptic-curve verification is handled with compiled code inside the product — no third-party crypto libraries in your shipped artifact. Verification happens locally in your application, so you are not running a license server just to check a token.
Wiring verification into your code
Pro verification is one call, but it needs a declaration file. You add a .pxd file that declares the runtime verifier shipped by the plugin:
# _p2n_bootstrap.pxd
cdef _runtime_verify_es256_jwt(token, expected_iss=*, expected_aud=*)
Then you cimport and call it with the license string your application reads at startup, pinning issuer and audience:
from _p2n_bootstrap cimport _runtime_verify_es256_jwt
licenseString = read_license_file() # your own loader
license = _runtime_verify_es256_jwt(
licenseString,
expected_iss="RSJ Software GmbH",
expected_aud="TimestampGIT",
)
The build command doesn’t change. Py2Native compiles the call site, and the plugin supplies the implementation and embedded public key. You are not writing C, not writing a C extension, and not running a separate cythonize step — you’re declaring one signature so the compiler knows what to link against.
To be precise about the division of labour: the MIT core handles compilation; Pro adds licensing and obfuscation. Nothing in the free tier stops working when Pro is absent.
Cost/Benefit and ROI: When the Free Tier Is Enough and When to Upgrade
Start with the honest question: does your product need license enforcement, or just source protection?
Community is enough when:
- You ship internal tools or prototypes where source readability is the concern.
- Your commercial model doesn’t depend on per-customer license tokens (e.g. you sell a service, or hardware with bundled software).
- You want native binaries for distribution size or startup characteristics rather than revenue control.
- You want to prove the pipeline works across Windows, Linux, and macOS before committing to anything.
Pro earns its keep when:
- You sell time-limited trials and need the executable to reject expired tokens.
- You sell per-seat or per-machine licenses and need offline enforcement.
- Your revenue depends on a customer not being able to flip a flag and unlock the product.
Compare that against the alternative: building it yourself. The “hard way” is writing C extensions or maintaining a hand-rolled Cython pipeline, then layering your own crypto verification on top — key generation, JWT signing, embedding a public key in a compiled artifact, and keeping it correct across three platforms and five CPython versions. That’s weeks of engineering plus permanent maintenance, and every CPython release is a new integration project.
Py2Native’s zero-config approach collapses that to a build command plus (for Pro) one declaration file and one call. The ROI case is straightforward: the saved engineering time on the first platform port usually exceeds the cost of the tooling that avoids it.
And there’s a subtle upgrade benefit: both tiers use the same command.
uv run py2native build main.py *.py --library --wheel dist --embed deploy/
Adding --license license.dat is the only difference in your pipeline. Your CI scripts, Dockerfiles, and release jobs stay as they are — which matters if you’ve already invested in release automation (see Ship Compiled Python Wheels Automatically on Every Release).
Upgrade Path and Deployment: Self-Hosted vs. Cloud
Both tiers are self-hosted. You run the compiler locally or in CI. There is no cloud dependency, no build telemetry requirement, and no hosted compile step that sees your source. Your proprietary code stays inside your infrastructure — which is often the deciding factor for vendors whose customers ask about supply-chain exposure.
The upgrade path is a plugin install, not a migration:
- Start with Community. Compile, package, and deploy.
- When you need enforcement, add
py2nativeproand pass--licenseat build time. - Generate a keypair and sign tokens with the Pro CLI.
# One-time: create an EC P-256 keypair
uv run py2native keygen private.pem public.pem
# Sign a JWT payload for a customer / trial
uv run py2native sign --private private.pem payload.json license.dat
# Inspect (and optionally verify) a token
uv run py2native show --public public.pem license.dat
Then build with the license, keeping the public key where your runtime expects it:
uv run py2native build main.py *.py --license license.dat --public public.pem \
--wheel dist --embed deploy/
Deployment modes are the same in both tiers:
--embed <dir>— auv-managed deployment directory, ready to run.--wheel <dir>— a PEP 427 wheel containing the compiled shared library and the generated__init__.py/__main__.py.--library— a shared library instead of an executable, for embedding in a larger host process.
Because Pro integrates through lifecycle hooks, existing build scripts keep working unchanged. For container-based delivery specifically, see How to Protect Python Code in Docker Container Deployments.
Making the Choice: Key Considerations for Commercial Vendors
A few practical trade-offs to weigh before you commit:
- Flexibility vs. enforcement. MIT gives you auditability, forking rights, and no royalty obligation. Pro gives you revenue protection. They are complementary, not competing.
- Compliance. LGPL libraries remain replaceable by the end user, which keeps you on the right side of those obligations. The MIT license itself permits commercial use.
- Platform coverage. CPython 3.11–3.15, including the free-threaded 3.14t and 3.15t builds. Windows 8+, manylinux2014/musl Linux, macOS. x86-64 or ARM64. A platform C compiler is required (MSVC, GCC, Clang), and the build needs internet access to fetch Python distributions and libraries.
- Known constraints, stated up front. You can’t have modules with identical names across source files. Monkey-patching is still possible, since third-party libraries remain Python source.
__init__.pyis skipped during compilation (it’s a namespace marker), and in library mode__main__.pyis excluded from sources because the wheel builder generates it. None of these are surprises — they’re documented behaviour. - Dependencies are modest and mainstream.
cython >= 3.2.4,setuptools >= 82.0.1,uv >= 0.11.8, andauditwheel >= 6.6.0on Linux only.
Our recommendation for a first purchase: evaluate Community first. Run a real build of your actual package, on all three platforms you ship, with your real dependency set. If the output protects your source and your imports still resolve, you’ve validated the risky part. Then decide whether license enforcement justifies Pro.
FAQ
Is the open source core really free for commercial use?
Yes. The py2native package is MIT-licensed, which permits commercial use, modification, and distribution. You can use it to compile proprietary Python code without paying royalties. The Pro plugin is a separate proprietary add-on for license verification and string compression.
Do I need the Pro tier to protect my source code? No. The Community tier compiles your Python code to native machine code, which already protects your source from casual inspection. The Pro tier adds JWT license verification and string compression, which are useful if you need to enforce licensing or further obfuscate strings.
How does the Pro license verification work?
With the Pro plugin, you generate an EC P-256 keypair using uv run py2native keygen, sign a JWT payload with uv run py2native sign, and then in your code include a .pxd file that cimports _runtime_verify_es256_jwt from _p2n_bootstrap. You call _runtime_verify_es256_jwt(licenseString, expected_iss="RSJ Software GmbH", expected_aud="TimestampGIT") to verify the license. The plugin bakes the signature verification code and public key into the executable.
Can I try the Pro features before buying? The Pro plugin is a commercial product. You can evaluate the Community tier for free to test compilation and deployment. For Pro features, you would need to obtain a license. Check the official documentation for trial availability.
Do I need a cloud account or a hosted build service?
No. Both tiers are self-hosted: you run uv run py2native build locally or in your own CI. Only the public key is embedded in the executable, and verification is handled by compiled code inside your binary — no third-party libraries and no remote check required to validate a token.
What are the technical requirements? CPython 3.11–3.15 (including free-threaded 3.14t and 3.15t), a platform C compiler/linker (MSVC on Windows, GCC on Linux, Clang on macOS), Windows 8+ / manylinux2014 or musl Linux / macOS, and x86-64 or ARM64. The build needs internet access to download Python distributions and libraries.
The Bottom Line
For a commercial vendor, the right question isn’t “free or paid” — it’s “which parts of my risk do I want to own?” An MIT-licensed compiler means you own the build pipeline: you can inspect it, self-host it, and fork it if you ever need to. A proprietary plugin means you can buy revenue protection as a discrete, removable component rather than as a precondition for shipping anything at all.
That’s the model Py2Native offers: compile plain Python to native binaries with zero configuration, keep your third-party libraries untouched, and add JWT license verification only when your business model demands it. Start with the Community tier at py2native.dev — build your real package, on your real platforms, and see what lands in dist/.
Related posts
- Ship Compiled Python Wheels Automatically on Every Release
- How to Protect Python Code in Docker Container Deployments
- What Is Cython, and Do You Need It to Compile Python?