Skip to main content

Python wrapper for the PyCrucible CLI tool

Project description

Poster image of PyCrucible

Overview

This tool runs a Python application using the UV binary. It extracts your application, optionally reads configuration from pycrucible.toml or pyproject.toml, and uses uv to execute it in an ephemeral environment.

What does this mean?

You get a single self-contained binary that can be distributed across machines running the same platform. No Python installation is required - just an internet connection. Run the executable, and it takes care of the rest.

Community

You can visit our community group on Telegram PyCrucible Telegram Community

Changelog

You can see latest changes at CHANGELOG FILE.

Github Action

PyCrucible has associated GitHub Action workflow which you can use to embed your python applications directly in CI. GitHub Action marketplace. GitHub Repository

Documentation

Documentation can be found at PyCrucible docs.

How to get PyCrucible

There are a couple of ways to get PyCrucible.

Using PyPI

PyCrucible is published to PyPI for every release. All you need to do is:

pip install pycrucible

Using Github Releases

You can download pre-made binaries for your system from Github Releases page

Downloading and building from source code

  1. Ensure you have Rust installed.

  2. Clone the repository git clone https://github.com/razorblade23/PyCrucible

  3. Change directory to be inside of a project cd PyCrucible

  4. Build Runner cargo build -p pycrucible_runner --release

  5. Build Pycrucible cargo build -p pycrucible --release

[!NOTE] The resulting binary will be in target/release/pycrucible.

How to use PyCrucible

All you need for starting is a single main.py file with some code.

If you installed it using pip you can just run it with:

pycrucible -e .

This will embed your project and produce a new binary which is by default called launcher (or launcher.exe on Windows).

[!TIP] To configure the output path and name of your binary, use -o or --output flag.

Example: pycrucible -e . -o ./myapp (or pycrucible -e . -o ./myapp.exe)

This is now all you need to distribute your python project to other people.

No python required on their end. Just this single binary.

Running pycrucible --help reveals more options:

$ pycrucible --help
Tool to generate python executable by melding UV and python source code in crucible of one binary

Usage: pycrucible [OPTIONS]

Options:
  -e, --embed <EMBED>
          Directory containing Python project to embed. When specified, creates a new binary with the embedded project
  -o, --output <OUTPUT>
          Output path for the new binary when using --embed
      --uv-path <UV_PATH>
          Path to `uv` executable. If not found, it will be downloaded automatically [default: `.`]
      --debug
          Enable debug output
  -h, --help
          Print help
  -V, --version
          Print version

How to configure PyCrucible

Configuration can be set in two files:

  • pycrucible.toml
  • pyproject.toml

[!NOTE] When both pycrucible.toml and pyproject.toml are discovered, configuration from pycrucible.toml will take effect.

[!IMPORTANT] When using any configuration, only entrypoint is required. Other options are optional.

[!TIP] In both pycrucible.toml and pyproject.toml directive entrypoint can also be replaced by just entry.

Both of these files have exact same configuration options. You can find example file for pycrucible.toml here

In pycrucible.toml you would define configuration like this:

entrypoint = "src/main.py"
# or
entry = "src/main.py"

[options]
debug = false
extract_to_temp = false
delete_after_run = false

[patterns]
include = [
    "**/*.py",
]
exclude = [
    "**/__pycache__/**",
]

[env]
FOO = "foo"
BAR = "bar"

[hooks]
pre_run = "some_script.py"
post_run = "some_other_script.py"

In pyproject.toml you would define configuration like this:

[tool.pycrucible]
entrypoint = "src/main.py"
# or
entry = "src/main.py"

[tool.pycrucible.options]
debug = false
extract_to_temp = false
delete_after_run = false
offline_mode = false

[tool.pycrucible.patterns]
include = [
    "**/*.py",
]
exclude = [
    "**/__pycache__/**",
]

[tool.pycrucible.env]
FOO = "foo"
BAR = "bar"

[tool.pycrucible.hooks]
pre_run = "some_script.py"
post_run = "some_other_script.py"

[!TIP] You can use patterns to include or exclude any arbitrary files, like HTML templates, Kivy layout files or any other arbitrary files needed for your application.

[!IMPORTANT] There is no need for setting PYTHONPATH env variable as uv will take care of this. If this is really needed, uv will complain and you should also also set UV_LINK_MODE="copy" as env variable to mitigate the warning.

Update your project from GitHub

In configuration file its possible to set your GitHub repository, so the resulting binary will always check for update before running the application.

In pycrucible.toml it would look like this:

[source]
repository = "https://github.com/username/repo"
branch = "main"
update_strategy = "pull"

In pyproject.toml it would look like this-

[tool.pycrucible.source]
repository = "https://github.com/username/repo"
branch = "main"
update_strategy = "pull"

Default configuration

entrypoint = "main.py"

# Options
debug = false
extract_to_temp = false
delete_after_run = false

# Patterns
patterns.include = [
    "**/*.py",
]
patterns.exclude = [
    ".venv/**/*",
    "**/__pycache__/**",
    ".git/**/*",
    "**/*.pyc",
    "**/*.pyo",
    "**/*.pyd"
]

# Source repository (GitHub)
source = None

# Enviroment variables
env = None

# Pre and post run hooks
hooks = None

If any of these configuration options is not used, it will be replaced with default value.

NOTE - entrypoint directive is required when using any configuration options.

Security / Code signing

For users who want to verify the authenticity of the builder binary, we recommend code signing. This ensures that the binary you download has not been tampered with. Code signing will be automatic in next release of PyCrucible.

The builder is the only distributed artifact; the Python projects themselves are provided by users at runtime.

Signing the builder ensures the binary is authentic.

Generated self-contained binaries (created by the builder) are not pre-signed — users may optionally sign them for their own distribution.

[!IMPORTANT] Make sure you run code signing after embedding your project. This makes sure that embedded project also be part of the signiture.

Features

  • Cross-Platform:
    • Windows support
    • macOS support (testing)
    • Linux support
  • Small overhead:
    • Runner binary that embeds your project is just 2 MB. This ofcourse grows with embedding uv and your project.
  • Configurable:
    • Use pycrucible.toml or pyproject.toml to customize embedding details
      • entrypoint
      • include/exlude files
      • arguments to uv
      • env variables
      • update source code from github
      • pre and post run hooks (python scripts)
      • offline mode
      • extract to temporary directory (removes temporary directory after running automaticly)
      • remove extracted files after running
    • Support for multiple ways of defining requirements
      • uv initialized pyproject.toml (This is preffered !)
      • requirements.txt
      • pylock.toml
      • setup.py
      • setup.cfg
    • Load the project as a directory
  • Tests:
    • Unit tests covering as much as i can make it

Thanks to

The idea is inspired by Packaged.

Thanks to all the briliant developers at Astral. They did awesome job with uv.

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 Distributions

If you're not sure about the file name format, learn more about wheel file names.

pycrucible-0.3.8-py3-none-win_amd64.whl (2.7 MB view details)

Uploaded Python 3Windows x86-64

pycrucible-0.3.8-py3-none-manylinux_2_28_x86_64.whl (2.8 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ x86-64

pycrucible-0.3.8-py3-none-macosx_11_0_arm64.whl (2.4 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

pycrucible-0.3.8-py3-none-macosx_10_12_x86_64.whl (2.5 MB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

Details for the file pycrucible-0.3.8-py3-none-win_amd64.whl.

File metadata

  • Download URL: pycrucible-0.3.8-py3-none-win_amd64.whl
  • Upload date:
  • Size: 2.7 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pycrucible-0.3.8-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 554085902b8f81776b933ac8720c169ee6bc588942c2fb1e314c14c5d6653fdf
MD5 e3344e11222d969babfa07eadf36567c
BLAKE2b-256 2fa4d976b24b6ed2d89d42c78b30d19c98308752e896c830ddb84db48ff82827

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycrucible-0.3.8-py3-none-win_amd64.whl:

Publisher: v0.3-pipeline.yml on razorblade23/PyCrucible

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pycrucible-0.3.8-py3-none-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pycrucible-0.3.8-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e3658c500f7969ad272fdaf63075cc58db2bd74fe1f12274a361c6483f0a3f15
MD5 c946c6fb1d226906fcbb2a3d2f1b129a
BLAKE2b-256 b8dede121d45ef0d328d378b4bac7d55b0cb3d99096a0c54222327654178fb11

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycrucible-0.3.8-py3-none-manylinux_2_28_x86_64.whl:

Publisher: v0.3-pipeline.yml on razorblade23/PyCrucible

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pycrucible-0.3.8-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pycrucible-0.3.8-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3dc7956efd862d8ab9e0636d2800660c9cfeac0e0e57195fbb461b46280a124e
MD5 b104e3b9d7d804c0a7a1395d411f5ab6
BLAKE2b-256 d98597258e01d81982a52a68d409301b75702528bbd4c9ff4d926e5171d8d355

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycrucible-0.3.8-py3-none-macosx_11_0_arm64.whl:

Publisher: v0.3-pipeline.yml on razorblade23/PyCrucible

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pycrucible-0.3.8-py3-none-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pycrucible-0.3.8-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 544746fbbfb122c2182a93cd05b1b9c6facb0f34b864aeaacb21e49eae65aae5
MD5 19a9eeabae74ee0083a77b8118b81400
BLAKE2b-256 ea90a6abe20522ed8dbc18de705ccbd34c43010785060773a8c08a5bb7685fd0

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycrucible-0.3.8-py3-none-macosx_10_12_x86_64.whl:

Publisher: v0.3-pipeline.yml on razorblade23/PyCrucible

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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