Search code examples
python-3.xpiphttp-proxypypitwine

twine upload fails when using a proxy server


I can't upload to pypi using twine when a proxy server is involved.

That's what I tried so far:

python -m twine upload -u USER -p PASSWORD dist/*

When I'm behind our company proxy server twine just hangs, no error message. Set the https_proxy and thehttp_proxy environment variables doesn't help as well.

Our company proxy server has it's own CA certificate (I've the .cer file).

So how can I use twine behind a proxy server.

With pip I was able to do it by adding the following pip.ini file to %Appdata%\pip:

[global]
proxy = proxy.company.com:8080
cert = C:\CA_Proxy.cer

Solution

  • Setting the HTTPS_PROXY and TWINE_CERT environment variables in command prompt before running twine solve the problem:

    set HTTPS_PROXY=proxy.company.com:8080
    set TWINE_CERT=C:\CA_Proxy.pem
    
    python -m twine upload -u USER -p PASSWORD dist/*
    

    Remark: make sure that the certificate is in the PEM (Base-64 encoded X.509) format.

    See the twine user manual for the TWINE_CERT environment variable https://twine.readthedocs.io/en/latest/.