Pylon: Command-Line Improvements
Project description
Pylon CLI
Pylon is a command-line tool that allows you to run Python scripts from either your current project directory or your user's .pylon directory. It supports both simple Python scripts and project-based scripts with pyproject.toml dependencies.
Installation
To install Pylon CLI, you can use pip:
pip install pylon-cli
Usage
pylon <script-name> [args...]
Pylon searches for scripts in the following order:
- Current project directory (the directory you're in)
- User scripts directory (
~/.pylon)
How It Works
Script Types
Pylon supports two types of scripts:
Simple Scripts: Standalone Python files without dependencies. They run using the current Python interpreter.
Project Scripts: Scripts that are part of a Python project with a pyproject.toml file. They run in isolated virtual environments with project dependencies installed.
Note
Pylon invokes the builtin
venvmodule to create virtual environments for project scripts. Currently we don't support managing Python installations. If your script requires a specific Python version that's different from the one powering Pylon, thevenv-creation will fail and Pylon will exit with an error message.
Directory Structure Examples
Simple Script (current directory):
.
├── hello.py # Script name: "hello"
└── other.py # Script name: "other"
Project Script (current directory with pyproject.toml):
.
├── pyproject.toml # Project configuration
├── main.py # Script name: "main" (runs in project virtual environment)
└── utils.py # Script name: "utils" (runs in same project virtual environment)
User Simple Script:
~/.pylon/
├── greet.py # Script name: "greet"
└── backup.py # Script name: "backup"
User Project Script:
~/.pylon/myproject/
├── pyproject.toml # Project configuration
├── task1.py # Script name: "task1" (has its own virtual environment)
└── task2.py # Script name: "task2" (has its own virtual environment)
Script Discovery
Pylon discovers scripts in two locations: the current project directory and the user scripts directory (~/.pylon).
In the current project directory, Pylon looks for .py files. If a pyproject.toml file exists in the current directory, all .py files are treated as project scripts and share a common virtual environment managed by the project dependencies.
In the user scripts directory, Pylon looks for both simple scripts (.py files directly in ~/.pylon) and project scripts (directories containing pyproject.toml and .py files). For project scripts in the user directory, each .py file is treated as a separate script with its own virtual environment.
Virtual Environment Management
For project-based scripts (those with pyproject.toml), Pylon:
- Creates virtual environments in
~/.pylon/.venvs/(hashed by project path) - Installs dependencies from
pyproject.tomlusingpip install -e . - Reuses existing virtual environments when available
Script Shadowing
If a script with the same name exists in both the current directory and user directory, the current directory script takes precedence (script shadowing).
Duplicate Detection
Duplicate script names within the same search location (user or project) will cause an error.
Examples
Basic Usage
If you have a script named hello.py in your current directory:
pylon hello
This will execute hello.py using the current Python interpreter.
With Arguments
You can pass arguments to your script:
pylon hello --name="World" --verbose
User Scripts
You can store scripts in your user's .pylon directory (~/.pylon) to make them globally accessible:
- Create a script file in
~/.pylon/myscript.py - Run it from anywhere:
pylon myscript arg1 arg2
Project-Based Scripts
For scripts with dependencies:
- Create a directory in
~/.pylon/myproject/ - Add
pyproject.tomlwith dependencies - Add your script
myscript.pyin the same directory - Run it:
pylon myscript
Pylon will automatically create a virtual environment and install dependencies.
Example Script
Create a file called greet.py in your current directory:
import sys
def main():
name = sys.argv[1] if len(sys.argv) > 1 else "World"
print(f"Hello, {name}!")
if __name__ == "__main__":
main()
Then run it with:
pylon greet Alice
# Output: Hello, Alice!
Available Scripts
When you run pylon without any arguments, it will show you all available scripts in both the current directory and the user's .pylon directory, along with their type and location.
Requirements
- Python 3.13 or higher
License
This project is licensed under the Apache-2.0 license.
Project details
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 pylon_cli-0.3.0.tar.gz.
File metadata
- Download URL: pylon_cli-0.3.0.tar.gz
- Upload date:
- Size: 17.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7692f106ecf43f8d2ea02699219f289a0e295a3a4d347872cb04fe6a30a1774a
|
|
| MD5 |
fffd82d20f4b20857dd1e05df29e2896
|
|
| BLAKE2b-256 |
ee899351b5ad753ee86dede64499d0b8dbcb1d58c54cf86cabafc7a6770ea3d7
|
File details
Details for the file pylon_cli-0.3.0-py3-none-any.whl.
File metadata
- Download URL: pylon_cli-0.3.0-py3-none-any.whl
- Upload date:
- Size: 9.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4156e0d213a8863062d128794931f1510b0527ed0f56885de93dae4d597fd882
|
|
| MD5 |
2dc16b8937082aa8226e5313e9a3a2f8
|
|
| BLAKE2b-256 |
fa31a7ccd053b0377ddac37a50a1cb2ddffa2b72b1e99cd7059b3f028337b2f3
|