[Catalog-sig] Problem switching to https://pypi.python.org/pypi (and work-around)

M.-A. Lemburg mal at egenix.com
Mon Feb 18 14:04:54 CET 2013


I wanted to switch to the HTTPS address of PyPI today, but the change
in my .pypirc did not result in the expected seemless upgrade ;-)

Here's my working .pypirc (fairly standard):

"""
[distutils]
index-servers =
    pypi

[pypi]
repository = http://pypi.python.org/pypi
username = xyz
password = abc
"""

If I change just the http:// to https://, the register command asks me
for login details (without doing any communication with the server).

The same happens when changing the repository to anything other
than the above default, e.g. http://www.python.org/pypi

I tried this with Python 2.6 and 2.7.

Looking at the code in Lib/distutils/config.py this appears to be
due to the ._read_pypirc() method choosing the server entry based
on the repository that was given as command line option to
the register command (or the default setting), so the change in
.pypirc to https:// is not enough to get distutils updated;
I'll also have to add a [register] section to the ~/pydistutils.cfg.

I would have expected distutils to lookup "pypi" and simply
use whatever is defined there as repository.

After looking closer, I found there's a trick one can use to
avoid the pydistutils.cfg change. If the server section is
named after the default repository URL, distutils will use
the section and still read the (new) repository URL:

"""
[distutils]
index-servers =
    http://pypi.python.org/pypi

[http://pypi.python.org/pypi]
repository = https://pypi.python.org/pypi
username = xyz
password = abc
"""

I verified with wireshark that this does result in HTTPS
communication.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Feb 18 2013)
>>> Python Projects, Consulting and Support ...   http://www.egenix.com/
>>> mxODBC.Zope/Plone.Database.Adapter ...       http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________

::::: Try our mxODBC.Connect Python Database Interface for free ! ::::::

   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
    D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
           Registered at Amtsgericht Duesseldorf: HRB 46611
               http://www.egenix.com/company/contact/


More information about the Catalog-SIG mailing list