From 89145ee468140bd59517234ea7a7cb1c225ff106 Mon Sep 17 00:00:00 2001 From: Olivier Bourdon <47036880+FeatCrush@users.noreply.github.com> Date: Wed, 30 Jan 2019 10:50:31 +0100 Subject: [PATCH 1/2] Add recipe to use PEX with requests module and proxies. --- docs/recipes.rst | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/docs/recipes.rst b/docs/recipes.rst index 865dae5e0..943b5c57a 100644 --- a/docs/recipes.rst +++ b/docs/recipes.rst @@ -31,3 +31,29 @@ configuration can be passed in the same way: $ service.pex myapp:appinstance -c /path/to/gunicorn_config.py And there you have it, a fully portable python web service. + +PEX and Proxy settings +---------------- + +While building pex files, you may need to fetch dependencies thought a proxy. The easiest way, is to use pex cli with request module and environment variables. Following, the steps to do just that : + +1) Install pex with requests + +.. code-block:: bash + + $ pip install pex[requests] + +2) Set the environment variables + +.. code-block:: bash + + $ export HTTP_PROXY='http://user:pass@address:port' + $ export HTTPS_PROXY='http://user:pass@address:port' + +3) Now you can test by running + +.. code-block:: bash + + $ pex -v pytest + +For more information on the requests module, here the official documentation: http://docs.python-requests.org/en/master/user/advanced/#proxies. From 446467ac86e923209a86f2c6faea0e3272c37e81 Mon Sep 17 00:00:00 2001 From: John Sirois Date: Wed, 30 Jan 2019 09:56:19 -0700 Subject: [PATCH 2/2] Some small copy edits. --- docs/recipes.rst | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/recipes.rst b/docs/recipes.rst index 943b5c57a..3df207389 100644 --- a/docs/recipes.rst +++ b/docs/recipes.rst @@ -35,9 +35,9 @@ And there you have it, a fully portable python web service. PEX and Proxy settings ---------------- -While building pex files, you may need to fetch dependencies thought a proxy. The easiest way, is to use pex cli with request module and environment variables. Following, the steps to do just that : +While building pex files, you may need to fetch dependencies thought a proxy. The easiest way is to use pex cli with the requests extra and environment variables. Following are the steps to do just that: -1) Install pex with requests +1) Install pex with requests .. code-block:: bash @@ -47,13 +47,14 @@ While building pex files, you may need to fetch dependencies thought a proxy. Th .. code-block:: bash - $ export HTTP_PROXY='http://user:pass@address:port' - $ export HTTPS_PROXY='http://user:pass@address:port' + $ # Hopefully your proxy supports https! If not, you can export HTTP_PROXY: + $ # export HTTP_PROXY='http://user:pass@address:port' + $ export HTTPS_PROXY='https://user:pass@address:port' 3) Now you can test by running .. code-block:: bash - $ pex -v pytest + $ pex -v pex -For more information on the requests module, here the official documentation: http://docs.python-requests.org/en/master/user/advanced/#proxies. +For more information on the requests module support for proxies via environment variables, see the official documentation here: http://docs.python-requests.org/en/master/user/advanced/#proxies.