Chainguard Libraries for Python overview
Learn about Chainguard Libraries for Python, providing enhanced security for PyPI packages through automated …
For the complete documentation index, see llms.txt.
Python library consumption in a large organization is typically managed by a repository manager. Commonly used repository manager applications are Cloudsmith, JFrog Artifactory, and Sonatype Nexus Repository. The repository manager acts as a single point of access for developers and development tools to retrieve the required libraries.
At a high level, adopting the use of Chainguard Libraries consists of the following steps:
You should also:
If your organization does not use a repository manager, you can still use Chainguard Libraries. However, this approach requires configuration of multiple build and development platforms and utilities to use Chainguard Libraries. For this reason, adopting the use of a repository manager is the recommended approach. Refer to the direct access documentation for build tools for more information.
Before configuring your repo manager, consider how you want to handle packages that aren’t yet available in the Chainguard Libraries repository. If you configure a fallback to PyPI, packages sourced from that registry are not covered by Chainguard’s malware-resistance guarantees. See the fallback approaches described in the Chainguard Libraries quick start for guidance on choosing the right approach for your environment.
Cloudsmith supports Python repositories for proxying and hosting and polyglot repositories that combine multiple repositories sources with compatible formats. Refer to the Cloudsmith Python Repository documentation and the Cloudsmith documentation for creating a repository for more information.
Use the following steps to add a repository with both Chainguard Libraries for Python and PyPI as upstream sources.
First, create a repository:
Next, configure the upstream proxies:
python-chainguard1https://libraries.cgr.dev/python/Cache and Proxypython-chainguard-remediated,
the priority 2, the same authentication details, and the URL
https://libraries.cgr.dev/python-remediated/.python-public3https://pypi.org/Cache and ProxySee the page on build tool configuration for Chainguard Libraries for Python for information on accessing credentials and setting up build tools.
Google Artifact Registry supports
the Python format for hosting artifacts in Standard repositories and proxying
artifacts from public repositories in Remote repositories. Use Virtual
repositories to combine them for consumption with pip and other build tools.
Use the Python package documentation for Google Artifact
Registry as the starting
point for more details.
Use the following steps to add the Pypi Package Index and the Chainguard Libraries for Python repository as remote repositories and combine them as a virtual repository:
Before configuring the repositories, you must create a secret with the password value as retrieved with chainctl:
Navigate to Artifact Registry and select Repositories in the left hand navigation under the Artifact Registry label to configure a remote repository for the Pypi Package Index:
Configure a remote repository for the Chainguard Libraries for Python repository:
Combine the two repositories in a new virtual repository:
JFrog Artifactory supports PyPI repositories for proxying and virtual repositories to combine multiple sources into a single repository. The following instructions are based on the PyPI Repository documentation for Artifactory.
Use the following steps to add the Chainguard Libraries for Python index and the PyPI public index as remote repositories and combine them as a virtual repository:
Configure a remote repository for the Chainguard Libraries for Python index:
python-chainguard.https://libraries.cgr.dev/python/.https://libraries.cgr.dev/python/.If you want to use the separate repository with remediated Python
libraries repeat the
preceding steps with the name python-chainguard-remediated, the same
authentication details, and the URL
https://libraries.cgr.dev/python-remediated/.
Configure a remote repository for the PyPI public index:
python-public.https://files.pythonhosted.org.https://pypi.org/.Combine the two repositories in a new virtual repository:
python-all.python-chainguard and
python-public repositories. Ensure the python-chainguard repository is
the first in the displayed list. Use the icon on the right of the repository
name to drag and drop repositories into the desired position.At this point, you have a virtual repository set up in Artifactory that allows you or others in your organization to access Chainguard Libraries for Python, optionally including remediated versions, with your chosen tools. This setup falls back to the public PyPI index in cases where a package is not available in Chainguard’s index.
After creating the python-chainguard remote repository, validate that Artifactory is successfully proxying through to Chainguard before proceeding. Because Artifactory falls back to the public PyPI index when a connection to a remote repository fails, a misconfigured repository may silently resolve packages from PyPI rather than Chainguard — and the build will succeed without any visible error.
Common sources of misconfiguration include invalid or expired credentials, or an incorrect or incomplete repository URL. The Artifactory Test button on the repository configuration screen is not a reliable indicator; it may fail for a correctly configured repository, and may pass for an incorrectly configured one. Instead, use the following steps to verify that fetching an artifact through Artifactory produces the same checksum as fetching it directly from libraries.cgr.dev.
urllib3. You can substitute any artifact you know to be available.curl -sSf \
-u "${CHAINGUARD_PYTHON_IDENTITY_ID}:${CHAINGUARD_PYTHON_TOKEN}" \
https://libraries.cgr.dev/python/simple/urllib3/ \
| grep -o 'https://[^"]*\.whl' | head -1libraries.cgr.dev and compute its checksum:curl -sSf -L \
-u "${CHAINGUARD_PYTHON_IDENTITY_ID}:${CHAINGUARD_PYTHON_TOKEN}" \
<url-from-step-1> \
| sha256sumcurl -sSfL \
-u "${ARTIFACTORY_USERNAME}:${ARTIFACTORY_TOKEN}" \
"https://<artifactory-host>/artifactory/<python-remote-repository>/${path-to-wheel}" \
| sha256sumReplace artifactory-host with your Artifactory instance hostname and replace python-remote-repository with your remote repository name. Replace path-to-wheel with the path component of the URL from step 1 (for example: /files/15f7d141c3b76b85/37e321caa85a8f41/urllib3/urllib3-1.26.9-py2.py3-none-any.whl)
The checksums returned by the commands must match.
If the checksum from the Artifactory remote repository differs from the direct fetch, or if the Artifactory fetch fails entirely, review the following before proceeding:
https://libraries.cgr.dev/python/.chainctl auth pull-token --repository=python and update the Artifactory repository credentials. Expired tokens fail silently.Do not proceed to virtual repository setup or build configuration until the checksums match.
See the page on build tool configuration for Chainguard Libraries for Python for information on accessing credentials and setting up build tools.
Sonatype Nexus Repository allows for merging multiple remote repositories as a repository group. The below instructions are based on the Nexus documentation for PyPI
The following steps create remote repositories for Chainguard Libraries for Python, a remote repository for the public PyPI index, and a repository group combining these sources.
First, log in to Sonatype Nexus as a user with administrator privileges and access the Server administration and configuration section within the gear icon in the top navigation bar.
Next, configure a remote repository for the public PyPI index:
python-public.https://pypi.org/.Configure a remote repository for the Chainguard Libraries for Python repository:
python-chainguard.https://libraries.cgr.dev/python/.If you want to use the separate repository with remediated Python
libraries repeat the
preceding steps with the name python-chainguard-remediated, the same
authentication details, and the URL
https://libraries.cgr.dev/python-remediated/.
Finally, create a new repository group and add the two repositories:
python-all.python-public and python-chainguard to the right and move the
python-chainguard repository to the top of the list with the arrow control.
If you configured the python-chainguard-remediated repository, also move
it to the right and the top of the list.See the page on build tool configuration for Chainguard Libraries for Python for information on accessing credentials and setting up build tools.
Last updated: 2025-04-07 14:42