Python wrapper for the PyCrucible CLI tool
Project description
PyCrucible
"Run Python Apps Instantly, No Setup Required."
A robust, cross-platform builder and launcher for Python apps using UV.
Overview
This tool runs a Python application with a help of UV binary. It extracts your package (ZIP or directory), loads an optional configuration from pycrucible.toml, and uses uv to run your app in an ephemeral environment.
Installation
You can install pycrucible with the usual:
pip install pycrucible
PyCrucible configuration
A directory with a single .py file is all you need to start.
There are however multiple configuration options to suit your specific needs.
Note - when using any configuration, only entrypoint is required. Other options are optional.
Configuration can be set in two ways:
pycrucible.tomlpyproject.toml
Both of these files have exact same configuration options. You can find example file for pycrucible.toml here
Diffrence between configuration options
Note - In both pycrucible.toml and pyproject.toml directive entrypoint can also be replaced by just entry.
In pycrucible.toml you would define configuration like this:
entrypoint = "src/main.py"
# or
entry = "src/main.py"
[package.patterns]
include = [
"**/*.py",
]
exclude = [
"**/__pycache__/**",
]
[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.patterns]
include = [
"**/*.py",
]
exclude = [
"**/__pycache__/**",
]
[tool.pycrucible.hooks]
pre_run = "some_script.py"
post_run = "some_other_script.py"
Default configuration
ProjectConfig {
package: PackageConfig {
entrypoint: "main.py".into(),
patterns: FilePatterns {
include: vec!["**/*.py".to_string()],
exclude: vec![
".venv/**/*".to_string(),
"**/__pycache__/**".to_string(),
".git/**/*".to_string(),
"**/*.pyc".to_string(),
"**/*.pyo".to_string(),
"**/*.pyd".to_string(),
],
},
},
source: None,
uv: None,
env: None,
hooks: None,
}
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"
Prepare your python project
Your project should include at least:
- A directory with your Python application (with an entry point (default: main.py))
- Some kind of manifest file declaring dependacies and/or configuration
- (optional) configuration file or section
- only
entrypointis required if using this configuration file, other options are optional - if this file is not present, it will be created with default values.
- only
Usage
$ 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: `.`]
--extract-to-temp
Extract Python project to a temporary directory when running
--debug
Enable debug output
--delete-after-run <DELETE_AFTER_RUN>
Delete extracted files after running. Note: requires re-downloading dependencies on each run [default: false]
-h, --help
Print help
-V, --version
Print version
Usage examples (Linux)
You can copy built/downloaded binary to your project folder and just run:
./pycrucible -e . -o ./launcher
This will embed your project into another binary (that we called "launcher")
You can run your project from binary by running
./launcher
Usage examples (Windows)
You can copy built/downloaded binary to your project folder and just run:
pycrucible.exe -e . -o ./launcher.exe
This will embed your project into another binary (that we called "launcher.exe")
You can run your project from binary by running
launcher.exe
Now you can copy that "launcher" on practicly any machine with the same architecture. Machine only needs internet connection in order to download the dependacies. This proccess is extremely fast (but reliant on internet connection)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pycrucible-0.2.8.tar.gz.
File metadata
- Download URL: pycrucible-0.2.8.tar.gz
- Upload date:
- Size: 3.7 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7dc33a20eda9baee6294b49247d49fd1cab140cefd2ed2da3aadae3904f5d686
|
|
| MD5 |
1e911d37a9189375d8b0fdef24f07db0
|
|
| BLAKE2b-256 |
582e2f1f51303f2a82c86ca669489e95c0dfda3726bb5df109f526aa2259e46a
|
File details
Details for the file pycrucible-0.2.8-py3-none-any.whl.
File metadata
- Download URL: pycrucible-0.2.8-py3-none-any.whl
- Upload date:
- Size: 3.8 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
69173c95fc003049d6b1c536f6d86e5a73d3db93fbc28887eb6c22f217dd2d86
|
|
| MD5 |
6e62fda930fa296b55bb73804fdd5c09
|
|
| BLAKE2b-256 |
14ffbc576ef41c167807afd4325d8d19a8b94a608d6137fa31c6501c7547af39
|