Metadata-Version: 2.4
Name: smartrun
Version: 0.2.31
Summary: Run any Python script with automatic environment setup, fast package resolution via uv, and reproducible lockfile generation
Project-URL: Repository, https://github.com/SermetPekin/smartrun
Project-URL: Homepage, https://github.com/SermetPekin/smartrun
Project-URL: Documentation, https://smartrun.readthedocs.io/en/latest/home.html
Project-URL: Issues, https://github.com/SermetPekin/smartrun/issues
Project-URL: Changelog, https://github.com/SermetPekin/smartrun/releases
Author-email: Sermet Pekin <Sermet.Pekin@gmail.com>
License: BSD 3-Clause License
        
        Copyright (c) 2025, Sermet Pekin
        
        Redistribution and use in source and binary forms, with or without
        modification, are permitted provided that the following conditions are met:
        
        1. Redistributions of source code must retain the above copyright notice, this
           list of conditions and the following disclaimer.
        
        2. Redistributions in binary form must reproduce the above copyright notice,
           this list of conditions and the following disclaimer in the documentation
           and/or other materials provided with the distribution.
        
        3. Neither the name of the copyright holder nor the names of its
           contributors may be used to endorse or promote products derived from
           this software without specific prior written permission.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
        AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
        FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
        SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
        CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
        OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
        OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
License-File: LICENSE
Classifier: License :: OSI Approved :: BSD License
Requires-Python: >=3.10
Requires-Dist: pip-tools>=7.4.1
Requires-Dist: pyyaml>=6.0.2
Requires-Dist: requests>=2.32.4
Requires-Dist: rich>=14.0.0
Requires-Dist: uv>=0.7.21
Provides-Extra: dev
Requires-Dist: black>=25.1.0; extra == 'dev'
Requires-Dist: flake8>=7.3.0; extra == 'dev'
Requires-Dist: myst-parser>=4.0.1; extra == 'dev'
Requires-Dist: pytest>=8.4.1; extra == 'dev'
Requires-Dist: ruff>=0.12.3; extra == 'dev'
Provides-Extra: jupyter
Requires-Dist: ipykernel>=6.30.0; extra == 'jupyter'
Requires-Dist: nbconvert>=7.0.0; extra == 'jupyter'
Requires-Dist: nbformat>=5.10.4; extra == 'jupyter'
Description-Content-Type: text/markdown


[![Python Package](https://github.com/SermetPekin/smartrun/actions/workflows/python-package.yml/badge.svg?2)](https://github.com/SermetPekin/smartrun/actions/workflows/python-package.yml)
[![PyPI](https://img.shields.io/pypi/v/smartrun)](https://img.shields.io/pypi/v/smartrun) ![PyPI Downloads](https://static.pepy.tech/badge/smartrun?2)![t](https://img.shields.io/badge/status-maintained-yellow.svg) [![](https://img.shields.io/github/license/SermetPekin/smartrun.svg)](https://github.com/SermetPekin/smartrun/blob/master/LICENSE.md) [![](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/) 
# 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
```bash
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:
```bash
pip install "smartrun[jupyter]"
```
🔹 Development install (optional)
For contributors and development work, install with:
```bash
pip install "smartrun[dev,jupyter]"
```
> **Requires Python 3.10+**
---
## Usage
```bash
smartrun your_script.py
```
## Notebook
```bash
smartrun your_notebook.ipynb
```
## Example file that we want to run
```python
#some_file.py
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())
```
## Create an environment 
✅ Create an environment : Windows / macOS / Linux
```bash
smartrun env .venv
```
✅ Activate the environment:
Windows
```bash
 .venv\Scripts\activate
```
<details>
 <summary>🐧 macOS/Linux</summary> 
✅ Activate the environment: macOS/Linux
```bash
 source .venv/bin/activate
```
</details> 
<details>
  <summary>🪟 Windows</summary>
  ✅ Activate the environment:
Windows
```bash
.venv\Scripts\activate
```
</details> 
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
```
### Data Science Examples
<details><summary>🌸 Iris dataset analysis</summary>
```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
```
</details> 
<details><summary>🐼 Titanic Dataset demo</summary>
```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
```
</details> 
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.  
---
