Skip to main content

Run any Python script with automatic environment setup, fast package resolution via uv, and reproducible lockfile generation

Project description

Python Package PyPI PyPI Downloadst

smartrun

Run any Python script in a clean, disposable virtual environment — automatically.

smartrun 🚀

Run Python and Jupyter files with zero setup, zero pollution. Just run it. smartrun scans your script or notebook, detects the required third-party packages, creates (or reuses) an isolated environment, installs what’s missing — and runs your code. ✅ No more ModuleNotFoundError
✅ No more cluttered global site-packages
✅ Just clean, reproducible execution — every time

Features

  • 🧪 Supports both .py and .ipynb files
  • 🔍 Automatically detects and resolves imports
  • 🛠️ Uses venv or fast uv environments (if available)
  • 📦 Installs only what's needed, only when needed
  • 💡 Reuses environments smartly to save time

Installation

🔹 Basic usage

pip install smartrun

This includes support for:

  • Running standard Python scripts
  • Automatic environment setup
  • Fast dependency resolution with uv
  • Reproducible installs via pip-tools 🔹 With Jupyter notebook support If you want to run .ipynb notebook files using smartrun, install the optional jupyter dependencies:
pip install "smartrun[jupyter]"

🔹 Development install (optional) For contributors and development work, install with:

pip install "smartrun[dev,jupyter]"

Requires Python 3.10+


Create an environment

✅ Create an environment : Windows / macOS / Linux

smartrun env .venv

✅ Activate the environment: Windows

 .venv\Scripts\activate
🐧 macOS/Linux ✅ Activate the environment: macOS/Linux ```bash source .venv/bin/activate ```
🪟 Windows ✅ Activate the environment: Windows ```bash .venv\Scripts\activate ```
Tip: smartrun will automatically create and manage a virtual environment if none is activated — but you're always free to bring your own. ✅ Run the script: Windows / macOS / Linux ```bash smartrun some_file.py ``` ✅ Run the jupyter file: Windows / macOS / Linux ```bash smartrun some_file.ipynb ```

Usage

smartrun your_script.py

Notebook

smartrun your_notebook.ipynb

Example file that we want to run

📄 some_file.py

# smartrun: numpy>=1.24 pandas>=2.0 rich>=13.0

import numpy as np
import pandas as pd
from rich import print

df = pd.DataFrame(np.random.randn(5, 3), columns=list("ABC"))
print("Data:")
print(df, end="\n\n")
print("Column means:")
print(df.mean())

✅ What SmartRun Does

Parses the comment for package names: numpy, pandas, rich

Creates or reuses a .venv

Installs any missing packages (via uv or pip)

Runs the script

No requirements.txt. No pip install. Just run the file.

Data Science Examples

🌸 Iris dataset analysis ```python # iris.py import seaborn as sns import pandas as pd import matplotlib.pyplot as plt # Load data df = sns.load_dataset('iris') # Show first few rows and summary print(df.head(), end="\n\n") print(df.describe(), end="\n\n") # Plot pairwise relationships sns.pairplot(df, hue='species') plt.savefig('iris_pairplot.png') ``` ```bash smartrun iris.py ```
🐼 Titanic Dataset demo ```python # titanic.ipynb import pandas as pd import seaborn as sns import matplotlib.pyplot as plt # Load dataset from GitHub url = 'https://raw.githubusercontent.com/datasciencedojo/datasets/master/titanic.csv' df = pd.read_csv(url) # Basic stats print(df[['Survived', 'Pclass', 'Sex']].groupby(['Pclass', 'Sex']).mean()) # Plot survival by class sns.countplot(data=df, x='Pclass', hue='Survived') plt.title('Survival Count by Passenger Class') plt.savefig('titanic_survival_by_class.png') print("Saved plot → titanic_survival_by_class.png") ``` ```bash smartrun titanic.ipynb ```
If the dependencies aren’t installed yet, `smartrun` will fetch them automatically. ## Why smartrun? Because setup should never block you from running great code. Whether you're experimenting, prototyping, or sharing — smartrun ensures your script runs smoothly, without dependency drama. ## Contributing Contributions are welcome! 🧑‍💻 If you’ve got ideas, bug fixes, or improvements — feel free to open an issue or a pull request. Let’s make smartrun even smarter together. ## License BSD 3‑Clause — see `LICENSE` for details. ---

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

smartrun-0.2.39.tar.gz (33.3 kB view details)

Uploaded Source

Built Distribution

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

smartrun-0.2.39-py3-none-any.whl (43.1 kB view details)

Uploaded Python 3

File details

Details for the file smartrun-0.2.39.tar.gz.

File metadata

  • Download URL: smartrun-0.2.39.tar.gz
  • Upload date:
  • Size: 33.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.1

File hashes

Hashes for smartrun-0.2.39.tar.gz
Algorithm Hash digest
SHA256 ce4ced9ea260d8d59e7e221ad90fd7e795c80b676ca470aff01f3198c5853e77
MD5 65a9be78c986b7f3a2fb925d326232e9
BLAKE2b-256 64345fa3a800004741b49f58b1343977cbc5c6e600f1719cfb64e7433c2dda2d

See more details on using hashes here.

File details

Details for the file smartrun-0.2.39-py3-none-any.whl.

File metadata

  • Download URL: smartrun-0.2.39-py3-none-any.whl
  • Upload date:
  • Size: 43.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.1

File hashes

Hashes for smartrun-0.2.39-py3-none-any.whl
Algorithm Hash digest
SHA256 cc36244a922a55505e891c25b161c9c10e7d2b665903c6f6d02c0f3877db3201
MD5 b4b2e3f3210dd94405e2de6c349cabcb
BLAKE2b-256 f9ae36045c0842893ba4b67b1935835c3eefa48073d15b54f174180876f0aba9

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