Skip to main content

Fuzzy Python module runner for uv

Project description

pymrun

Run Python modules by basename with uv.

What it does

pymrun indexes all .py files under your project root (detected by pyproject.toml or requirements.txt) and lets you run them as fully-qualified modules by basename instead of typing the full dotted path.

Given a project like:

myproject/
├── pyproject.toml
└── src/
    └── myapp/
        ├── main.py
        └── utils/
            └── helper.py

You can run:

pymrun helper          # instead of: uv run -m src.myapp.utils.helper
pymrun main            # instead of: uv run -m src.myapp.main

Requirements

  • Python ≥ 3.10
  • uv installed and available on your $PATH

Installation

pip install pymrun

Or with uv:

uv pip install pymrun

Usage

Run a module by basename

# Run src/myapp/utils/helper.py
pymrun helper

Forward arguments to the module

Use -- to separate pymrun arguments from the module's arguments:

pymrun helper -- --flag value --verbose

Duplicate basenames

If multiple files share the same basename (e.g., two main.py files), pymrun lists them and prompts you to choose:

$ pymrun main
Multiple modules named 'main' found:
  1. src.myapp.main
  2. src.myapp.subpkg.main
Select module [1]:

No arguments

Running pymrun without arguments shows the help text:

pymrun

Shell Completion

Bash / Zsh / Fish

Install completion for your current shell:

pymrun --install-completion

If auto-detection fails, specify the shell explicitly:

pymrun --install-completion --shell=zsh

Then restart your terminal or source your rc file.

Manual setup (any shell)

You can also source the generated completion script directly:

# Bash example
eval "$(_PYMRUN_COMPLETE=bash_source pymrun)"

How it works

  1. Root detection — Walks up from the current directory looking for pyproject.toml or requirements.txt.
  2. Indexing — Recursively scans the project for *.py files, skipping common build, cache, and hidden directories (__pycache__, .venv, .git, dist, build, node_modules).
  3. Execution — Converts the chosen file to a fully-qualified module name and replaces the current process with uv run -m <module> via os.execvp, so signals (e.g., Ctrl-C) flow directly to uv.

Development

Setup

# Clone the repository
git clone https://github.com/yourusername/pymrun.git
cd pymrun

# Create virtual environment and install dependencies
uv venv
source .venv/bin/activate  # or .venv\Scripts\activate on Windows
uv pip install --group dev --group lint -e .

Running tests

pytest

Or with tox across multiple Python versions:

tox

Linting and type checking

tox -e lint

Or manually:

ruff check .
ruff format --check .
pyright

Contributing

This project uses Conventional Commits for automatic semantic versioning:

  • feat: → minor version bump
  • fix: → patch version bump
  • BREAKING CHANGE: in commit footer → major version bump

License

MIT

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

pymrun-1.0.1.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

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

pymrun-1.0.1-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file pymrun-1.0.1.tar.gz.

File metadata

  • Download URL: pymrun-1.0.1.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pymrun-1.0.1.tar.gz
Algorithm Hash digest
SHA256 4d4c758e1e96cbe2a773f27da16560b4cfa4badb805f0e8d9b42d36c250cc8c6
MD5 88f17236e9ab4d67c07cfc3950b33804
BLAKE2b-256 8145f206b4bd97b338db7c089b78530fb25c7ca977f29450773d46d21db6e29c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymrun-1.0.1.tar.gz:

Publisher: ci.yml on Lamanaable/pymrun

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

File details

Details for the file pymrun-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: pymrun-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pymrun-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 335d05c121e20adc11e7bac727204c40a339da5d69240c30a4126387408382c1
MD5 337ce3f2dba4eea85533c80cf9e02503
BLAKE2b-256 b4bfeca403db9b40fe40f3507fdc17e9d59e86ce608c8c42e0ebb216067d8c24

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymrun-1.0.1-py3-none-any.whl:

Publisher: ci.yml on Lamanaable/pymrun

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