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.0.tar.gz (25.8 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.0-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pymrun-1.0.0.tar.gz
  • Upload date:
  • Size: 25.8 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.0.tar.gz
Algorithm Hash digest
SHA256 79e76263831e42797c3244a7ec7faa3fc1ecba767013e117a5bf6b8584e3ab71
MD5 20e38367002b01cfabbffad1a5fee8d4
BLAKE2b-256 61c5f75ed292a6d52b34a2aff614903e6fe35bad58b844375a70d0616274b3f0

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymrun-1.0.0.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.0-py3-none-any.whl.

File metadata

  • Download URL: pymrun-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 7.0 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2bdd9e866e89cc3f25d981080849f6ffeeb6925b655ca7465b7b46856a4451dd
MD5 00b8940aa6c04c97e9efce42d18a5252
BLAKE2b-256 e73948e447a081514fa202ac67ae1f569e5a41ac85d807d3af6e5f1f25984402

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymrun-1.0.0-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