Automated Python environment management tool that scans imports, installs dependencies, and generates requirements.txt
Project description
MetaEnv
Automated Python environment management tool
Ever cloned a Python project and spent 30 minutes figuring out dependencies? Yeah, me too. That's why I built MetaEnv.
MetaEnv automatically scans your project for imports, creates a virtual environment, installs everything you need, and generates a clean requirements.txt file. No more manual setup headaches.
Why you'll love it:
- ๐ One command to set up any Python project
- ๐ฆ No more "ModuleNotFoundError" surprises
- ๐ง Works across different machines (finally!)
- โก Saves you from dependency hell
๐ฏ Overall Objective
โ Automatically set up a Python virtual environment
โ Detect dependencies directly by scanning project imports
โ Install all required third-party libraries seamlessly
โ Allow optional control over Python version
โ Generate requirements.txt with pinned versions
โ Provide utility commands for scanning, cleaning, running, and installing
โ Ensure reproducible, consistent environments across machines
โ Save onboarding time and simplify environment management
Quick Start
Installation
# Install metaenv
pip install -e .
Basic Usage
# 1. Full automatic setup (one command!)
metaenv create
# 2. Create with specific Python version
metaenv create --python 3.11
# 3. Generate requirements.txt
metaenv generate
# 4. Scan imports only (no install)
metaenv scan
# 5. Install into existing environment
metaenv install
# 6. Clean/remove environment
metaenv clean
# 7. Run script in managed environment
metaenv run app.py
๐ฅ CLI Command Overview
1. Default Command โ Full Automatic Setup
metaenv create
What it does:
- โ Detects available Python version
- โ Creates a virtual environment
- โ Scans all .py files for imports
- โ Identifies third-party dependencies
- โ Installs all required libraries
One-step complete setup!
Example output:
MetaEnv - Creating Environment
Project: /home/user/myproject
1. Virtual Environment
โ Creating virtual environment...
Python: Python 3.11.4
Pip: pip 23.2.1
2. Scanning Imports
Scanned 15 file(s)
Found 47 import statement(s)
3. Classifying Imports
Third-party: 8 package(s)
4. Resolving Package Names
cv2 โ opencv-python
sklearn โ scikit-learn
Resolved to 8 PyPI package(s)
5. Installing 8 Package(s)
โ requests
โ numpy
โ opencv-python
...
โ Environment created successfully!
2. Create Environment With a Specific Python Version
metaenv create --python 3.11
# or
metaenv create -p 3.11
What it does:
- Uses the specified Python version for the venv
- Scans imports
- Installs dependencies
Useful for compatibility or when multiple Python versions exist.
3. Generate Only a requirements.txt File
metaenv generate
What it does:
- Reads packages installed in the venv
- Generates a fully pinned requirements.txt
โ Use after modifying your environment โ Works even if no scanning/install is needed
๐งฉ Optional / Utility Commands
4. Scan Only (No Install, No Env Creation)
metaenv scan
What it does:
- Scans project imports
- Lists third-party dependencies
- Does not create environment or install packages
โ Useful for audit and checking missing libs
5. Install Only (Use Existing Environment)
metaenv install
What it does:
- Installs dependencies detected earlier
- Assumes environment already exists
โ Great when environment exists but dependencies need updating
6. Clean/Delete Existing Environment
metaenv clean
What it does:
- Removes the existing virtual environment folder (.venv)
โ Useful for resetting the environment โ Important before a fresh rebuild
7. Run a Script Using the Managed Environment
metaenv run app.py
What it does:
- Runs a Python script using the venv interpreter
- No need to manually activate the environment
โ Convenience for developers โ Guarantees correct environment usage
Project Structure
After initialization, your project will have:
your-project/
โโโ .venv/ # Virtual environment (auto-created)
โโโ .metaenv/ # MetaEnv metadata
โ โโโ config.json # Configuration
โ โโโ deps.json # Per-file dependency map
โโโ requirements.txt # Auto-generated dependencies
โโโ .gitignore # Auto-updated to exclude .venv and .metaenv
โโโ your code...
Import Resolution
MetaEnv intelligently maps import names to PyPI packages:
| Import | PyPI Package |
|---|---|
cv2 |
opencv-python |
sklearn |
scikit-learn |
skimage |
scikit-image |
bs4 |
beautifulsoup4 |
PIL |
Pillow |
yaml |
PyYAML |
dateutil |
python-dateutil |
dotenv |
python-dotenv |
MySQLdb |
mysqlclient |
psycopg2 |
psycopg2-binary |
And many more! For most packages, import name = package name.
Configuration
Configuration is stored in .metaenv/config.json:
{
"python_path": ".venv/bin/python",
"pip_path": ".venv/bin/pip",
"venv_path": ".venv",
"exclude_patterns": [
".venv",
"venv",
"__pycache__",
".git",
"node_modules",
"build",
"dist",
"*.egg-info"
],
"auto_install": true,
"index_url": ""
}
You can edit this file to customize behavior.
Command Reference
metaenv create [PATH]
Create virtual environment and install all dependencies automatically.
Options:
--python, -p VERSION- Python version to use (e.g., 3.11)
Examples:
metaenv create # Use default Python
metaenv create --python 3.11 # Use Python 3.11
metaenv create -p 3.11 # Short form
metaenv generate [PATH]
Generate requirements.txt with pinned versions.
Options:
--output, -o PATH- Output file (default: requirements.txt)
Examples:
metaenv generate # Default output
metaenv generate --output requirements-prod.txt
metaenv scan [PATH]
Scan project imports and list dependencies (no install).
Examples:
metaenv scan # Scan current directory
metaenv install [PATH]
Install dependencies into existing environment.
Examples:
metaenv install # Install in current directory
metaenv clean [PATH]
Remove the virtual environment.
Options:
--yes, -y- Skip confirmation prompt
Examples:
metaenv clean # Remove with confirmation
metaenv clean --yes # Remove without confirmation
metaenv run SCRIPT [ARGS...]
Run a Python script using the managed environment.
Examples:
metaenv run app.py
metaenv run scripts/train.py --epochs 10
Use Cases
Starting a New Project
mkdir myproject
cd myproject
# Write your Python code with imports...
metaenv create
# Everything is set up automatically!
Cloning a Repository
git clone https://github.com/user/repo.git
cd repo
metaenv create
# All dependencies detected and installed!
Using a Specific Python Version
cd myproject
metaenv create --python 3.11
# Environment created with Python 3.11
Generating Requirements for Deployment
metaenv generate
# requirements.txt created with pinned versions
Scanning Project Before Setup
# First check what dependencies are needed
metaenv scan
# Then create environment
metaenv create
Cleaning and Rebuilding Environment
# Remove old environment
metaenv clean --yes
# Create fresh environment
metaenv create
Running Scripts in Managed Environment
# No need to activate venv manually
metaenv run main.py
metaenv run tests/test_app.py
Comparison with Other Tools
| Feature | MetaEnv | pip | poetry | pipenv |
|---|---|---|---|---|
| Auto-scan imports | โ | โ | โ | โ |
| Auto-install from code | โ | โ | โ | โ |
| Venv management | โ | โ | โ | โ |
| Per-file deps | โ | โ | โ | โ |
| Zero config | โ | โ | โ | โ |
| Import resolution | โ | โ | โ | โ |
Roadmap
v0.1.0 - Core Functionality โ
- AST-based import scanner
- Smart import name resolution (cv2โopencv-python, etc.)
- Automatic virtual environment creation
- Automatic dependency installation
- CLI:
createandgeneratecommands - Requirements.txt generation with pinned versions
v0.2.0 - Enhanced Features (Planned)
- Support for pyproject.toml
- Jupyter notebook support (.ipynb files)
- Enhanced error handling and logging
- Progress indicators for long operations
v0.3.0 - Advanced Features (Future)
- Watch mode (auto-detect file changes)
- Docker integration (Dockerfile generation)
- CI/CD templates (GitHub Actions)
- IDE plugins (VSCode, PyCharm)
Documentation
For more detailed information, see:
- Quick Start Guide - Get up and running in 60 seconds
- Installation Guide - Setup instructions and troubleshooting
- Project Summary - Technical overview and architecture
Contributing
Contributions welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
License
MIT License - see LICENSE file for details.
Credits
Built with:
Made with โค๏ธ to make Python dependency management effortless
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file metaenv-0.1.0.tar.gz.
File metadata
- Download URL: metaenv-0.1.0.tar.gz
- Upload date:
- Size: 29.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c034f87fbdb58a407475386ace0d4ee4f062dea25460ed72f57e3dc3a3ac677
|
|
| MD5 |
85ec7186401a08be057a40268c334ad9
|
|
| BLAKE2b-256 |
86cb19625a26e49f2dff96c54811241540e00da77ade3940c1c692c734f18862
|
File details
Details for the file metaenv-0.1.0-py3-none-any.whl.
File metadata
- Download URL: metaenv-0.1.0-py3-none-any.whl
- Upload date:
- Size: 22.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
54cfb359f7af4dc78bbf527b21f5d9930416cb0acf5dd3c0af79ba680e58c0a8
|
|
| MD5 |
b2c3bd1b390c5694631fedb054592e75
|
|
| BLAKE2b-256 |
ddaaba16be2bfc7a230cbd2c2d3d6ff8aa34689e95e1865558813fd15148f820
|