| Crates.io | py_executer |
| lib.rs | py_executer |
| version | 0.3.0 |
| created_at | 2025-05-13 18:00:51.584727+00 |
| updated_at | 2025-07-24 14:10:59.20694+00 |
| description | A Rust-based command-line tool to execute Python scripts with automatic virtual environment and dependency management. |
| homepage | |
| repository | https://github.com/guangyu-he/py_executer |
| max_upload_size | |
| id | 1672267 |
| size | 33,254 |
A Rust-based command-line tool to execute Python scripts with automatic virtual environment and dependency management.
py_executer streamlines running Python code by handling environment setup, dependency installation, and environment
variables, making your workflow faster and more reliable.
requirements.txt automatically..env file or from CLI.PYTHONVENV: Automatically set python path based on the path where the CLI is executed.make sure you have rust installed. uv is optional but recommended.
git clone https://github.com/guangyu-he/py_executer
cd py_executer
cargo install --path .
cargo install --git https://github.com/guangyu-he/py_executer
cargo install py_executer
py_executer run <SCRIPT_PATH> [OPTIONS]
<SCRIPT_PATH>: Path to the Python script to execute.-p, --project <PROJECT_PATH>: Specify the project directory (default: current directory).-E, --env <KEY=VALUE>: Additional environment variables in the format KEY=VALUE. Can be used multiple times.-e, --env-file <ENV_FILE>: Path to a .env file if provided, it will be loaded. If a .env file is found under
--project path, it will be loaded automatically--quiet: Suppress output from the CLI (python stdout and stderr will display normally).--clean: Clean the created uv-managed .venv and config files after execution. Pre-existing files are not deleted.-- <ARGs>: Arguments to pass to the Python script. Must be placed as the last argument(s) and after --.py_executer uv <COMMAND> [OPTIONS]
assume there is a project like this:
project/
├── myscript.py
├── requirements.txt
└── .env
py_executer run my_script.py
this will be equivalent to:
uv venv
uv pip install -r requirements.txt
# or uv sync --project xxx # if it is an uv project
export $(grep -v '^#' .env | xargs) # if .env exists
PYTHONPATH=$PYTHONPATH:$(pwd)
uv run --project xxx my_script.py
or if no uv installed:
which python3
python3 -m venv .venv
source .venv/bin/activate
python3 -m pip install -r requirements.txt
export $(grep -v '^#' .env | xargs)
PYTHONPATH=$PYTHONPATH:$(pwd)
python3 my_script.py
py_executer run my_script.py --project /path/to/project -E DEBUG=true -- --input data.txt
this will be equivalent to:
uv venv --project /path/to/project # if venv is not created
uv pip install -r requirements.txt
# or uv sync --project /path/to/project # if it is an uv project
export $(grep -v '^#' /path/to/project.env | xargs)
PYTHONPATH=$PYTHONPATH:$(pwd)
DEBUG=true
uv run --project /path/to/project my_script.py --input data.txt
src/main.rs: Main CLI logic and environment setup.src/lib/: Internal modules for utilities, macros, and uv integration.Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.
MIT