Skip to main content

lykn Python SDK

Python license validation SDK for applications protected by Lykn.

What this SDK provides

  • Runtime license verification with LicenseValidator.
  • RSA signature, validity period, hardware binding, and feature checks.
  • CLI tools for verification, license inspection, hardware collection, and packaging.
  • FastAPI dependencies for route-level license and feature enforcement.
  • Packaging helpers for bundling protected Python applications with PyInstaller or Nuitka.

Installation

Install the base SDK:

pip install lykn

Install optional integrations when needed:

pip install lykn[fastapi]
pip install lykn[pack]

For local development from this repository:

cd sdk/python
pip install -e ".[dev]"

Verify a license

Use LicenseValidator with a project public key and a signed license file:

from lykn import LicenseValidator

validator = LicenseValidator(
    public_key="./public.pem",
    license_path="./license.lic",
    check_interval=300,
)

license_data = validator.start()
assert validator.has_feature("reports") is True
validator.stop()

LicenseValidator accepts either license_path or license_content. Set check_interval to a positive number of seconds to re-check the license in the background after start() is called.

Common methods:

  • verify(required_features=None): validate once and return LicenseData.
  • start(): validate once and start background re-checks when enabled.
  • stop(): stop the background re-check loop.
  • has_feature(feature): check whether the current license includes a feature.
  • on_invalid(callback): register a callback for background validation failure.

License data

Successful validation returns a LicenseData object with these fields:

  • id: license ID.
  • subject: licensed user or organization information.
  • plan: license plan code.
  • plan_name: license plan display name.
  • issued_at, not_before, not_after: license time window.
  • hardware: optional hardware binding data.
  • features: enabled feature list.
  • limits: structured license limits such as max_users and max_devices.
  • metadata: legacy custom metadata, kept for older licenses.

Validation can raise these SDK errors:

  • LicenseFileError
  • LicenseSignatureError
  • LicenseExpiredError
  • LicenseNotYetValidError
  • HardwareMismatchError
  • FeatureNotLicensedError

CLI

The lykn command is installed with the SDK.

Verify a license and require one or more features:

lykn verify --public-key ./public.pem --license ./license.lic --feature reports

Inspect a signed license payload without verifying it:

lykn inspect --license ./license.lic

Collect local hardware data for hardware-bound licenses:

lykn hardware-info --format json
lykn hardware-info --format table

Bundle a protected Python application:

lykn pack --project ./my-app --engine pyinstaller --entry main.py --out ./dist
lykn pack --project ./my-app --engine nuitka --module my_app --mode onefile

FastAPI

Install the FastAPI extra first:

pip install lykn[fastapi]

Use RequireLicense to require any valid license, or RequireFeatures to require specific licensed features:

from fastapi import Depends, FastAPI
from lykn import LicenseValidator
from lykn.contrib.fastapi import RequireFeatures, RequireLicense

validator = LicenseValidator(public_key="./public.pem", license_path="./license.lic")
app = FastAPI()

@app.get("/health/license")
def license_health(license_data=Depends(RequireLicense(validator))):
    return {"license": license_data.id}

@app.get("/reports")
def reports(license_data=Depends(RequireFeatures(validator, "reports"))):
    return {"plan": license_data.plan}

Invalid licenses or missing features return HTTP 403 from the dependency.

Packaging protected apps

Install the packaging extra first:

pip install lykn[pack]

lykn pack stages the project, includes common Lykn resources such as license.lic and public.pem when present, and delegates the build to PyInstaller or Nuitka.

Use CLI options for one-off builds:

lykn pack \
  --project ./my-app \
  --engine pyinstaller \
  --entry main.py \
  --mode onedir \
  --resource license.lic \
  --resource public.pem \
  --exclude .env \
  --name my-app

Or store defaults in pyproject.toml:

[tool.lykn.pack]
engine = "pyinstaller"
entry = "main.py"
out = "dist"
mode = "onedir"
resources = ["license.lic", "public.pem"]
exclude = [".env", ".env.*", ".git", "__pycache__"]
name = "my-app"
clean = true
extra_args = ["--noconfirm"]

CLI options override values from pyproject.toml.

Compatibility

  • Python 3.10 or newer.
  • Optional FastAPI integration requires fastapi>=0.100.
  • Optional packaging support requires pyinstaller>=6.0 or nuitka>=2.0.

Metadata

Release files for lykn 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lykn 0.0.1
File Size Uploaded Provenance Actions
lykn-0.0.1.tar.gz 69.4 kB Without provenance Details for lykn-0.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for lykn 0.0.1
File Interpreter ABI Platform Actions
lykn-0.0.1-py3-none-any.whl Python 3 none any Details for lykn-0.0.1-py3-none-any.whl

Total release size: 85.4 kB

Release files / lykn-0.0.1.tar.gz

Download URL lykn-0.0.1.tar.gz
Size 69.4 kB
Tags Source
SHA-256 checksum
How to use checksums
239dbe55d9c2823e8f272956a051f85b38dcd60b42f01d9e07dabc6a988042d0
BLAKE2b-256 checksum
How to use checksums
7074270eeb1b9818cbebaa8ce13c7f8c995889b588a455054f38458ab6c8d477
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / lykn-0.0.1-py3-none-any.whl

Download URL lykn-0.0.1-py3-none-any.whl
Size 16.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
627a0d69210022d4bc3e0efaeadffb6c5afa3560ea909a7c4a65019bfd335ea0
BLAKE2b-256 checksum
How to use checksums
93358e61501d582283be25d0e0e3088555dd7ef85480e63fae47dc2771e54c20
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for lykn 0.0.1

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.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page