devpi uses only legacy pip configuration file

Issue #218 on hold
hoel
created an issue

According to the pip documentation the location of the per user pip configuration file under UNIX is $XDG_CONFIG_HOME/pip/pip.config or if XDG_CONFIG_HOME is not set $HOME/.config/pip/pip.config. The settings in this files take precedence over the settings in $HOME/.pip/pip.config.

It would be nice if devpi use .. --set-cfg would write to the new config dirs.

In my case my UNIX home directory is shared via NFS between a wide bunch of incompatible Linux machines. I would like to provide binary packages via my devpi server installation for them but have to provide different versions via different indices to distinguish for example between linux_64 SLES11 and linux_64 UBUNTU 14.04. I would like to switch by using different XDG_CONFIG_HOME settings.

Comments (11)

  1. hoel reporter

    I came up with the following patch:

    berhol@pc130799:>diff use.py_ORI use.py
    455,456c455,459
    <         default_location = ("~/.pip/pip.conf" if sys.platform != "win32"
    <                             else "~/pip/pip.ini")
    ---
    >         default_location = (
    >             "{}/pip/pip.conf".format(
    >                 os.environ.get('XDG_CONFIG_HOME',
    >                                '{}/.config'.format(os.environ.get('HOME'))))
    >             if sys.platform != "win32" else "~/pip/pip.ini")
    
  2. Holger Krekel repo owner

    It's only pip>=6.0 that implements the new locations. devpi is meant to also work with pip-1.5.x so we need to be careful about changing locations. The environment where "devpi use" is run is not neccessarily the same where later "pip install" is issued.

    Also, pip merges the settings of the various files but "devpi use" can only modify one particular file. In order to determine the right file to modify we would need to look which file sets the index url and change that, i guess. I am reluctant to care for all of this myself, including the tests, at the moment. If you can take the time to submit a PR including test, i am willing to review it.

    Lastly, the new pip also looks for virtualenv specific config files and for that to be possible with "devpi use" we may need a command line switch, maybe revise the current options. But that is maybe unrelated to the purpose of this issue, just related to the topic.

  3. Anthon van der Neut

    This bit me hard yesterday, until I realiased pip was using some config file I never created, or had the intention of creating.

    I had setup a new server, and before installing my python utilities (that each go in their own virtualenv) I setup a devpi-server in a docker container, configure pip like on the other servers (using ~/.config/pip/pip.conf ), installed devpi and ran into trouble that non of my dependencies (that normally would come from PyPi) would install. After working around the issue for a while by pushing my packages explicitly to the devpi-server, after two hours I finally realised that instead of the extra-index-url in my ~/.config/pip/pip.conf the index_url from ~/.pip/pip.conf was taken.

    If devpi updates a file, it should update only update ~/.pip/pip.conf if it exists and neither of $XDG_CONFIG_HOME/pip/pip.conf or ~/.config/pip/pip.conf exists. If both exists, I would error out and not try to guess which one to update. It seems that pip overwrites the info from ~/.config/pip/pip.conf with that from ~/.pip/pip.conf (but I am not sure), and that is IMHO worse behaviour than throwing an error telling the user to make up their minds about where to store their configuration.

  4. ckot

    +1 for support of $VIRTUAL_ENV/pip.cfg etc. I typically use different devpi indices for different venvs. I have to always type 'devpi use' prior to pip installs so that I don't get burned..

  5. ckot

    for the time being, I found the current hack (bash function + alias) copies your pip.conf to your virtualenv (provided you use the alias)

    function devpi_use_hack
    {
        devpi use $@
        if [[ ! -z "${VIRTUAL_ENV}" ]]; then
            cp "${HOME}/.pip/pip.conf" "${VIRTUAL_ENV}/"
        fi
    }
    

    alias dpu="devpi_use_hack"

  6. Log in to comment