Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

`requirements.txt` dependencies, getting only high level dependencies

I have a three python projects A, B and C. Each depending on each other.

How can I now "clean up" my requirements.txt that only the high level dependencies that are required at this "level" are there.

Example

A requirements:

boto3==1.2.4

B requirements:

A==0.0.1
boto3==1.2.4
cookiecutter==1.4.0

C requirements:

B==0.0.1
slacker==0.9.9
boto3==1.2.4
cookiecutter==1.4.0

The bold packages are the ones which should be filtered out.

like image 313
lony Avatar asked Jun 22 '16 11:06

lony


People also ask

Why you shouldn't use pip freeze?

pip freeze might seem very useful initially but it can mess up your project because of the following reasons: It dumps all the libraries installed in your project including dependencies and sub-dependencies in the requirements. txt file. It still misses out on the libraries that are not installed using pip.

How do I remove unused dependencies from requirements txt?

txt, you can use the "Sync Python Requirements" tool (under the Tools menu) to find and remove unused packages (check the "Remove unused requirements" box). This could be a nightmare if you "inspect" a project and contain the whole dependencies inside of it, so delete the dependencies (if you have a virtual env.


1 Answers

pipdeptree can display the dependencies tree, and for a given package tell you which other package(s) depends on it.

like image 147
bruno desthuilliers Avatar answered Oct 14 '22 23:10

bruno desthuilliers