Let's say I have a setup.cfg
(or setup.py
) file with all the packages listed.
Now, if I run pip install .
it'll install all packages and it's dependencies listed in install_requires
. Is there a way to only get the list of packages and dependencies without downloading or installing them, like in a requirements.txt
format?
This command I'm looking for ideally would also work for pip install '.[tests]'
, which would list packages defined for tests
under extras_require
in setup.cfg
.
What this question is NOT asking:
- I'm not asking for
pip freeze
orpip list
type of command which lists all the packages installed in an environment. Rather I want the same type of list, just not of the packages already installed but of the packages that will be installed by the defined configuration insetup.cfg
. - I'm not asking about how to generate this list by downloading these packages either, but only to collect them. I don't see why
pip
would need to download these packages when what I need is only the list of the packages and dependencies with their versions.
SOLUTION
stackoverflow
marked this question as a duplicate which it is NOT. I have found a solution however because this question is closed I won't be able to submit it as an answer, but will post it here in the question instead.
To generate requirements.txt
for packages listed in install_requires
in your setup.cfg
or setup.py
, you would need to install pip-tools
.
pip install pip-tools
pip-compile
To generate a requirements.txt
file that includes packages specified under extras_requires
for tests
and dev
:
pip-compile --extra tests --extra devrequirements.txt file with packages listed under