Py2Native Python to native compilerPython-zu-Native-Compiler

← All posts

2026-11-22

MIT-Licensed Python Compiler: What's Included

MIT-Licensed Python Compiler: What's Included
python compiler cython code protection open source

MIT-Licensed Python Compiler: What’s Included

You’re comparing Python code-protection tools, and before you commit budget or bake a dependency into your release pipeline, you want a straight answer to one question: what does the MIT license actually cover, and what do I still have to pay for?

Short version: with Py2Native, the compiler itself is open source under the MIT license. You can read it, modify it, fork it, and ship its output in commercial products. The paid piece is a separate, optional Pro plugin that adds JWT license verification and string compression. That split is the whole purchase decision — everything below is about which side of it your product lands on.

The Purchase Decision: What the MIT License Actually Covers

Py2Native is a Python-to-native compiler. You write plain Python, run one build command, and get a compiled native binary instead of readable .py files. Under the hood it drives Cython, but you never see that layer: no .pyx sources to maintain, no .pxd boilerplate for your business logic, no manual cythonize step, no hand-written C extension. That’s the “hard way,” and it’s a maintenance project disguised as a build step.

The MIT license applies to the py2native package — the compiler, the build orchestrator, the platform backends, the wheel and embed builders. Concretely, that means:

  • Inspect it. The Cython templates, platform flags, and linking logic are all in the repository. If your security team wants to know what happens to your source at build time, they can read it.
  • Modify it. Need a custom compile flag for an exotic toolchain? Patch it.
  • Redistribute it. Fork it into your internal build image and hand it to your CI team.
  • No vendor lock-in on the compilation step. If the project disappeared tomorrow, the code you already have keeps compiling.

The py2nativepro package is separate, proprietary, and licensed. It’s the tier you buy when your business model depends on enforcing per-customer licenses. The decision isn’t “open source vs. commercial” — it’s “do I need license enforcement in the binary, or not?”

What You Get at Each Tier

Community tier — py2native (MIT)

The full compilation pipeline, unrestricted:

  • Compiles your Python modules into a single native artifact — shared library (.pyd / .so / .dylib) or executable.
  • --embed <dir> produces a uv-managed deployment directory you can zip and ship.
  • --wheel <dir> produces a PEP 427 wheel containing the compiled library plus the __init__.py meta-path finder that redirects import mypkg.submodule to the native library, and a generated __main__.py so python -m mypkg works.
  • Windows, Linux, and macOS backends with per-platform compiler flags, linking, and naming.
  • CPython 3.11–3.15, including free-threaded 3.14t and 3.15t.

Third-party libraries stay as Python source and keep working as-is. That’s deliberate: it keeps you LGPL-compliant (end users can still replace those libraries) and it keeps your build config near-empty.

Pro tier — py2nativepro (proprietary)

Everything above, plus:

  • JWT license verification baked into the compiled binary, with only the public key embedded.
  • String compression, so your literals aren’t sitting in the binary in plain text.
  • CLI tooling for license operations: keygen, sign, show.
  • --license flag on build, so a build without a valid license fails at compile time.
Capability Community (MIT) Pro
Plain-Python → native compilation Yes Yes
Wheel output (--wheel) Yes Yes
Embeddable deployment dir (--embed) Yes Yes
Library mode (--library) Yes Yes
Windows / Linux / macOS Yes Yes
Source modifiable & redistributable Yes Compiler core only
JWT license enforcement in binary — Yes
keygen / sign / show — Yes
String compression — Yes
Typical use case Internal tools, CLI utilities, IP protection on freely distributed software Paid products, per-seat licensing, premium feature gating

Both tiers use the identical build command. Nothing about your source layout changes:

uv run py2native build main.py *.py --wheel dist

Cost/Benefit and ROI: When Pro Pays for Itself

The MIT core removes a cost center that’s easy to underestimate: the compilation step itself has no per-seat, per-build, or per-artifact fee. Your CI can compile on every commit without a metering conversation.

The real hidden cost in DIY protection isn’t the compiler — it’s everything around it:

  • Maintaining build scripts that invoke Cython correctly, per platform, per Python version.
  • Getting linking right on three operating systems with three different shared-library formats.
  • Writing a license check in pure Python, where anyone with a text editor can find the if and flip it.
  • Rebuilding all of the above whenever CPython ships a new minor version.

The Pro plugin earns its price at the moment your revenue depends on people not bypassing your license check. A pure-Python check is a string search and a patch away. Pro’s approach is different in kind: the ES256 signature verification code is compiled, and only the public key is stored in the executable. There is no private key to steal from the binary and no third-party crypto library to shadow-patch. (The elliptic curve verification is implemented in compiled code inside the plugin — no external crypto dependency.)

Rule of thumb:

  • Shipping free tools, internal services, or obfuscated-but-open binaries → Community tier is sufficient, and it’s free.
  • Shipping software customers pay for, with seats, expiries, or feature tiers encoded in a license → Pro pays for itself the first time it prevents a shared key from becoming a product-wide bypass.

If you want the deeper mechanics of the verification flow, we covered it separately in Verify a Signed License Key in a Compiled Python App.

Upgrade Path: Community to Pro Without Rewriting Your App

The upgrade is incremental by design. Your application code doesn’t change. What changes is the build command and one small verification hook.

Step 1 — start on the MIT core. No commitment, no license file:

uv add py2native
uv run py2native build main.py *.py --embed deploy

Step 2 — add Pro when you need enforcement. Generate a keypair, sign a payload, and inspect the result:

uv add py2nativepro

uv run py2native keygen private.pem public.pem
uv run py2native sign --private private.pem payload.json license.dat
uv run py2native show --public public.pem license.dat

keygen produces an EC P-256 keypair. sign turns your JSON payload into a JWT written to license.dat. show prints the claims, and optionally verifies the signature against the public key — useful for support tickets.

Step 3 — wire the verification hook. The Pro plugin generates and bakes a bootstrap module (_p2n_bootstrap) that contains the signature verification code and the public key. You add a declaration file next to your sources so your code can call into it:

# _p2n_bootstrap.pxd
cdef _runtime_verify_es256_jwt(token, expected_iss=*, expected_aud=*)

Then a small hook module cimports it and performs the check:

# license_hook.pyx — compiled alongside your app by py2native
from _p2n_bootstrap cimport _runtime_verify_es256_jwt

def checkLicense(str licenseString):
    license = _runtime_verify_es256_jwt(licenseString, expected_iss="RSJ Software GmbH", expected_aud="TimestampGIT")
    return license

That’s the entire Cython surface area: one declaration line and one call. You are not writing C, not linking OpenSSL, and not shipping a private key.

Step 4 — build with the license and public key:

uv run py2native build main.py *.py \
  --license license.dat \
  --public public.pem \
  --wheel dist

The plugin’s build hook validates the JWT before compilation proceeds, then bakes the verification code and public key into the artifact. The private key never leaves your signing machine.

Self-Hosted by Design: Nothing Leaves Your Build Environment

Py2Native is a compiler you run, not a service you call. Your source code is processed on your machine or in your CI runner — it is never uploaded. The same is true of the Pro plugin: license checks happen at build time (via --license) and at runtime (inside your binary), not through a cloud API.

The MIT license makes this composable. You can bake the compiler into your own build image, wrap it in an internal Makefile target, or gate it behind your release tooling — no redistribution restrictions to negotiate with legal. Network access is only needed for the build dependencies themselves (Python distributions and libraries are downloaded during compilation), so pin your images and cache accordingly.

For a containerized setup, the Docker build walkthrough shows the one-command pattern.

One platform note: build on the platform you’re targeting. Windows builds on Windows, Linux on Linux, macOS on macOS — each backend produces that platform’s native format. It’s not a restriction you fight; it’s just how you should structure your matrix:

# .github/workflows/release.yml (excerpt)
strategy:
  matrix:
    os: [ubuntu-latest, windows-latest, macos-latest]
steps:
  - uses: actions/checkout@v4
  - run: uv sync
  - run: uv run py2native build main.py *.py --wheel dist
  - uses: actions/upload-artifact@v4
    with:
      name: wheel-${{ matrix.os }}
      path: dist/*

Making the Choice: A Checklist for Your Team

Run through these before you decide:

  • Do you need license enforcement? If yes, Pro. If your software is free to distribute and you only want to stop casual source reading, Community is enough.
  • How large is the team that touches the build? One build command is easy to standardize across a team. A homegrown Cython pipeline is a specialist dependency.
  • Compliance constraints? Third-party libraries stay as Python source, so LGPL libraries remain replaceable by end users. __init__.py files are skipped during compilation (namespace markers, not compilable code), and in library mode __main__.py is generated by the wheel builder rather than compiled.
  • Long-term maintenance. Every CPython minor release is someone’s job to chase. With Py2Native, it’s a version bump in your lockfile.
  • Naming discipline. No two source files may share a module name — a small constraint worth checking before a large migration.

A sensible trial: compile a real internal tool on the Community tier and confirm your third-party dependencies still import cleanly from the wheel. Then run a small pilot of the Pro flow — keygen, sign, one license check in the binary — against a single customer contract. Two afternoons, and you’ll know which tier you’re buying.

For exhaustive interface details, the CLI reference and llms-full.txt in the repository cover every flag, artifact layout, and runtime API.

FAQ

Can I use the MIT-licensed compiler in a commercial product without paying? Yes. The Community tier (py2native) is MIT-licensed, so you can use it freely in commercial projects, modify it, and redistribute it. You only need the Pro plugin if you want JWT license verification and string compression.

What exactly does the Pro plugin add beyond the MIT core? The Pro plugin (py2nativepro) adds JWT license verification, string compression, and CLI commands (keygen, sign, show) for managing signed licenses. It also provides the --license flag on build to enforce a valid license at compile time.

How does the Pro plugin verify licenses without third-party libraries? The Pro plugin bakes the ES256 signature verification code and public key directly into the executable. At runtime, your code calls _runtime_verify_es256_jwt from the _p2n_bootstrap module, which performs the verification using compiled code — no external crypto libraries are needed.

Is cross-compilation supported for building on one platform for another? No, cross-compilation is not supported. You need to build on the target platform (Windows, Linux, or macOS) to produce a native binary for that platform.

Conclusion

The MIT license on Py2Native’s core means the compilation step — the part every Python project needs — is free, inspectable, and yours to modify. The Pro plugin is a narrow, well-defined purchase: it buys you JWT license enforcement and string compression, compiled into the binary rather than bolted on in Python.

Start with the core today at py2native.dev, compile one real project, and see how little build configuration zero-config actually requires. Add py2nativepro when a paying customer’s license needs to mean something.

Related posts

EU label: AI-generated content