This is the pulp_python Plugin for Pulp Project
3.0+. A Pulp plugin to support hosting your own
pip compatible Python packages.
For more information, please see http://www.pulpproject.org.
All REST API examples bellow use httpie to perform the requests.
The httpie commands below assume that the user executing the commands has a .netrc file
in the home directory. The .netrc should have the following configuration:
machine localhost login admin password admin
If you configured the admin user with a different password, adjust the configuration
accordingly. If you prefer to specify the username and password with each request, please see
httpie documentation on how to do that.
This documentation makes use of the jq library to parse the json received from requests, in order to get the unique urls generated when objects are created. To follow this documentation as-is please install the jq library with:
$ sudo dnf install jq
Follow the installation instructions provided with pulpcore.
- sudo -u pulp -i
- source ~/pulpvenv/bin/activate
- git clone https://github.com/pulp/pulp_python.git
- cd pulp_python
- git checkout 3.0-dev
- python setup.py develop
- pulp-manager makemigrations pulp_python
- pulp-manager migrate pulp_python
- django-admin runserver
- sudo systemctl restart pulp_resource_manager
- sudo systemctl restart pulp_worker@1
- sudo systemctl restart pulp_worker@2
- sudo -u pulp -i
- source ~/pulpvenv/bin/activate
- pip install pulp-python
- pulp-manager makemigrations pulp_python
- pulp-manager migrate pulp_python
- django-admin runserver
- sudo systemctl restart pulp_resource_manager
- sudo systemctl restart pulp_worker@1
- sudo systemctl restart pulp_worker@2
$ http POST http://localhost:8000/pulp/api/v3/repositories/ name=foo
{
"_href": "http://localhost:8000/pulp/api/v3/repositories/e81221c3-9c7a-4681-a435-aa74020753f2/",
...
}$ export REPO_HREF=$(http :8000/pulp/api/v3/repositories/ | jq -r '.results[] | select(.name == "foo") | ._href')
$ http POST http://localhost:8000/pulp/api/v3/remotes/python/ name='bar' repository=$REPO_HREF url='https://repos.fedorapeople.org/repos/pulp/pulp/fixtures/python-pypi/' projects='["shelf-reader"]'
{
"_href": "http://localhost:8000/pulp/api/v3/repositories/foo/remotes/python/3750748b-781f-48df-9734-df014b2a11b4/",
...
}$ export REMOTE_HREF=$(http :8000/pulp/api/v3/remotes/python/ | jq -r '.results[] | select(.name == "bar") | ._href')
Use python Remote:
$ http POST $REMOTE_HREF'sync/' repository=$REPO_HREF
$ http GET $REPO_HREF'versions/'
[
{
"_href": "http://localhost:8000/pulp/api/v3/repositories/e81221c3-9c7a-4681-a435-aa74020753f2/versions/1/",
"_content_href": "http://localhost:8000/pulp/api/v3/repositories/e81221c3-9c7a-4681-a435-aa74020753f2/versions/1/content/",
"_added_href": "http://localhost:8000/pulp/api/v3/repositories/e81221c3-9c7a-4681-a435-aa74020753f2/versions/1/added/",
"_removed_href": "http://localhost.dev:8000/pulp/api/v3/repositories/e81221c3-9c7a-4681-a435-aa74020753f2/versions/1/removed/",
"number": 1,
"created": "2018-01-03T19:15:17.974275Z",
"content_summary": {}
}
]Create an Artifact by uploading the wheel to Pulp.
$ http --form POST http://localhost:8000/pulp/api/v3/artifacts/ file@./shelf_reader-0.1-py2-none-any.whl
{
"_href": "http://localhost:8000/pulp/api/v3/artifacts/7d39e3f6-535a-4b6e-81e9-c83aa56aa19e/",
...
}Create a file with the json bellow and save it as content.json.
{
"filename": "shelf_reader-0.1-py2-none-any.whl",
"packagetype": "bdist_wheel",
"name": "shelf-reader",
"version": "0.1",
"metadata_version": null,
"summary": "Make sure your collections are in call number order.",
"description": "Shelf Reader is a tool for libraries that retrieves call numbers of items \nfrom their barcode and determines if they are in the correct order.",
"keywords": "",
"home_page": "https://github.com/asmacdo/shelf-reader",
"download_url": "UNKNOWN",
"author": "Austin Macdonald",
"author_email": "[email protected]",
"maintainer": null,
"maintainer_email": null,
"license": "GNU GENERAL PUBLIC LICENSE Version 2",
"requires_python": null,
"project_url": null,
"platform": "UNKNOWN",
"supported_platform": null,
"requires_dist": "[]",
"provides_dist": "[]",
"obsoletes_dist": "[]",
"requires_external": "[]",
"classifiers": [],
"artifacts": {"shelf_reader-0.1-py2-none-any.whl":"http://localhost:8000/pulp/api/v3/artifacts/7d39e3f6-535a-4b6e-81e9-c83aa56aa19e/"}
}$ http POST http://localhost:8000/pulp/api/v3/content/python/packages/ < content.json
{
"_href": "http://localhost:8000/pulp/api/v3/content/python/packages/a9578a5f-c59f-4920-9497-8d1699c112ff/",
"artifacts": {
"shelf_reader-0.1-py2-none-any.whl": "http://localhost:8000/pulp/api/v3/artifacts/7d39e3f6-535a-4b6e-81e9-c83aa56aa19e/"
},
"digest": "b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c",
"notes": {},
"path": "shelf_reader-0.1-py2-none-any.whl",
"type": "python"
}$ export CONTENT_HREF=$(http :8000/pulp/api/v3/content/python/packages | jq -r '.results[] | select(.path == "shelf_reader-0.1-py2-none-any.whl") | ._href')
Currently there is no endpoint to manually associate content to a repository. This functionality will be added before pulp3 beta is released.
$ http POST http://localhost:8000/pulp/api/v3/publishers/python/ name=bar
{
"_href": "http://localhost:8000/pulp/api/v3/repositories/foo/publishers/python/bar/",
...
}$ export PUBLISHER_HREF=$(http :8000/pulp/api/v3/publishers/python/ | jq -r '.results[] | select(.name == "bar") | ._href')
$ http POST $PUBLISHER_HREF'publish/' repository=$REPO_HREF
[
{
"_href": "http://localhost:8000/pulp/api/v3/tasks/fd4cbecd-6c6a-4197-9cbe-4e45b0516309/",
"task_id": "fd4cbecd-6c6a-4197-9cbe-4e45b0516309"
}
]$ export PUBLICATION_HREF=$(http :8000/pulp/api/v3/publications/ | jq -r --arg PUBLISHER_HREF "$PUBLISHER_HREF" '.results[] | select(.publisher==$PUBLISHER_HREF) | ._href')
$ http POST http://localhost:8000/pulp/api/v3/distributions/ name='baz' base_path='foo' publication=$PUBLICATION_HREF
{
"_href": "http://localhost:8000/pulp/api/v3/distributions/9b29f1b2-6726-40a2-988a-273d3f009a41/",
...
}The metadata and packages can now be retrieved from the distribution:
$ curl localhost:8000/pulp/content/foo/simple/
$ curl localhost:8000/pulp/content/foo/simple/shelf-reader/
The content is also pip installable:
pip install --trusted-host dev.pulp3 -i http://dev.pulp3:8000/pulp/content/foo/simple/ shelf-reader
Alternatively, you can modify your pip.conf file. See the
pip docs for more detail.
$ cat pip.conf
[global] index-url = http://dev.pulp3:8000/pulp/content/foo/simple/
pip install --trusted-host dev.pulp3 shelf-reader
$ http GET http://localhost:8000/pulp/api/v3/tasks/82e64412-47f8-4dd4-aa55-9de89a6c549b/
$ http GET http://localhost:8000/pulp/content/foo/shelf_reader-0.1-py2-none-any.whl