This guide walks through the complete lifecycle of an artifact in Pulp: uploading it, publishing it, exposing it, then retrieving it from a client machine. Intended audience: teams that want to host their own packages or cache a public repository. Prerequisites: a working Pulp instance and the pulp CLI configured (see Install Pulp). You will work through three examples: a file repository that you fill by hand, your own Python package, then a PyPI proxy consumed by pip install.
A reminder of the model: in Pulp, an artifact is stored in a repository, which you can freeze into a publication, then expose through a distribution (the access URL). The repository is fed either by direct upload or by synchronisation from a remote (the description of a remote source). Publication depends on the plugin: it is mandatory for pulp_file and optional for pulp_python. The guide illustrates both modes and both cases.
What you will learn
- Create a repository and upload an artifact into it.
- Publish then distribute that repository at a stable URL.
- Retrieve the artifact with a simple HTTP request.
- Build, upload (with
--relative-path) and install your own Python package from another machine, checking the import. - Synchronise a subset of PyPI and install it with pip.
Upload an artifact
You start with the pulp_file plugin, the simplest one: it hosts any binary file. The scenario is an internal artifact, a deliverable or an archive, that you want to distribute to your machines.
-
Create the repository:
Terminal window pulp file repository create --name livrables -
Upload a file into this repository:
Terminal window echo "Livrable interne v1.0" > mon-livrable-1.0.txtpulp file content upload \--repository livrables \--file mon-livrable-1.0.txt \--relative-path mon-livrable-1.0.txtPulp computes the file's sha256, stores it only once through digest deduplication, and adds it to the repository. Every upload creates a new immutable version of the repository.
Publish and distribute
A filled file repository cannot be browsed yet: a distribution without a publication answers 404 (tested on Pulp 3.114: 404 before the publication, 200 after). You have to publish it (freeze a version in a servable format) then create a distribution (the access URL).
-
Publish the latest version of the repository:
Terminal window pulp file publication create --repository livrables -
Distribute the repository under a readable base path:
Terminal window pulp file distribution create \--name livrables \--base-path livrables \--repository livrablesBy linking the distribution to the repository, and not to a frozen publication, it always serves the latest publication: a new upload followed by a publication is exposed automatically.
Retrieve the artifact
The artifact is now reachable at a predictable URL, under /pulp/content/<base-path>/. From any authorised machine:
curl https://pulp.exemple.com/pulp/content/livrables/mon-livrable-1.0.txtThe output shows Livrable interne v1.0. You have just gone through the repository → publication → distribution → retrieval cycle from end to end, as a file repository requires it.
How do I host my own Python package in Pulp?
To host an in-house package, you build it into a Python distribution, upload it to a python repository with --relative-path, distribute it at an address, then install it from another machine with pip. The procedure differs from the file repository on two points. pip does not read a folder, it reads an index (an HTML page that lists packages by name), and Pulp generates it. A Python distribution linked to the repository serves this index without a prior publication, whereas a file repository needs a publication.
The scenario below is a library called bibliotheque-equipe, which exists on no public repository.
Build the distribution
A Python distribution is the file that pip installs: a wheel (.whl, a ready-to-install archive) or an sdist (.tar.gz, the sources). All it takes is a short pyproject.toml and a module folder, here bibliotheque_equipe/, which contains an __init__.py:
[build-system]requires = ["setuptools>=68"]build-backend = "setuptools.build_meta"
[project]name = "bibliotheque-equipe"version = "1.0.0"description = "Bibliothèque interne de l'équipe"requires-python = ">=3.9"The package name (with hyphens) and the name of the module to import (with underscores) are two different things: pip normalises them, but import only accepts the second. The file bibliotheque_equipe/__init__.py contains a single function, bonjour(). The import will call it to check the package:
def bonjour(): return "bonjour depuis le depot interne"The build is run from the project folder:
python3 -m buildls dist/The command writes two files to dist/: the wheel bibliotheque_equipe-1.0.0-py3-none-any.whl and the sdist bibliotheque_equipe-1.0.0.tar.gz. Without access to PyPI, python3 -m build fails, because it downloads setuptools into an isolated environment. In that case, install python3-build, python3-setuptools and python3-wheel, then add --no-isolation.
Upload the package with --relative-path
You first create a python repository, then upload the wheel into it. The --relative-path option states the file name inside the repository, and you give it the exact name of the file:
pulp python repository create --name equipepulp python content create \ --repository equipe \ --file dist/bibliotheque_equipe-1.0.0-py3-none-any.whl \ --relative-path bibliotheque_equipe-1.0.0-py3-none-any.whlThe create command uploads the file transparently, then adds it to the repository. It replaces pulp python content upload, which still exists but has been deprecated since version 0.38.0 of pulp-cli: the online help marks it [deprecated], and you will come across it in older tutorials. No removal date has been announced.
Remember the trap of --relative-path. The option is mandatory: the CLI refuses the command if it is missing. However, Pulp does not check that its value matches the file, and the effect of a wrong name depends on the file type. Always give the exact file name.
On Pulp 3.114 (pulp_python 3.32.1), a wheel uploaded with --relative-path nimporte-1.0.0-py3-none-any.whl is accepted, and Pulp stores it under its real name, read from the wheel. The index offers bibliotheque_equipe-1.0.0-py3-none-any.whl and pip install succeeds.
An sdist uploaded with --relative-path nimporte-1.0.0.tar.gz is also accepted, but it is served under that wrong name. The index does list bibliotheque-equipe, the project page offers the file nimporte-1.0.0.tar.gz, and pip install bibliotheque-equipe answers Could not find a version that satisfies the requirement bibliotheque-equipe (from versions: none). Every upload creates a new version of the repository, as with pulp_file.
To check the content, list the packages. The content list command has no --repository option (that one exists only for create): you filter on the package name. The --repository-version option targets a specific repository version:
pulp python content list --name bibliotheque-equipeThe name, the version 1.0.0 and the package file name appear. This filter does not say which repository the package is in: the repository version, read from pulp python repository list, must have gone from 0 to 1.
Distribute the repository
For a Python repository, the distribution is enough: linked to the repository with --repository, it generates the index from the latest repository version, with no publication step.
pulp python distribution create \ --name equipe \ --base-path equipe \ --repository equipeCheck that the index offers the package. The address is /pypi/<base-path>/simple/:
curl -sS https://pulp.exemple.com/pypi/equipe/simple/The page is displayed directly and contains the link bibliotheque-equipe:
<a href="bibliotheque-equipe/">bibliotheque-equipe</a><br/>To read the response code, add -o /dev/null -w '%{http_code}\n': the command prints 200, with no redirect.
curl -sS -o /dev/null -w '%{http_code}\n' https://pulp.exemple.com/pypi/equipe/simple/200If the page is empty or answers 404, the distribution probably does not point to the right repository. If the index page lists the project but pip answers from versions: none, open the project page (/pypi/equipe/simple/bibliotheque-equipe/): a file name that does not start with the package name, such as nimporte-1.0.0.tar.gz, comes from a wrong --relative-path on an sdist.
There is a second form, which freezes the index: you first create a publication (pulp python publication create --repository equipe), then link the distribution to that publication with --publication <publication href> instead of --repository. The href is the object's address in Pulp's API, displayed by the creation command. The two options exclude each other: Pulp answers Only one of the attributes 'repository' and 'publication' may be used simultaneously. This form keeps an identical index until you publish again, instead of following every new repository version.
Install from another machine and prove the import
The proof is made from a host other than the Pulp server, in a fresh virtual environment. Done from the server, it would succeed without anything being served; done in an environment that already has the package, it would prove nothing.
python3 -m venv /tmp/essai/tmp/essai/bin/pip install --no-cache-dir \ --index-url https://pulp.exemple.com/pypi/equipe/simple/ \ bibliotheque-equipe/tmp/essai/bin/python -c 'import bibliotheque_equipe; print(bibliotheque_equipe.bonjour())'--no-cache-dir stops pip from reusing an already downloaded file. Since the package name exists on no public repository, a successful installation can only come from your Pulp. The last line counts as much as the installation: a package whose wheel is empty or badly built installs without error and cannot be imported. It must print bonjour depuis le depot interne, the string returned by the package's bonjour() function. The client must trust Pulp's certificate, as in the next section.
The second lab of the "Hands-on practice" section replays this procedure end to end on machines, with a different package name: you write the project yourself, without copying this one.
Cache PyPI and install from it with pip
Proxy mode replaces a public repository with a local cache: Pulp synchronises a package from PyPI, then pip installs it by pointing at Pulp. Nexus and Artifactory have an equivalent, their proxy repositories.
-
Describe the source with a remote, fetching only one targeted package and actually storing the files (
immediate):Terminal window pulp python remote create \--name pypi-proxy \--url https://pypi.org/ \--includes '["shellingham"]' \--policy immediateThe
--includesfilter limits the synchronisation; it is also a first control lever (see Securing Pulp). Theimmediatepolicy downloads and keeps the artifacts: the cache is complete and the digests are consistent. -
Create a Python repository and synchronise it:
Terminal window pulp python repository create --name pypi-cachepulp python repository sync --name pypi-cache --remote pypi-proxy -
Distribute the repository: the Python plugin then exposes a PEP 503-compatible index:
Terminal window pulp python distribution create \--name pypi-local \--base-path pypi-local \--repository pypi-cache -
Install the package from Pulp on a client machine:
Terminal window pip install \--index-url https://pulp.exemple.com/pypi/pypi-local/simple/ \shellinghampipqueries the index served by Pulp over HTTPS, downloads the wheel from the cache and installs it. Your machines no longer depend directly on PyPI.The client must trust Pulp's certificate: a public certificate, or a self-signed authority added to the trust store (see Pulp air-gapped). Do not resort to
--trusted-host, which disables TLS verification.There is one exception on an HTTP lab with no TLS:
piponly accepts an unencrypted origin forlocalhost,127.0.0.0/8,::1andfile. For a repository's IP address, it refuses the index unless you pass--trusted-host <host:port>, an option that lifts the origin check and the certificate check for that host only. Reserve it for the lab: in production, serve the index over HTTPS.
The same pattern for every format
The three objects (repository, publication, distribution) exist for every format, and you simply replace file or python with the plugin you want. The role of the publication, however, depends on the plugin: tested on Pulp 3.114, it is mandatory for pulp_file (404 without it) and optional for pulp_python.
In the diagram, the solid path is that of a file repository: the repository goes through a publication before being distributed. The dashed arrow is that of a Python repository, which goes from the repository to the distribution with no publication.
For the other plugins, read the plugin's documentation before assuming either. The commands carry the plugin name:
pulp rpmfor an internal YUM/DNF repository.pulp debfor an APT mirror.pulp ansiblefor a private collections repository.pulp npm,pulp maven,pulp gemfor the matching ecosystems.
Once the remote / repository / publication / distribution pattern is acquired, the commands look alike from one plugin to the next.
Hands-on practice
The first lab puts a proxy repository in front of PyPI, then cuts the repository's network egress and requires an installation that still succeeds. A cache that serves while the source is reachable proves nothing: the client could have bypassed it. The validation checks the cut instead of assuming it.
The second lab has you build a Python package, upload it to a hosted repository, then install it from another machine. Its name exists on no public repository: pip cannot have found it elsewhere. The validation also checks that the module can be imported: a package that installs without importing has proven nothing.
Key points
- An artifact is stored in a repository, possibly frozen into a publication, exposed by a distribution, then retrieved. Publication is mandatory for
pulp_fileand optional forpulp_python. - You feed a repository by direct upload (
content uploadfor a file,content createfor a Python package) or by synchronisation from a remote. - For a file repository, linking a distribution to the repository always exposes the latest publication, which you must have created. For a Python repository, a distribution linked to the repository serves the index without a publication.
- An in-house Python package is built (
python3 -m build), uploaded with--relative-path(mandatory; Pulp does not check it, and an sdist with a wrong name stays unfindable forpip), distributed, then proven by an installation and an import from another machine. - A Python remote in proxy mode gives you a real
pip installfrom Pulp, without depending on PyPI. - The same objects exist for RPM, DEB, Ansible, npm, Maven: the plugin name changes, and the role of the publication has to be checked plugin by plugin.
Knowledge check
Eight questions on the full cycle of an artifact: uploading with its relative path, publishing, distributing, and proving an install from another machine down to the import.
Knowledge check
Check what you have learned with this interactive quiz
How it works
- The timer starts when you click Start
- Multiple choice, true/false and short answer questions
- You can move between questions
- Detailed results are shown at the end
Starts the quiz and the timer
Review
(0/0)Result saved on this device. It will be sent to your account at the next sync. Sync now
Score by domain
A domain groups several guides and gets several questions, so its score is more reliable than a per-topic score, which often rests on a single question.
Summary
Strengths
No topic passed at 80% on at least two questions yet.
Weak areas
No topic below the pass mark.
Recommended next
Hints before you try again?
Continue the course: Pulp as a container registry, with Trivy scanning
A new full quiz with random questions
Work again only on the questions you missed