pip install some_package -i my_index
all the timeIn that case, which file should I modify and how?
On Unix and macOS the file is $VIRTUAL_ENV/pip. conf. On Windows the file is: %VIRTUAL_ENV%\pip. ini.
To create a virtual environment, go to your project's directory and run venv. If you are using Python 2, replace venv with virtualenv in the below commands. The second argument is the location to create the virtual environment. Generally, you can just create this in your project and call it env .
Base URL of the Python Package Index (default https://pypi.org/simple).
I run into the same problem, and found that pip support this in current version de facto https://pip.pypa.io/en/latest/user_guide.html#config-file
Inside a virtualenv:
On Unix and Mac OS X the file is $VIRTUAL_ENV/pip.conf
On Windows the file is: %VIRTUAL_ENV%\pip.ini
I never tried using my own index, but after some research this article should cover what you want to do.
Basically you need to add the following to your ~/.pip/pip.conf
(on Windows systems, located at %HOME%\pip\pip.ini
):
[global]
index-url = http://my.pypi.index/comes/here
The problem is that you will have a global definition for all your projects and what you want is a definition for all your users in the specific project. From pip documentation you can alter the config file lookup by using the environment var PIP_CONFIG_FILE
You could edit the virtual-env-folder/bin/activate
script to include this environment var, but the problem is that creating a new virtual environment would lose this change and would not be possible to automate. What you can do is creating the .pip/pip.conf
file in the root of your project and creating a simple activate-virtual-env
script also on the root of the project with the following:
pushd $(dirname $0)
export PIP_CONFIG_FILE="$(pwd)/.pip/pip.conf"
source "$(pwd)/virtual-env-folder/bin/activate"
popd
and instruct your users to source this file instead of virtual-env-folder/bin/activate
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With