https://github.com/simone-contorno/py-manager
Provides tools for managing Python packages and virtual environments. It includes scripts for automating package updates and comprehensive virtual environment management with easy creation, activation, and dependency handling.
https://github.com/simone-contorno/py-manager
json package-update python3 virtual-environments
Last synced: 2 months ago
JSON representation
Provides tools for managing Python packages and virtual environments. It includes scripts for automating package updates and comprehensive virtual environment management with easy creation, activation, and dependency handling.
- Host: GitHub
- URL: https://github.com/simone-contorno/py-manager
- Owner: simone-contorno
- License: mit
- Created: 2025-03-03T09:13:47.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-27T19:44:53.000Z (about 1 year ago)
- Last Synced: 2025-06-19T18:45:46.752Z (about 1 year ago)
- Topics: json, package-update, python3, virtual-environments
- Language: Python
- Homepage:
- Size: 75.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Python Manager
## Overview
Py-Manager is a comprehensive toolkit for Python development environment management. It provides two main utilities:
1. **Python Package Manager** - Automates the process of updating Python packages while intelligently handling dependency conflicts, maintaining logs, and respecting package blacklists.
2. **Virtual Environment Manager** - Simplifies the creation, activation, and management of multiple Python virtual environments with tools for generating requirements files and installing dependencies across environments.
Designed to streamline Python development workflows, this project helps maintain clean, organized, and conflict-free Python environments.
## Features
### Package Management
- Automatically creates a `logs/` directory and maintains timestamped logs.
- Loads configuration from `package_config.json`, allowing package blacklisting and specific version enforcement.
- Upgrades `pip` to the latest version.
- Lists all outdated packages.
- Checks for dependency conflicts before upgrading.
- Upgrades packages while considering blacklists and specific version constraints.
- Detects and suggests packages to add to the blacklist based on recurring dependency issues.
- Provides a detailed summary after upgrades.
### Virtual Environment Management
- **Create and manage** multiple Python virtual environments
- **Generate and update** requirements files for each environment
- **Install dependencies** from one environment to another
- **Quick activation** with Windows batch file aliases
- **Clean removal** of environments and their associated batch files
## Requirements
- Python 3.x
- `pip` (installed by default with Python)
All dependencies are listed in the `requirements.txt` file. Most are standard libraries included with Python.
## Installation
Clone this repository and navigate to the directory:
```bash
git clone https://github.com/simone-contorno/py-manager
cd py-manager
```
No additional installation is required as the project primarily uses standard Python libraries. If needed, you can install the few external dependencies with:
```bash
pip install -r requirements.txt
```
## Project Structure
```
py-manager/
├── py_packages_update.py # Package update script
├── py_env_manager.py # Virtual environment management script
├── create_venv_alias.py # Script to create batch file aliases for environments
├── package_config.json # Configuration for package updates
├── requirements.txt # Project dependencies
├── venv/ # Directory containing all virtual environments
│ ├── environments/ # Individual virtual environments
│ └── requirements/ # Requirements files for each environment
├── bat/ # Directory containing batch file aliases
└── logs/ # Logs from package update operations
```
## Configuration
Edit the `package_config.json` file to specify blacklisted packages and version-specific requirements:
```json
{
"blacklist": [
"package_name_1",
"...",
"package_name_k"
],
"specific_versions": {
"package_name_k+1": "x.x.x",
"...": "x.x.x",
"package_name_n": "x.x.x",
}
}
```
- `blacklist`: Packages in this list will not be upgraded.
- `specific_versions`: Specifies exact versions for certain packages.
## Usage
### Package Update Tool
Run the package update script with:
```bash
python py_packages_update.py
```
#### Main Functions
- **Logging**: All actions are logged in a timestamped file inside the logs/ directory.
- **Upgrade pip**: Ensures pip is at the latest version.
- **Check outdated packages**: Lists outdated packages using pip list --outdated.
- **Check dependency conflicts**: Uses pip check to identify dependency issues.
- **Upgrade packages**: Upgrades packages, skipping blacklisted ones and respecting specific version constraints.
- **Handle dependency issues**: Detects and suggests adding problematic packages to the blacklist.
- **Summary report**: Displays and logs a detailed report of successful, failed, and skipped upgrades.
### Virtual Environment Manager
Run the virtual environment management script to access the interactive menu:
```bash
python py_env_manager.py
```
This will display a menu with the following options:
1. **Create** a new virtual environment
2. **Activate** a virtual environment
3. **Deactivate** the active virtual environment
4. **Generate/Update** requirements.txt file
5. **Install dependencies** from requirements.txt
6. **Install dependencies** from one environment to another
7. **Delete** a virtual environment (also removes associated bat file)
8. **List** virtual environments
9. **Exit**
### Batch File Aliases
To create batch file aliases for quick activation of your environments:
```bash
python create_venv_alias.py
```
This will create `.bat` files in the `bat` directory that you can use to quickly activate environments by simply running the batch file.
Example:
```bash
.\bat\activate_myenv.bat
```
## Example Output
```plaintext
🔍 Checking for outdated packages...
📦 Found 5 outdated packages.
⬆️ Upgrading pip...
✅ pip upgraded to the latest version.
🔄 Updating: numpy (1/5)
✅ Successfully upgraded numpy
...
✅ Upgrade process completed!
```
## Error Handling
- If a package upgrade fails, the error message is logged.
- If dependency conflicts are detected, the user is prompted with options to resolve them.
- If the `package_config.json` file is missing, a default one is created.
- If logs cannot be written due to permission errors, the script provides troubleshooting suggestions.
## License
This project is open-source under the [MIT License](LICENSE).