Skip to main content

Python code protection

Project description

stonefish-code-shield

Industry-grade Python code protection.

PyPi Version

For a comprehensive license management solution that is both developer- and user-friendly, check out the Stonefish License Manager.

Quickstart

Protecting Python Packages

To protect a Python project using the Stonefish Code Shield, ensure that it includes a minimal pyproject.toml file. Then simple replace your build system (e.g., setuptools) with stonefish_code_shield in the pyproject.toml file:

[build-system]
# requires = ["setuptools"]
# build-backend = "setuptools.build_meta"
requires = ["stonefish-code-shield"]
build-backend = "stonefish_code_shield.build_meta"

# ...
# additional project metadata as per PEP 621
# <https://peps.python.org/pep-0621/>
# (recommended)
# ...

Done! Your project is now protected with Stonefish Code Shield. Try it out by running

pip install .

or

(pip install build)
python -m build . --wheel

[!TIP]

In some situations, turning off code protection can be beneficial, for example when testing your software. To turn off Stonefish Code Shield, build with

python -m build . --wheel -Cstonefish=off

When testing with tox, a possible config is

[tox]
envlist = py3

[testenv:.pkg]
passenv = *
config_settings_build_wheel =
  stonefish-code-shield = off

[testenv]
passenv = *
package = wheel
deps =
    pytest
commands =
    pytest

Protecting Standalone Python Scripts

For individual Python files, you can use the scs command-line utility:

scs /path/to/file.py

Guidelines

Here are some guidelines to keep in mind while working with Stonefish Code Shield:

  • Stonefish renames class and function names, so relying on the __name__ attribute in your code won't be possible.

  • Stonefish cannot yet handle relative * imports, e.g.,

    from .utils import *
    

    Make all imports explicit:

    from .utils import div_to_mod, Extractor
    
  • Stonefish discards private (underscored) names from the API. If you want your users to use these variables or functions, you'll have to rename them.

  • Users must add *.dat files to their package data, e.g.,

    [tool.setuptools.package-data]
    "*" = ["*.dat"]
    

    in pyproject.toml. This is because the encrypted code must be shipped with the package.

  • Local imports should be relative (from . import x) instead of using absolute imports (import x) if x/ or x.py is an internal folder or directory.

  • Stonefish places all data files in a flat directory structure, so it cannot handle files that are read from two different Python paths.

    ./data.dat
    
    ./a.py
        Path(__file__).parent / "data.dat"
    
    ./b/b.py
        Path(__file__).parent / .. / "data.dat"
    

More info

For details on on Stonefish Code Shield protects your code, see here.

Contact support@mondaytech.com for more info.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

stonefish_code_shield-0.3.56-py3-none-any.whl (74.5 kB view details)

Uploaded Python 3

File details

Details for the file stonefish_code_shield-0.3.56-py3-none-any.whl.

File metadata

File hashes

Hashes for stonefish_code_shield-0.3.56-py3-none-any.whl
Algorithm Hash digest
SHA256 90cb0f63504624fde0bbf2f101b2b72b44efabacabb6b6dd337e355a01be76fb
MD5 38d734e23ea9d309f4e9df77adb90af5
BLAKE2b-256 32015a850ef965f1004c4d66c92e41fedbd5c80b9902dba4f0107cf57187ff15

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page