Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pip.conf file to use environment variable

Tags:

pip

Is it possible to have an environment variable as a part of the index url in pip.conf?

I tried using $ and ${} but it does not resolve the variables

like image 512
abhishek phukan Avatar asked Aug 27 '19 18:08

abhishek phukan


People also ask

Does pip have a config file?

pip has 3 “levels” of configuration files: global : system-wide configuration file, shared across users. user : per-user configuration file. site : per-environment configuration file; i.e. per-virtualenv.

Where is the pip config file?

On Unix the file may be located in /etc/pip. conf. Alternatively it may be in a "pip" subdirectory of any of the paths set in the environment variable XDG_CONFIG_DIRS (if it exists), for example /etc/xdg/pip/pip. conf.

Where is pip config in VENV?

On Unix and macOS the file is $VIRTUAL_ENV/pip. conf. On Windows the file is: %VIRTUAL_ENV%\pip. ini.

What is Pip_index_url?

${PIP_INDEX_URL} is expanded by the shell before passing to sudo . This is a handy shell trick and works with ssh and anything else that passing args and environment directly to a subprocess. Modify your sudo configuration in sudoers to extend the list of allowed environment variables to pass to the child.


1 Answers

You can set environment variables for pip to use instead of specifying them in pip.conf file.

Use export PIP_DEFAULT_INDEX_URL='some_url.com' to set them.

To list all config, use pip config list. They should be set.

But beware of config precedence:

--host=foo overrides PIP_HOST=foo

PIP_HOST=foo overrides a config file with [global] host = foo

A command specific section in the config file [] host = bar overrides the option with same name in the [global] config file section

like image 51
Dinko Pehar Avatar answered Sep 20 '22 21:09

Dinko Pehar