Artifactory (parallels/artifactory)
The `artifactory` library, currently at version 0.1.17, provides a Python interface for interacting with JFrog Artifactory. It's designed as a pathlib-like module for object-oriented path manipulations for Artifactory resources. However, this repository is largely unmaintained and considered outdated, with an active fork (`dohq-artifactory` / `pyartifactory`) being the recommended alternative for modern Python environments. It has a very slow release cadence, with the last release being 0.1.17.
Common errors
-
Failed to install packages from artifactory
cause This generic error often indicates issues with Artifactory accessibility, incorrect repository configuration in pip, or the package not being present/accessible in the specified Artifactory repository.fixVerify Artifactory URL and credentials. Ensure the package exists in the Artifactory repository. Check pip configuration (`pip.ini`/`pip.conf`) for correct `--index-url` or `--extra-index-url` settings, potentially including `--trusted-host` if using HTTP or self-signed certificates. -
Could not find a version that satisfies requirement
cause When fetching packages from Artifactory, `pip` may fail to find versions if the package is not available for your Python version, if the repository is misconfigured, or if metadata parsing fails.fixEnsure the package version is compatible with your Python environment. Verify that your Artifactory repository is correctly configured as a PyPI remote or virtual repository, proxying `pypi.org` if needed. Update `pip` to a recent version (20.2 or later is recommended for Artifactory). -
Artifactory is failing to fetch packages from pypi, as it can no longer parse the page.
cause Changes to the HTML output of `pypi.org`'s simple API can break older Artifactory versions or clients that parse the HTML directly, leading to failures in mirroring or downloading packages.fixUpdate your Artifactory instance to a version that supports the latest PyPI Simple JSON API or has updated HTML parsing capabilities. Ensure Artifactory's PyPI remote/virtual repositories are correctly configured.
Warnings
- breaking This `parallels/artifactory` library is outdated and officially superseded by the `dohq-artifactory` (also known as `pyartifactory`) fork. It is strongly recommended to use `pyartifactory` for new projects and consider migrating existing ones.
- gotcha The library primarily targets older Python versions (2.7, 3.2, 3.3). While it might still function on newer Python 3 versions for basic operations, it lacks modern Python features, type hints, and robust maintenance for current Artifactory API versions. For Python 3.8+, `pyartifactory` is the recommended choice.
- gotcha Authentication issues (401/403 errors) are common if credentials (username/password or API key) are incorrect, or if the user lacks the necessary permissions on the Artifactory instance.
- gotcha SSL certificate verification errors can occur when interacting with Artifactory, especially with self-signed certificates or misconfigured SSL. This can manifest as connection errors.
Install
-
pip install artifactory
Imports
- ArtifactoryPath
from artifactory import ArtifactoryPath
Quickstart
import os
from artifactory import ArtifactoryPath
ART_URL = os.environ.get('ARTIFACTORY_URL', 'http://localhost:8081/artifactory')
ART_USER = os.environ.get('ARTIFACTORY_USERNAME', 'admin')
ART_PASS = os.environ.get('ARTIFACTORY_PASSWORD', 'password') # Or API key
try:
# Initialize ArtifactoryPath for a repository with authentication
# Note: For security, use environment variables or a config file for credentials.
repo_path = ArtifactoryPath(
f"{ART_URL}/my-local-repo",
auth=(ART_USER, ART_PASS)
)
# Create a directory (if it doesn't exist)
repo_path.mkdir()
print(f"Successfully connected and accessed: {repo_path}")
# Example: Deploy a dummy file
dummy_content = b"This is a test artifact."
artifact_name = "test_artifact.txt"
artifact_path = repo_path / artifact_name
with open(artifact_name, "wb") as f:
f.write(dummy_content)
artifact_path.deploy_file(artifact_name)
print(f"Deployed artifact: {artifact_path}")
# Clean up local dummy file
os.remove(artifact_name)
# Example: List contents of the repository
print(f"\nContents of {repo_path}:")
for item in repo_path:
print(item)
except Exception as e:
print(f"An error occurred: {e}")
print("Please ensure Artifactory is running and accessible, and credentials are correct.")