Skip to main content

Run Python scripts using the local virtual environment without activating it

Project description

localpython

Run Python scripts using your local virtual environment — without activating it manually.

localpython is a simple cross-platform CLI tool that automatically detects your local .venv, venv, or env folder and uses its Python interpreter to run a script — just like a smart alias. It can also create virtual environments and install dependencies automatically.

Features

  • Runs scripts using .venv/Scripts/python or bin/python
  • No need to activate virtual environments manually
  • Supports arguments, flags, and quoted paths
  • Automatically searches parent directories with -p
  • Creates virtual environments and installs dependencies with --setup
  • Includes --version, --which, --help

Installation

Install via pip:

pip install localpython

Usage

Basic

localpython script.py

Pass arguments to your script

localpython script.py --input file.json --debug true

Search in parent directories for a venv

localpython -p script.py --some arg

Show path to the interpreter

localpython --which

Show version

localpython --version

Create virtual environment and install dependencies

localpython --setup

This will:

  • Check if a virtual environment already exists (and warn if it does)
  • Create a .venv directory in the current location
  • Automatically detect and install dependencies from common requirements files:
    • requirements.txt, req.txt, requirements-dev.txt
    • requirements-test.txt, dev-requirements.txt, reqs.txt
    • pip-requirements.txt, requirements.pip

Example

Given a project:

myproject/
├── .venv/
├── script.py

And a command:

localpython script.py --run fast

This tool will automatically run:

./.venv/Scripts/python script.py --run fast

(Or the Unix equivalent if on Linux/Mac)

License

This project is licensed under the MIT License.

Author

Created by Yali Ach

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

localpython-0.2.0.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

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

localpython-0.2.0-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file localpython-0.2.0.tar.gz.

File metadata

  • Download URL: localpython-0.2.0.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for localpython-0.2.0.tar.gz
Algorithm Hash digest
SHA256 69c005a9e57a1c40a40d633c5dd5e8f84dcf22fd8a615fce442886db4ca1bebe
MD5 02c8d41f15c9449564bcd70a60a5dd91
BLAKE2b-256 f062867d26758752ef43de6c0f369eb2965e5cc46a632d831931027a1170632e

See more details on using hashes here.

Provenance

The following attestation bundles were made for localpython-0.2.0.tar.gz:

Publisher: publish.yml on yaliach/local-python

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

File details

Details for the file localpython-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: localpython-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for localpython-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b9673cbe283b50b4363ee2fb2321252ed23f3fadfd01e2ceac7d4b5b04ca0d97
MD5 4e817c1e35236cfc6b22f9cd3089f45b
BLAKE2b-256 63929c9e9e8286c79e8e77525be1a6d90537ce9241c148ea9766a17e7d6b9338

See more details on using hashes here.

Provenance

The following attestation bundles were made for localpython-0.2.0-py3-none-any.whl:

Publisher: publish.yml on yaliach/local-python

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