A class providing more control over libraries using pip
Project description
libManager
libManager is a Python class for managing project dependencies, including installation, information retrieval, dependency resolution, and creating a requirements.txt file.
Overview
libManager simplifies dependency management in a project. This class enables:
- Checking installed libraries.
- Automatically installing required libraries.
- Automatically deleting libraries, including their dependencies that are not used in side-libraries.
- Retrieving information about libraries.
- Generating a
requirements.txtfile for dependency management.
Requirements
- Python 3.x
pippackage manager installed
Installation
Clone the repository and import the libManager class into your project.
from lib_manager import libManager
Usage
1. Initialization
Create an instance of the libManager class:
manager = libManager()
2. Retrieving a List of Installed Libraries
Use the get_installed_libs method to retrieve a list of installed libraries:
installed_libs = manager.get_installed_libs()
3. Installing Libraries
To install a set of required libraries, call the following method:
manager = libManager()
manager.libraries_needed = {'numpy', 'pandas'}
manager.init_libs()
Or do it right at the initialization:
#By default libManager will initialize the libraries after getting the set of libraries
manager = libManager({'numpy', 'pandas'})
4. Deleting Libraries
To delete all of the libraries that are stated libraries_needed, including their dependencies, call the deinit_libs() method:
#Initialize libraries we need
manager = libManager({'numpy', 'pandas'})
import numpy
import pandas
#Work goes here
#Shall we clean up after hard work?
manager.deinit_libs()
It should be noted that it deletes only those libraries that are not used in other side-libraries.
5. Creating a requirements.txt File
To create a requirements.txt file, use create_actual_requirements():
manager = libManager()
manager.create_actual_requirements("*path_to_file*.py")
Thus, libManager will try to create requirements.txt based only on your project file.
However, if there are libraries that practically can not be got from the file, you can directly state them in additional_libs argument:
manager.create_actual_requirements("*path_to_file,py*", additional_libs={"aiohttp"})
Methods
get_installed_libs: Returns a set of installed libraries. Can focribly get update of installed libraries via settingupdateargument toTrueinit_libs: Installs specified libraries basing onlibraries_needed.deinit_libs: Delets specified libraries and their dependencies basing onlibraries_neededcreate_actual_requirements: Creates a requirements.txt file basing on targetfile.py.
License
This project is licensed under the MIT License.
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 libManager-0.1.1.tar.gz.
File metadata
- Download URL: libManager-0.1.1.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32179d73129b2fa5b635451074fc907b48c0b7ba8e865f83ba054b2864e2c4c8
|
|
| MD5 |
302b04f4180822e5aba29a97b44ee570
|
|
| BLAKE2b-256 |
4828f782e9381c0ee14f16f06f54e457bd9280f8c77982e2c9d79bba4353080d
|
File details
Details for the file libManager-0.1.1-py3-none-any.whl.
File metadata
- Download URL: libManager-0.1.1-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d9642d0b84ae4afe4370bf1086b8e48e63fcac1b9a171e293bb6a54dc957e465
|
|
| MD5 |
176628af40ed984654d96028fd9769e9
|
|
| BLAKE2b-256 |
5189b52c712e507efbaf12939456ea66534a959e437793361e2ce1d0f7609826
|