Skip to main content

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:

  1. Current project directory (the directory you're in)
  2. 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 venv module 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, the venv-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 Scripts (two example projects):

~/.pylon/
├── greet.py          # Simple script: "greet"
├── backup.py         # Simple script: "backup"
├── project1/         # Project directory
│   ├── pyproject.toml    # Project configuration
│   ├── task1.py          # Script name: "task1" (shares virtual environment with task2)
│   └── task2.py          # Script name: "task2" (shares virtual environment with task1)
└── project2/         # Another project directory
    ├── pyproject.toml    # Project configuration
    ├── analyze.py        # Script name: "analyze" (shares virtual environment with report.py)
    └── report.py         # Script name: "report" (shares virtual environment with analyze.py)

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, all .py files in the same project directory share a common virtual environment.

Virtual Environment Management

For project-based scripts (those with pyproject.toml), Pylon:

  1. Creates virtual environments in ~/.pylon/.venvs/ (hashed by project path)
  2. Installs dependencies from pyproject.toml using pip install -e .
  3. 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:

  1. Create a script file in ~/.pylon/myscript.py
  2. Run it from anywhere:
pylon myscript arg1 arg2

Project-Based Scripts

For scripts with dependencies:

  1. Create a directory in ~/.pylon/myproject/
  2. Add pyproject.toml with dependencies
  3. Add your script myscript.py in the same directory
  4. 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

pylon_cli-0.3.1.tar.gz (17.2 kB view details)

Uploaded Source

Built Distribution

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

pylon_cli-0.3.1-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file pylon_cli-0.3.1.tar.gz.

File metadata

  • Download URL: pylon_cli-0.3.1.tar.gz
  • Upload date:
  • Size: 17.2 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

Hashes for pylon_cli-0.3.1.tar.gz
Algorithm Hash digest
SHA256 a6e0966a66a2742001090c4091a2cf6dff94f163d8516363cde6cc4d738838b7
MD5 3825e1e779815d1d57ed1d7ae7e884a1
BLAKE2b-256 9c2efabbf935e376b0b04c5513276a7174a34a9157a729c98d3d29278e4ba6c9

See more details on using hashes here.

File details

Details for the file pylon_cli-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: pylon_cli-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 9.8 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

Hashes for pylon_cli-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1373f8c14159c8ec4cb0a1a48fac361fc73eb258b675815e5ad9c39a7d30c104
MD5 3906ddbf872bb66b6a23fff51e251c97
BLAKE2b-256 956e647371e38adb381041b37efcf7dd3a4d9e82e0a7196bb46bcdbf739b94f9

See more details on using hashes here.

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