Managing Python type content

You can use orcharhino to manage Python type repositories. To achieve this, custom products in orcharhino include repositories for Python type content. This provides a generic method to incorporate Python packages in a product.

You can upload Python packages to Python type repositories and synchronize files from an upstream orcharhino Server. When you add Python packages to a Python type repository, you can use the normal orcharhino management functions such as adding a specific version to a content view to provide version control and making the repository available on various orcharhino Proxies. You must download the files on clients over HTTP or HTTPS using curl -O.

You can create an independent repository source in a directory on orcharhino Server, or on a remote HTTP server, and then synchronize the contents of that directory into orcharhino. This method is useful when you have multiple Python packages to add to a custom repository.

Synchronizing Python repositories

On orcharhino, you can synchronize your Python repositories from any mirror and other orcharhino instances. You can view the Python packages in the orcharhino management UI at Content > Content Types > Other Content Types.

Procedure
  1. In the orcharhino management UI, navigate to Content > Products.

  2. Select a custom product by name.

  3. In the Products window, select the name of a product that you want to create a repository for.

  4. Click the Repositories tab, and then click New Repository.

  5. In the Name field, enter a name for the repository.

    The Label field is populated automatically based on the name.

  6. From the Type list, select python.

  7. In the Upstream URL field, enter the URL for the upstream content source, for example https://pypi.org.

  8. Optional: In the Upstream Username field, enter the user name for the upstream repository if required for authentication. Clear this field if the repository does not require authentication.

  9. Optional: In the Upstream Password field, enter the corresponding password for the upstream repository. Clear this field if the repository does not require authentication.

  10. Optional: In the Upstream Authentication Token field, provide the token of the upstream repository user for authentication. Leave this field empty if the repository does not require authentication.

  11. Optional: In the Excludes field, enter a list of Python packages separated by newlines to exclude from synchronizing to orcharhino.

  12. Optional: In the Includes field, enter a list of Python packages separated by newlines to limit the synchronization only to the included packages.

  13. Optional: In the Package Types field, enter a list of package types separated by comma. You can use this field to only synchronize the source distribution if you enter .tar.gz or the built distribution if you enter .whl.

  14. From the Mirroring Policy list, select the type of content synchronization orcharhino Server performs. For more information, see Mirroring Policies Overview.

  15. Optional: In the HTTP Proxy Policy field, select an HTTP proxy.

  16. Optional: You can clear the Unprotected checkbox to require a subscription entitlement certificate for accessing this repository. By default, the repository is published through HTTP.

  17. Optional: In the SSL CA Cert field, select the SSL CA Certificate for the repository.

  18. Optional: In the SSL Client cert field, select the SSL Client Certificate for the repository.

  19. Optional: In the SSL Client Key field, select the SSL Client Key for the repository.

  20. Click Save to create the repository.

  21. Select your repository.

  22. From the Select Action menu, select Sync Now.

Uploading files to a Python type repository

You can upload files from your local machine to a Python type repository.

Procedure
  1. In the orcharhino management UI, navigate to Content > Products.

  2. Select a custom product by name.

  3. Select a Python type repository by name.

  4. Click Browse to search and select the file you want to upload.

    You can upload .whl packages and .tar.gz archives that contain Python packages.

  5. Click Upload to upload the selected file to orcharhino Server.

CLI procedure
# hammer repository upload-content \
--id My_Repository_ID \
--organization-id My_Organization_ID \
--path Path_To_My_File

The --path option can indicate a file, a directory of files, or a glob expression of files. Globs must be escaped by single or double quotes.

Verification
  • Visit the Published At URL to see the file.

Installing Python packages from orcharhino Server

You can install Python packages from orcharhino on hosts using pip.

Prerequisites
  • You have uploaded or synchronized a Python package to orcharhino.

Procedure
  • On your hosts, set the URL to orcharhino Server to install a Python package:

    $ pip install \
    --index-url https://orcharhino.example.com/pulp/content/My_Organization_Label/Library/custom/MyCustom_Product/My_Python_Repository/simple/ \
    My_Python_Package

    If your host does not trust the certificate of your orcharhino Server, add the --trusted-host orcharhino.example.com option.

Downloading files to a host from a Python type repository

You can download files to a client over HTTPS using curl -O, and optionally over HTTP if the Unprotected option for repositories is selected.

Prerequisites
  • You have a Python type repository.

  • You know the name of the Python package you want to download to clients from the Python type repository.

  • To download the Python packages over HTTPS to your hosts, you require:

Procedure
  1. In the orcharhino management UI, navigate to Content > Products.

  2. Select a custom product by name.

  3. Select a Python type repository by name.

  4. Optional: Select the Unprotected checkbox to access the repository published through HTTP.

  5. Copy the Published At URL.

  6. On your client, download the file from orcharhino Server:

    • For HTTPS:

      # curl \
      --cacert ./_katello-server-ca.crt \
      --cert ./_My_Organization_key-cert.pem \
      --remote-name \
      https://orcharhino.example.com/pulp/content/My_Organization_Label/Library/custom/My_Product_Label/My_Repository_Label/My_File
    • For HTTP:

      # curl \
      --remote-name \
      http://orcharhino.example.com/pulp/content/My_Organization_Label/Library/custom/My_Product_Label/My_Repository_Label/My_File
CLI procedure
  1. List all file type repositories:

    # hammer repository list --content-type python
  2. View the repository information:

    # hammer repository info \
    --name "My_Python_Repository" \
    --organization-id My_Organization_ID \
    --product "My{customproductid}_"
  3. On your client, download the file from orcharhino Server:

    • For HTTPS:

      # curl \
      --cacert ./_katello-server-ca.crt \
      --cert ./_My_Organization_key-cert.pem \
      --remote-name \
      https://orcharhino.example.com/pulp/content/My_Organization_Label/Library/custom/My_Product_Label/My_Repository_Label/My_File
    • For HTTP:

      # curl \
      --remote-name \
      http://orcharhino.example.com/pulp/content/My_Organization_Label/Library/custom/My_Product_Label/My_Repository_Label/My_File

The text and illustrations on this page are licensed by ATIX AG under a Creative Commons Attribution–Share Alike 3.0 Unported ("CC-BY-SA") license. This page also contains text from the official Foreman documentation which uses the same license ("CC-BY-SA").