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:
Add Chainguard Libraries as a remote repository for library retrieval.
Add the public PyPI repository as a remote repository.
Create a group, virtual, or polyglot repository combining these repository
sources with any desired internal repositories. Configure the Chainguard
Libraries repository as the first choice for any library access after any
desired internal repositories.
You should also:
Remove all prior cached artifacts in the virtual server or proxy public
repository. This step reduces confusion about the origin of libraries and
assists technical evaluation and adoption of Chainguard Libraries.
Remove any repositories that are no longer desired or necessary. Depending on
your library requirements, this step can result in removal of some proxy
repositories or even removal of all proxy repositories.
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.
Use the following steps to add a repository with both Chainguard Libraries for
Python and PyPI as upstream sources.
First, create a repository:
Log in to your Cloudsmith instance as user with administrator privileges.
Select the Repositories tab near the top of the screen.
Navigate to the Repositories Overview, then select + New repository.
At the new repository form, enter the name python-all for your new
repository. The name should include python to identify the repository
format. This convention helps avoid confusion, since repositories in
Cloudsmith are multi-format.
Select a storage region that is appropriate for your organization and
infrastructure.
Select + Create Repository.
Next, configure the upstream proxies:
Select the name of the new python-all repository on the repositories page
to configure it.
Access the Upstreams tab and click + Add Upstream Proxy.
Configure an upstream proxy with the format python and the following
details:
If you want to use the separate repository with
remediated Python libraries,
repeat the preceding two steps with the name python-chainguard-remediated,
the priority 2, the same authentication details, and the URL
https://libraries.cgr.dev/python-remediated/.
Configure another upstream proxy with the following details
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.
Initial configuration
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:
Log in to the Google Cloud console as a user with administrator privileges.
Navigate to your project and find the Artifact Registry with the search.
Activate Artifact Registry if necessary.
Navigate to your project and find the Secret Manager with the search.
Use the Password from chainctl output to set the Secret value.
Press Create secret.
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:
Press Create a Repository or the + button.
Set the Name to python-public.
Set the Format to Python.
Select Remote for the Mode.
Select PyPi for the Remote repository source.
Choose a suitable Region for your development in Location type.
Press Create.
Configure a remote repository for the Chainguard Libraries for Python repository:
Press the + button to add another repository.
Set the Name to python-chainguard.
Set the Format to Python.
Select Remote for the Mode.
Select Custom for the Remote repository source.
Set the URL for the Custom repository to https://libraries.cgr.dev/python/.
Select Authenticated in Remote repository authentication mode.
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:
Log in as a user with administrator privileges.
Press Administration in the top navigation bar.
Select Repositories in the left hand navigation.
Configure a remote repository for the Chainguard Libraries for Python index:
Select Create a Repository and choose the Remote option.
Set the PyPI Settings - Registry URL to
https://libraries.cgr.dev/python/.
Optionally click the Test button to verify connection and authentication.
Access the Advanced configuration tab and deactivate the Block
Mismatching Mime Types setting in the Others section.
Press Create Remote Repository.
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:
Select Create a Repository and choose the Remote option.
Select PyPI as the Package type.
Set the Repository Key to python-public.
Set the URL to https://files.pythonhosted.org.
Set the PyPI Settings - Registry URL to https://pypi.org/.
Select Create Remote Repository.
Combine the two repositories in a new virtual repository:
Press Create a Repository and choose the Virtual option.
Select PyPI as the Package type.
Set the Repository Key to python-all.
In the Repositories section, find the 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.
Select Create Virtual Repository.
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.
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:
Select Repository - Repositories in the left hand navigation.
Select Create repository.
Select the PyPI (proxy) recipe.
Provide a new name, such as python-public.
In the Proxy - Remote storage field, add the following URL:
https://pypi.org/.
Select Create repository.
Configure a remote repository for the Chainguard Libraries for Python repository:
Select Repository - Repositories in the left hand navigation.
Select Create repository.
Select the PyPI (proxy) recipe.
Provide a new name, such as python-chainguard.
In the Proxy - Remote storagefield, add the following URL:
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:
Select Repository - Repositories in the left hand navigation.
Select Create repository.
Select the PyPI (group) recipe.
Provide a new name, such as python-all.
In the section Group - Member repositories, move the new repositories
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.