I am using pip 1.4.1, attempting to install a package from a local path, for example:
pip install /path/to/my/local/package
This does what I want, which is more or less the equivalent of running python /path/to/my/local/package/setup.py install
, but I would like to pass some additional options/arguments to my package's setup.py install.
I understand from the pip documentation that this is possible with the --install-option
option, for example:
pip install --install-option="--some-option" /path/to/my/local/package
This post from the python-virtualenv Google Group suggests this is possible.
What I do not understand is how to obtain the passed-in "--some-option" from within setup.py. I tried looking at sys.argv
, but no matter what I put for "--install-option=", sys.argv
is always this:
['-c', 'egg_info', '--egg-base', 'pip-egg-info']
How can I get the values of things passed in as "--install-option" from pip install?
You need to extend the install command with a custom command of your own. In the
run
method you can expose the value of the option tosetup.py
(in my example I use a global variable).Register the custom install command with the
setup
function.It seems that the order of your arguments is off
pip install /path/to/my/local/package --install-option="--someopt"
It works well and also documented.
One of common mistakes is to pass
setup
options to pip like you pass it tosetup
directly. Use options from pip like that:But this way is a wrong way:
Absence of equal sign causes well known error:
I was having this problem installing pyside.
I needed to specify the
--qmake
option.This is the form you need:
For consistency, you can add an option to both
setup.py install
andsetup.py develop
(akapip install -e
): (building off Ronen Botzer's answer)Then you can pass options to pip like:
Or in develop mode: