Skip to main content

python-quickstart

Last updated on

Prerequisites

  • Ensure you have Python CLI installed and configured on your local machine.
  • Ensure you have access to a Harness account with the appropriate permissions to create registries and connectors.

Create a Python Artifact Registry

private python registry

This registry will serve as your private Python registry within Harness.


Configure an Upstream Proxy (Optional)

An upstream proxy allows your registry to fetch Python packages from external sources if they are not available locally.

Create an upstream proxy

Configure the upstream proxy in your registry

upstream proxy caching

If a Python package isn’t found in your Harness registry, the upstream proxy fetches it from an external registry like PyPI, reducing duplication and improving package resolution.

Configuring Python PyPI Upstream Proxy with Custom Registry Suffix

Harness supports configuring Python PyPI upstream proxies for registries that use non-standard endpoint paths. In addition to specifying the remote registry URL, you can define an optional custom registry suffix when the PyPI repository is not available under the default /simple/ endpoint.

This is commonly required when integrating with enterprise artifact repositories such as Artifactory, Nexus, or private PyPI mirrors. Authentication can be configured using anonymous access or username and password credentials. Once configured, Harness handles package resolution and authentication automatically when proxying Python dependencies from the upstream registry.


Publish & Install Python Packages

1. Generate Identity Token

An identity token will serve as the password for uploading and downloading artifacts.

Generate an identity token from your Harness account settings.

2. Configure Authentication

Create or update your ~/.pypirc file with the following content:

[distutils]
index-servers = harness

[harness]
repository = https://pkg.harness.io/pkg/<account-id>/<python-registry-name>/python
username = <your-email@harness.io>
password = <identity-token>

3. Publish Package

Build and publish your package:

python -m build
python -m twine upload --repository harness /path/to/files/*

4. Install Package

Install a package using pip:

pip install --index-url https://<your-email@harness.io>:<TOKEN>@pkg.harness.io/pkg/<account-id>/<python-registry-name>/python/simple --no-deps <ARTIFACT_NAME>==<VERSION>