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.
View on PyPI (Note: PyPI version may have issues, if so use source code by cloning )
Real-Life Use Cases
Perfect for teams where each member uses different Python versions, operating systems, or hardware, this tool ensures that the requirements.txt
file remains flexible and compatible across all environments, resolving version conflicts and platform-specific issues.
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 and install the dependencies manually:
git clone https://github.com/benny-png/Flexible-Requirements-python-LIBRARY.git cd Flexible-Requirements-python-LIBRARY pip install -r own_requirements.txt
-
Alternatively, you can install the package from PyPI (note: this method may have issues):
pip install flexible-requirements
Usage
1. For the cloning approach use commands
Run the script from the command line:
Default Usage
python main.py
Modular Usage
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 DEBUG --fast
2. For the PYPI package use commands
DEFAULT
flexible-requirements
OR
MODULAR
flexible-requirements [input_file] [output_file] [--sequential] [--fast] [--log {DEBUG,INFO,WARNING,ERROR,CRITICAL}]
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. Default is 'flexible_requirements.txt'
- 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.5.tar.gz
.
File metadata
- Download URL: flexible-requirements-0.1.5.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c6051120376ee8d38298d25f7bc06c29e65f830f744f24003f6a08a5ad2568f0 |
|
MD5 | 00a7b8e58b3e2868c3bb21f57a26077e |
|
BLAKE2b-256 | 29fdb253c848227e9a1507926a44c79a9e0e56267d979f38841665b4f47584e9 |
File details
Details for the file flexible_requirements-0.1.5-py3-none-any.whl
.
File metadata
- Download URL: flexible_requirements-0.1.5-py3-none-any.whl
- Upload date:
- Size: 9.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b43058e0f387306fa4a131798063edca82224c61c7bda2af2af0f8887df112d |
|
MD5 | 119b0db483054cb22472347dae2b790c |
|
BLAKE2b-256 | ee80b51f8401e251b99f5f4ab97da5e18a922c5ebd239fca8ee174b47c547d59 |