Skip to main content

Rqmts

PyPI Download/Month PyPI Version PyPI license PyPI pyversions PyPI implementation

Rqmts - Generate requirements.txt file for any project by analysing package imports

Rqmts logo
Click here to see the demo.
Click here for documentation.

About the project

Rqmts is a fantastic stand-alone tool which generates requirements.txt file for any project by analysing package imports.

It does not requires any dependency (works out-of-the-box), not needs internet to work (is completely offline, upto this moment), nor uses regular expressions in such a violent way as existing projects do. Instead, it uses simple heuristic techniques and parse conditional trees, which is a better method for extracting imported names from statements, functions, etc.

Why this project

Questions

  • Why not just use pip's freeze command to generate a requirements.txt file for my project?
  • Why to re-invent the wheel when there are modules such as pipreqs, pigar, poetry already present?
  • Why not manually?

Answers

  • Why not just pip freeze?
    • pip freeze only saves the packages that are installed with pip install in your environment.
    • pip freeze saves all packages in the environment including those that you don't use in your current project. (if you don't have virtualenv)
  • Why re-invent the wheel (?)
    • pipreqs fails on many occasions (see - pipreqs/issues)
    • pigar queries pypi servers, big no-no. Ideally, it should be local, on fallback? then maybe. Other than that, pigar recommends using Pipenv (pipenv has serious issues)
    • poetry quotes "Be aware, however, that it will also install poetry's dependencies which might cause conflicts."
    • Sheer curiousity. "can I create a project that has potential of collecting thosands of stars and most importantly, hundreds of contributors?"
  • Manually?
    • Are you serious right now?

Installation

Use pip to install rqmts. This is the recommended way of running Rqmts.

Installation Guide

Rqmts also provides a script that will run a rqmts instance isolated from the rest of your system by using file-less/memory-based execution.

curl -sSL https://raw.githubusercontent.com/0x48piraj/rqmts/master/Rqmts.py | python

Alternatively, you can download Rqmts.py from the root directory and execute it separately.

Usage

Command-line Interface and Interactive mode

Usage Demo

Challenges

The major challenge of this project is to extract the required metadata from modules which are first extracted from the input script.

  • Version numbers in python can be in very different places depending on the case
  • Package name in the package index is independent of the module name we import

and these quirks make this project interesting. There's a funny comment in the source which reflects the diversity between us and it goes like :

# module_name.__version__ sucks, because we suck (PEP 0396)

This project aims to combine the best existing strategies to cover the broadest possible set of cases (if not all). The project was built keeping in mind the modular programming paradigms and so other than being readable it's easily extensible making it possible to add new strategies/algorithms quickly.

Changelog

Playing with different versions? Read the Changelog.

Contribute

All patches are Welcome! Please see CONTRIBUTING.md for further details. For discussions, create a new issue or ping me over Twitter

Again, if you have any issues or suggestions/patches, please do not hesitate to open an issue or a pull request!

Running the tests

This project uses unittest.

The Python unit testing framework, sometimes referred to as "PyUnit," is a Python language version of JUnit, by Kent Beck and Erich Gamma. JUnit is, in turn, a Java version of Kent’s Smalltalk testing framework. Each is the de facto standard unit testing framework for its respective language.

You may need to install the package (rqmts) for setup beforehand, using

pip install --user rqmts

All tests are encapsulated in one single script named testsuite.py and all the respective test-cases are under tests/testcases/

For getting started,

python tests/testsuite.py

License

This software is licensed under BSD 3-Clause "New" or "Revised" License. To view a copy of this license, visit BSD 3-Clause.

Metadata

Release files for rqmts 2.0.3

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

Source distribution (sdist)

Source distribution for rqmts 2.0.3
File Size Uploaded Provenance
rqmts-2.0.3.tar.gz 608.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for rqmts 2.0.3
File Interpreter ABI Platform
rqmts-2.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 617.6 kB

Release files / rqmts-2.0.3.tar.gz

Download URL rqmts-2.0.3.tar.gz
Size 608.9 kB
Tags Source
SHA-256 checksum
How to use checksums
1a588aa6a73a842e3473733480199de893876545e4b8c6f0898be7242ac8c531
BLAKE2b-256 checksum
How to use checksums
8834349f114684711fc992943596e8ae6c85b487bfe0e71897e1df2832820302
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.11.1 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

Release files / rqmts-2.0.3-py3-none-any.whl

Download URL rqmts-2.0.3-py3-none-any.whl
Size 8.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
97dc17665ddf51bcd39cf25758b9a648f44ba0aa50615a280587ad9d50d05eec
BLAKE2b-256 checksum
How to use checksums
2a76b234be01a1b80035da2c858cef2e5eee16030384ecbcf85542fe78f5cd2d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.11.1 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

Security for rqmts 2.0.3

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