A library for generating flexible Python requirements
Project description
# Flexible Requirements Generator
[GET ITS PYPI HERE](https://pypi.org/project/flexible-requirements/0.1.0/)
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
1. Install the package from PyPI:
pip install flexible-requirements
2. Alternatively, you can 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
## Usage
Run the script from the command line:
### Default Usage
flexible-requirements
### Modular Usage
flexible-requirements [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
flexible-requirements my_requirements.txt my_flexible_requirements.txt --sequential --log DEBUG --fast
## How it works
1. The script reads the input requirements file.
2. For each requirement, it checks the package's availability and version compatibility using the PyPI JSON API.
3. It considers the current platform (e.g., Windows, Linux, macOS) when checking for compatible versions.
4. 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
5. The processed requirements are written to the output file with explanatory comments.
6. 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](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.2.tar.gz
.
File metadata
- Download URL: flexible_requirements-0.1.2.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac4c575a023b415f6d86453331e2f12866e2b5a93fd2de1bb47a570d5a920be8 |
|
MD5 | 27acc322acf3de1c63d8b6d8e2f2ec20 |
|
BLAKE2b-256 | d84899fd4b52e632c9bb7eeb367baf0e2cd9dfc10c89ff09f86d11b8bb0f8e09 |
File details
Details for the file flexible_requirements-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: flexible_requirements-0.1.2-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 | 251c9b0df3677fe3d9820dcb9d73ea9261a444e1e243f61869d86a82b928e25e |
|
MD5 | 7c64073d3d75abc3dbdddbabca056457 |
|
BLAKE2b-256 | 7d4103a031a25ab1de69bf788f1e39320ef534176ac47de354e038a0c9f687c2 |