0x48piraj / rqmts

rqmts - Generate pip requirements.txt file for any project
BSD 3-Clause "New" or "Revised" License
5 stars 3 forks source link
generator heuristics pip python python-library python-package requirements-dependencies

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

Answers

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.

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.