AirKetchup
AirKetchup

Reputation: 198

How to read the requirements from a setup.py file

I'm making a utility for the Python mobile app Pythonista. It is basically just a version of pip, which is not supported by default (Yes I am aware one already exists, I am making mine differently for personal use).

In packages, there exists a setup.py, but not always a requirements.txt. How can I read the file and find the dependencies from it? Alternatively, how would I fetch the dependencies? I know it should be possible, because pip itself finds the dependencies, and they don't always have a requirements.txt.

So how would I get the dependencies of a package by the setup.py, or however pip does it?

Upvotes: 1

Views: 297

Answers (1)

Michal Yanko
Michal Yanko

Reputation: 389

A solution not using setup.py or pip:

You can try and us pipreqs package.

pipreqs - Generate requirements.txt file for any project based on imports

Another option use the pip-tools

The pip-compile command lets you compile a requirements.txt file from your dependencies, specified in either setup.py or requirements.in.

Upvotes: 1

Related Questions