Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
like image 811
Wollmich Avatar asked Sep 05 '25 03:09

Wollmich


2 Answers

I've been able to solve a similar issue under Windows by setting an HTTPS_PROXY environment variable, without having to set anything about certificates.

Working in a cmd prompt, run

set HTTPS_PROXY=proxy.company.com:8080

before running your twine command in the same session.

The environment variable can also be set permanently using the control panel or as described in https://superuser.com/q/79612/1148425

like image 177
jpeg Avatar answered Sep 07 '25 22:09

jpeg


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/.

like image 41
Wollmich Avatar answered Sep 07 '25 21:09

Wollmich