Skip to main content

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 GitHub View on PyPI (Note: PyPI version may have issues, if so use source code by cloning )

Downloads Downloads Downloads

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

  1. 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
    
  2. 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

  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. Default is 'flexible_requirements.txt'
  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 file for details.

Metadata

Release files for flexible-requirements 0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flexible-requirements 0.1.6
File Size Uploaded Provenance Actions
flexible-requirements-0.1.6.tar.gz 7.6 kB Without provenance Details for flexible-requirements-0.1.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for flexible-requirements 0.1.6
File Interpreter ABI Platform Actions
flexible_requirements-0.1.6-py3-none-any.whl Python 3 none any Details for flexible_requirements-0.1.6-py3-none-any.whl

Total release size: 17.5 kB

Release files / flexible-requirements-0.1.6.tar.gz

Download URL flexible-requirements-0.1.6.tar.gz
Size 7.6 kB
Tags Source
SHA-256 checksum
How to use checksums
c5085755044ff5793e1d412c30a9c7e18e011382446ce46fde74cd5f6df10fd6
BLAKE2b-256 checksum
How to use checksums
ab7e55d35bf202d6bb66c0c32dd561aa502e3f3516978be0c073160d19759622
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.10

Release files / flexible_requirements-0.1.6-py3-none-any.whl

Download URL flexible_requirements-0.1.6-py3-none-any.whl
Size 9.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b65a5980f544207e056e933851532cfc99c9d2d49de34870ac5410027a3077c0
BLAKE2b-256 checksum
How to use checksums
9a63eb172954ad7408853a216dc28c8e843fd46877eec2dd4396dcf12033eeab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.10

Security for flexible-requirements 0.1.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page