Skip to main content
Version: 2.3 (deprecated)

Proxies

How to configure Pants to work with proxies.


Asking for help

It can be tricky to get a proxy working. It's also possible that Pants does not yet have all the mechanisms it'll need to work with your organization's specific setup, which we'd love to fix.

Please reach out on Slack or open a GitHub issue for any help.

Installing Pants

The ./pants script from Installing Pants uses PyPI to download and install the wheel pantsbuild.pants and all of Pants's dependencies.

If you cannot access PyPI, you may instead download Pants as a PEX binary from https://github.com/pantsbuild/pants/releases. After downloading the PEX artifact, you can rename the file to ./pants, run chmod +x ./pants, then run ./pants --version like you normally would.

You may want to check the binary into version control so that everyone in your organization can use it. To upgrade to a new Pants release, update the pants_version option in pants.toml and download the newest release from https://github.com/pantsbuild/pants/releases.

Setting up a Certificate Authority

You may need to configure Pants to use a custom Certificate Authority (CA) bundle:

pants.toml
[GLOBAL]
ca_certs_path = "/path/to/certs/file"

Setting HTTP_PROXY and HTTPS_PROXY

You may need to set standard proxy-related environment variables, such as http_proxy, https_proxy and all_proxy, in executed subprocesses:

pants.toml
[subprocess-environment]
env_vars.add = ["http_proxy=http://myproxy", "https_proxy"]

You can use lowercase or all-caps env var names.

Note that if you leave of the env var's value, as for https_proxy above, Pants will use the value of the same variable in the environment in which it is invoked.

Using a custom "cheeseshop"/PyPI

See Third-party dependencies for instructions.

Hosting binaries

Pants downloads some binaries in order to run certain functionality, including:

Some proxies restrict access to these URLs. If you are not able to allowlist them, you can host the binaries yourself and instruct Pants to use your custom URL.

We recommend hosting the same binary Pants normally uses, as Pants uses a checksum to ensure the download is valid. You can run ./pants help-advanced $options_scope to determine the full URL with the url_template option.

ToolOptions scope
PEX[download-pex-bin]
Protoc[protoc]
gRPC Python[grpc_python_plugin]
SCC[scc]

Note that this URL is only a template. Anywhere you see {version}, Pants will substitute in the current value for the version option. Anywhere you see {platform}, Pants will look up if you're on macOS or Linux, then look up the dictionary in url_platform_mapping and substitute in the respective value.

For example, ./pants help-advanced protoc gives us the template https://github.com/protocolbuffers/protobuf/releases/download/v{version}/protoc-{version}-{platform}-x86_64.zip. We see the version option is set to 3.11.4. We are running on macOS, so look up darwin in the url_platform_mapping option and find the string osx. Thus, the final URL is https://github.com/protocolbuffers/protobuf/releases/download/v3.11.4/protoc-3.11.4-osx-x86_64.zip.

Once you determine the full URL, you can download the original binary and host it yourself. Then, you can update the url_template option to point to your host:

pants.toml
[protoc]
url_template = "https://binaries.pantsbuild.org/bin/protoc/{version}/{platform}/protoc.zip"

For simplicity, we used the original value for url_platform_mapping, meaning that we set up our hosted URL to store the darwin binary at .../osx/protoc.zip and the linux binary at .../linux/protoc.zip. You can override the option url_platform_mapping if you want to use different values.

Occasionally, new Pants releases will upgrade to new versions of these binaries, which will be mentioned in the "User API Changes" part of the changelog https://github.com/pantsbuild/pants/tree/master/src/python/pants/notes. When upgrading to these new Pants releases, you should download the new artifact and upload a copy to your host.