Is there any way to get pip to print the config it will attempt to use? For debugging purposes it would be very nice to know that:
- config.ini files are in the correct place and pip is finding them.
- The precedence of the config settings is treated in the way one would expect from the docs
For 10.0.x and higher
There is new
pip config
command, to list current configuration values(As pointed by @wmaddox in comments) To get the list of where pip looks for config files
Pre 10.0.x
You can start python console and do. (If you have virtaulenv don't forget to activate it first)
create_main_parser
is function that createsparser
which pip uses to read params from command line(optparse
) and loading configs(configparser
)Possible file names for configurations are generated in
get_config_files
. IncludingPIP_CONFIG_FILE
environment variable if it set.parser.config
is instance ofRawConfigParser
so all generated file names inget_config_files
are passed toparser.config.read
.From how I see it, your question can be interpreted in three ways:
There is a quite extensive documentation for the configurations supported by pip, see here: https://pip.pypa.io/en/stable/user_guide/#configuration
This is specified by the package that is being installed. The package maintainer is responsible for producing a configuration script. For example, Numpy has a Configuration class (https://github.com/numpy/numpy/blob/master/numpy/distutils/misc_util.py) that they use to configure their Cython build.
This is easy,
pip freeze > requirements.txt
. This will produce a file of all currently installed pip modules along with their exact versions. You can then dopip install -r requirements.txt
to reproduce that exact environment configuration on another machine.I hope this helps.
You can run pip in pdb. Here's an example inside ipython:
The only trick here was looking up the path of the baseparser (and knowing that the files are in there). If you don't know this already you can simply step through the program or read the source. This type of exploration should work for most Python programs.