Python requirements.txt Guesser

Overview

Python-Requirements-Guesser

⚠️ This is alpha quality software. Work in progress

Attempt to guess requirements.txt modules versions based on Git history.

What is the problem ?

Did you ever clone a repo with python code that didn't specify library versions in a requirements.txt file ? Or even worst: a repo without a requirements.txt...

Reproducing results is hard, it's even harder when you have mismatched library versions.

Solution

There is a fair chance that the owner of the repo you just cloned installed most of it's packages using

pip install <package name>

This would have installed the latest available version at the time the command was runned.

Based on this, we look at the git commit history to find out when a package was first imported in the code or when it was first added to the requirements.txt file.

We then query Pypi to retrieve the version available at the commit date.

Usage

Py-Requirements-Guesser should be runned inside a git repository.

py-requirements-guesser --write {requirements.txt path}

You will be prompted by a serie of choice to orient the guessing process.

Python Requirements Guesser

Installation

This package doesn't have any dependencies. To install the Py-Requirements-Guesser:

pip3 install py-requirements-guesser

Package name mapping - Pipreqs

There might be mismatches between the name of a package on Pypi and the name used to import it (Ex : pip install PyYAML & import yaml ). There doesn't seem to be a straightforward way to do the mapping between Pypi name and import name.

The great PipReqs package (which was an inspiration for this package) manually maintains a mapping file between Pypi names and the import names. They also maintain a list of the standard library module names.

For now, we grab the mapping and stdlib files at commit 90102acdbb23c09574d27df8bd1f568d34e0cfd3.

Thanks guys !

Additional arguments

Py-Requirements-Guesser can take 2 additional parameters :

--keep_unused_packages: By default, unused packages are ignored. This parameter will force version guessing for the packages in requirements.txt that are not imported in the code anywhere.

--force_guess {package1},{package2},..: By default, if your code contains a module named yaml.py, import yaml statements won't be analyzed. Use this argument if local modules have conflicting names with Pypi packages to force version guessing.

TODO

  • Guess/Pin the dependencies tree of the package Ex : Torch package will install numpy, etc
  • Poetry support ?
  • Jupyter notebook support
  • Add guessing choice where user can choose version between the time the package was first imported and the date of the last commit on a python file
  • Detect python & os versions. Some package versions might not be available for certain os or python versions
  • Better output/UX

License

GNU GPLV3 see License

Contributing

Pull requests are welcomed ! Fill up an issue if you encounter any problem !

Owner
Jerome
Jerome
It was created to conveniently respond to events such as donation, follow, and hosting using the Alert Box provided by twip to streamers

This library is not an official library of twip. It was created to conveniently respond to events such as donation, follow, and hosting using the Alert Box provided by twip to streamers.

junah201 8 Nov 19, 2022
LinuxHelper - A collection of utilities for non-technical Linux users accessible via a GUI

Linux Helper A collection of utilities for non-technical Linux users accessible via a GUI This app is still in very early development, expect bugs and

Seth 7 Oct 03, 2022
Quantity Takeoff with Python. Collecting groups of elements by filters

The free tool QuantityTakeoff allows you to group elements from Revit and IFC models (in BIMJSON-CSV format) with just a few filters and find the required volume values for the grouped elements.

OpenDataBIM 9 Jan 06, 2023
Hy - A dialect of Lisp that's embedded in Python

Hy Lisp and Python should love each other. Let's make it happen. Hy is a Lisp dialect that's embedded in Python. Since Hy transforms its Lisp code int

Hy Society 4.4k Jan 02, 2023
A Lego Mindstorm robot for dealing out cards based on a birds-eye view of a poker table and given ArUco fiducial tags.

A Lego Mindstorm robot for dealing out cards based on a birds-eye view of a poker table and given ArUco fiducial tags.

4 Dec 06, 2021
A demo Piccolo app - a movie database!

PyMDb Welcome to the Python Movie Database! Built using Piccolo, Piccolo Admin, and FastAPI. Created for a presentation given at PyData Global 2021. R

11 Oct 16, 2022
Download and archive entire usenet newsgroups over NNTP.

Usenet Archiving Tool This code is for archiving Usenet discussions, not downloading files. Newsgroup posts are saved under the authors name and email

Corey White 2 Dec 23, 2021
This repository contains the code for the python introduction lab

This repository contains the code for the python introduction lab. The purpose is to have a fairly simple python assignment that introduces the basic features and tools of python

1 Jan 24, 2022
Pokemon catch events project to demonstrate data pipeline on AWS

Pokemon Catches Data Pipeline This is a sample project to practice end-to-end data project; Terraform is used to deploy infrastructure; Kafka is the t

Vitor Carra 4 Sep 03, 2021
Simple Crud Python vs MySQL

Simple Crud Python vs MySQL The idea came when I was studying MySQ... A desire to create a python program that can give access to a "localhost" databa

Lucas 1 Jan 21, 2022
Osu statistics right on your desktop, made with pyqt

Osu!Stat Osu statistics right on your desktop, made with Qt5 Credits Would like to thank these creators for their projects and contributions. ppy, osu

Aditya Gupta 21 Jul 13, 2022
A MCPI hack with many features.

Morpheus 2.0 A MCPI hack with many features To Use: You will need to install the keyboard, pysimplegui, and MCPI python modules and you will need to e

11 Oct 11, 2022
All kinds of programs are accepted here, raise a genuine PR, and claim a PR, Make 4 successful PR's and get the Stickers and T-Shirt from hacktoberfest 2021

this repository is excluded from hacktoberfest Hacktoberfest-2021 This repository aims to help code beginners with their first successful pull request

34 Sep 11, 2022
Liquid Rocket Engine Cooling Simulation

Liquid Rocket Engine Cooling Simulation NASA CEA The implemented class calls NASA CEA via RocketCEA. INSTALL GUIDE In progress install instructions fo

John Salib 1 Jan 30, 2022
This repo is for scripts to run various clients at the merge f2f

merge-f2f This repo is for scripts to run various clients at the merge f2f. Tested with Lighthouse! Tested with Geth! General dependecies sudo apt-get

Parithosh Jayanthi 2 Apr 03, 2022
This is the DBMS Project done in 5th sem of B.E CS.

Student-Result-Management-System This is the DBMS Project done in 5th sem of B.E CS. You need to install SQlite DB Browser in your pc or laptop to ope

Vivek kulkarni 1 Jan 14, 2022
SMS-b0mber VANDALIZM developed for VK group

VANDALIZM SMS-b0mber VANDALIZM developed for VK group https://vk.com/dark__code if you come across this code, you can use it for your own purposes) ус

5 Jun 24, 2022
Small tool to use hero .json files created with Optolith for The Dark Eye/ Das Schwarze Auge 5 to perform talent probes.

DSA5-ProbeMaker A little tool for The Dark Eye 5th Edition (Das Schwarze Auge 5) to load .json from Optolith character generation and easily perform t

2 Jan 06, 2022
This repository holds those infrastructure-level modules, that every application requires that follows the core 12-factor principles.

py-12f-common About This repository holds those infrastructure-level modules, that every application requires that follows the core 12-factor principl

Tamás Benke 1 Dec 15, 2022
Compile Binary Ninja's HLIL IR to LLVM, for purposes of compiling it back to a binary again.

Compiles BinaryNinja's HLIL to LLVM Approach Sweep binary for global variables, create them Sweep binary for (used?) external functions, declare those

Kyle Martin 31 Nov 10, 2022