A library for generating flexible Python requirements
Project description
Flexible Requirements Generator
This tool generates a flexible requirements.txt
file from an existing one, helping to resolve version conflicts and compatibility issues in Python projects.
Features
- Checks package compatibility with PyPI without installing packages
- Supports both concurrent and sequential processing
- Keeps compatible requirements, loosens incompatible ones, and comments out unavailable packages
- Provides detailed information about each requirement's status
- Handles platform-specific package availability
- Includes comprehensive logging for better visibility and debugging
Installation
- Clone this repository:
git clone [https://github.com/yourusername/flexible-requirements-generator.git](https://github.com/benny-png/Flexible-Requirements-python-LIBRARY.git) cd Flexible-Requirements-python-LIBRARY pip install own_requirements.txt
- Install the required dependencies:
pip install requests packaging
Usage
Run the script from the command line: Default
python main.py
or Modular
python main.py [input_file] [output_file] [--sequential] [--fast] [--log {DEBUG,INFO,WARNING,ERROR,CRITICAL}]
input_file
: Path to the input requirements file (default:requirements.txt
)output_file
: Path to the output flexible requirements file (default:flexible_requirements.txt
)--sequential
: Use sequential processing instead of concurrent (optional)--log
: Set the logging level (default: INFO)--fast
: Faster but not that accurate and not perfected yet/tested well
Example:
python main.py my_requirements.txt my_flexible_requirements.txt --sequential --log --fast DEBUG
How it works
- The script reads the input requirements file.
- For each requirement, it checks the package's availability and version compatibility using the PyPI JSON API.
- It considers the current platform (e.g., Windows, Linux, macOS) when checking for compatible versions.
- Based on the results, it either:
- Keeps the requirement as-is if it's compatible
- Loosens the version constraint if no compatible version is found for the current platform
- Comments out the requirement if the package is not available on PyPI or for the current platform
- The processed requirements are written to the output file with explanatory comments.
- Detailed logs are provided throughout the process for better visibility and debugging.
Output
The generated flexible requirements file includes:
- The original requirements (kept, loosened, or commented out)
- Comments explaining the status of each requirement
- Information about compatible versions or reasons for changes
Performance
The script supports both concurrent and sequential processing. Concurrent processing is faster but may be limited by API rate limits. Sequential processing is slower but more reliable for large requirement files.
Limitations
- Relies on the PyPI JSON API, so it requires an internet connection
- Does not handle dependencies of packages, only direct requirements
- May be affected by PyPI API rate limits when processing large files concurrently
- Platform-specific package availability may result in different outputs on different systems
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
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
File details
Details for the file flexible_requirements-0.1.1.tar.gz
.
File metadata
- Download URL: flexible_requirements-0.1.1.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc50b9141b9500a84c2b88c8755d8ea267ec182b0f4e663d92c33e3cb489ee0b |
|
MD5 | 6d90013c3ac0179ae46fbb9a36e565ce |
|
BLAKE2b-256 | a8034c9c13dd31ea551f364fd1c9ba06f440578ff0412e22a2fd053061d787bd |
File details
Details for the file flexible_requirements-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: flexible_requirements-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dddb00e27f6f34899bf39f19d227360cfaecdfe81268cfbd5dfa1fcfd64e2783 |
|
MD5 | d6ade7d6e7457fd30d242fd9d9be1899 |
|
BLAKE2b-256 | 90757274e8ab8e10a5ceba7d8fdb5f75420db6887d14bce82407e8d551da4ec4 |