I am forced to download python packages from local mirror PyPi repository. I do this by using the -i
and --trusted-host
options. Whole installation command looks like this:
pip install -i https://sampleurl.com/pypi-remote/simple --trusted-host sample.host.com package_name
Having to type in that options each time is kinda annoying though (in reality those are long URL's). I've tried to create get_package.bat
file (I'm working on Windows 10) with following content:
pip install -i https://sampleurl.com/pypi-remote/simple --trusted-host sample.host.com "%1"
It works perfectly fine, although when I wanted to execute pip search command, it turned out to be useless since it has hard-coded install
command and there is no way to use it with search
.
Is there any way in which I can setup pip to download from mirror repository by default, so that I can execute pip install package_name
or pip search package_name
without any additional options?
Eventually I could try making .bat
file that would take 2 parameters like this:
pip %1 -i https://sampleurl.com/pypi-remote/simple --trusted-host sample.host.com "%2"
But I wonder if there's more "elegant" way to do this.
using pip config, on user or global level. I have /etc/pip.conf
configured like this:
[global]
index=https://my-company/nexus/repository/pypi-group/pypi
index-url=https://my-company/nexus/repository/pypi-group/simple
trusted-host=my-company
but you can configure this using pip config
on user or global level, something like:
pip config --user set global.index https://my-company/nexus/repository/pypi-group/pypi
pip config --user set global.index-url https://my-company/nexus/repository/pypi-group/simple
pip config --user set global.trusted-host my-company
#NOTES
--index-url
is used by pip install--index
is used by pip search