I am not interested in installing my package itself but I am interested installing all the dependencies used by my package. Is there a way to do this using setup.py
? It seems setup.py
installs my package and all dependencies.
How to use setup.py to install dependencies only?
Use the -e flag on pip install
pip install -e .
I'm confused by this -
-e
is for "editable mode", which will do things like symlink the working directories of dependencies. In this case OP wants to install everything "for real", just not the one package under development. Does this handle the use case well? –
Repeat @KenWilliams editable mode will install everything "for real", except for the very package you're working on (this will be "symlinked", as you mentioned). You might not want this link to remain though -- which is what your trick with as subsequent
pip uninstall
handles. –
Trinl this is obviously not the right answer! Why is this accepted? This will do much more than "only install dependencies". –
Nemhauser
Please vote for this request to get a better solution: github.com/pypa/pip/issues/11440 –
Bernhard
The only way I've found to reliably do this in a straightforward manner is this:
pip install . && pip uninstall `python setup.py --name`
Thanks, great answer. One minor suggestion:
pip uninstall --yes
, so it doesn't prompt you (e.g. in a Dockerfile) –
Trinl This is great answer! One minor comment is that it does not work for python3, however it is easy to adapt. –
Latini
@QiLuo I use this with python 3, what problem did you encounter? –
Repeat
In an environment with both python2 and python3, I could use
pip3 install . && pip3 uninstall `python3 setup.py --name`
–
Latini @QiLuo Yeah, that's just because pip and python are apparently called
pip3
and python3
in your environment. In mine, they're simply called pip
and python
. –
Repeat Please vote for this request to get a better solution: github.com/pypa/pip/issues/11440 –
Bernhard
if you wan to do it from setup.py do:
python setup.py egg_info
pip install -r *.egg-info/requires.txt
rm -rf *.egg-info/
all of this ran from the project folder usually for me it's the root of my github where setup.py is.
credits: https://mcmap.net/q/297953/-pip-installing-only-the-dependencies
Exactly what I wanted for my docker container! –
Christachristabel
© 2022 - 2024 — McMap. All rights reserved.
abc
which is dependent onxyz
, you want to installxyz
but notabc
am i right ? – Assetpip install -r requirements.txt
. – Plumate