Documentation Index
Fetch the complete documentation index at: https://mintlify.com/harness/harness-cli/llms.txt
Use this file to discover all available pages before exploring further.
Harness Artifact Registry provides full support for Python packages, compatible with pip, allowing you to host private Python libraries.
Overview
Python registry features:
- PyPI-compatible repository protocol
- Support for wheel (
.whl) and source distributions (.tar.gz)
- Folder uploads for multiple distribution files
- Version management
- Integration with pip, poetry, and other Python package managers
Pushing Python packages
Use the hc artifact push python command:
hc artifact push python <registry-name> <package-path> \
--pkg-url <pkg-url>
Wheel (.whl)
Source (.tar.gz)
Folder
Binary distribution format:hc artifact push python my-registry ./dist/mypackage-1.0.0-py3-none-any.whl \
--pkg-url https://app.harness.io/registry/pkg
Source distribution format:hc artifact push python my-registry ./dist/mypackage-1.0.0.tar.gz \
--pkg-url https://app.harness.io/registry/pkg
Upload all distributions in a folder:hc artifact push python my-registry ./dist/ \
--pkg-url https://app.harness.io/registry/pkg
Building Python packages
Prepare your package
Ensure you have a proper setup.py or pyproject.toml:from setuptools import setup, find_packages
setup(
name="mypackage",
version="1.0.0",
packages=find_packages(),
install_requires=[],
)
Build distributions
Build wheel and source distributions:# Install build tools
pip install build
# Build both wheel and sdist
python -m build
Upload to registry
Push the distributions:hc artifact push python my-registry ./dist/ \
--pkg-url https://app.harness.io/registry/pkg
Installing Python packages
Configure pip to use your Harness registry:
Using pip configuration
Create or edit ~/.pip/pip.conf (Linux/macOS) or %APPDATA%\pip\pip.ini (Windows):
[global]
index-url = https://<username>:<token>@<registry-url>/simple
Using environment variables
export PIP_INDEX_URL=https://<username>:<token>@<registry-url>/simple
pip install mypackage
Per-command authentication
pip install mypackage --index-url https://<username>:<token>@<registry-url>/simple
Examples
# Build and push a wheel
python -m build --wheel
hc artifact push python my-registry ./dist/mypackage-1.0.0-py3-none-any.whl \
--pkg-url https://app.harness.io/registry/pkg
Using Poetry
Configure Poetry to use your Harness registry:
# Add repository
poetry config repositories.harness https://<registry-url>/simple
# Set credentials
poetry config http-basic.harness <username> <token>
# Publish
poetry build
poetry publish --repository harness
Or use the CLI:
poetry build
hc artifact push python my-registry ./dist/ \
--pkg-url https://app.harness.io/registry/pkg
Package naming conventions
Python package filenames follow strict conventions:
{distribution}-{version}[-{build}]-{python}-{abi}-{platform}.whl
Example: mypackage-1.0.0-py3-none-any.whl
{distribution}-{version}.tar.gz
Example: mypackage-1.0.0.tar.gz
CI/CD integration
- name: Build and publish
run: |
pip install build
python -m build
hc artifact push python my-registry ./dist/ \
--pkg-url https://app.harness.io/registry/pkg
env:
HARNESS_API_KEY: ${{ secrets.HARNESS_API_KEY }}
publish:
script:
- pip install build
- python -m build
- hc artifact push python my-registry ./dist/ --pkg-url $PKG_URL
variables:
HARNESS_API_KEY: $HARNESS_TOKEN
Troubleshooting
Only .whl and .tar.gz files are supported:# ❌ Wrong
hc artifact push python my-registry ./mypackage.zip
# ✅ Correct
python -m build # Generates .whl and .tar.gz
hc artifact push python my-registry ./dist/
Package name extraction failed
Authentication failed during pip install
Check your index URL includes credentials:# Test access
curl -u username:token https://<registry-url>/simple/
See also