Credentials in pip.conf for private PyPI

前端 未结 4 1839
感动是毒
感动是毒 2020-12-24 02:17

I have a private PyPI repository. Is there any way to store credentials in pip.conf similar to .pypirc?

What I mean. Currently in .py

4条回答
  •  忘掉有多难
    2020-12-24 02:35

    You could store credentials for Pip to use in ~/.netrc like this:

    machine pypi.example.com
        login johndoe
        password changeme
    

    Pip will use these credentials when accessing https://pypi.example.com but won't log them. You must specify the index server separately (such as in pip.conf as in the question).

    Note that ~/.netrc must be owned by the user pip executes as. It must not be readable by any other user, either. An invalid file is silently ignored. You can ensure the permissions are correct like this:

    chown $USER ~/.netrc
    chmod 0600 ~/.netrc
    

    This permissions check doesn't apply before Python 3.4, but it's a good idea in any case.

    Internally Pip uses requests when making HTTP requests. requests uses the standard library netrc module to read the file, so the character set is limited to an ASCII subset.

提交回复
热议问题