Skip to content

Local Python Packages

This page provides an overview of the various options and configurations available when using local-python sources. The quick-start guide also includes a section for getting started quickly with internally-built Python packages.

Local Python Sources#

Similar to the local source for R packages, Package Manager has a local-python source type that can be used for uploading your local Python packages. Any repositories of the python type can subscribe to local-python sources, enabling you to create combined repos that subscribe to both PyPI and your internally-built Python packages. For example:

Terminal
# Create a local Python source:
$ rspm create source --name=local-python-src --type=local-python
<< Source 'local-python-src':
<<  Type:  Local Python
# Create a Python repository:
$ rspm create repo --name=python-repo --type=python --description='Access Python packages'
<< Repository: python-repo - Access Python packages - Python

# Subscribe the repository to the local Python source:
$ rspm subscribe --repo=python-repo --source=local-python-src
<< Repository: python-repo
<< Sources:
<< --local-python-src (Local Python)

# Subscribe the repository to the local Python source:
$ rspm subscribe --repo=python-repo --source=pypi
<< Repository: python-repo
<< Sources:
<< --local-python-src (Local Python)
<< --pypi (PyPI)

# Upload a single package:
$ rspm add --source=local-python-src --path=/path/to/package-1.0.0.tar.gz

# Upload a signed package:
$ rspm add --source=local-python-src --path=/path/to/example-0.0.3-py3-none-any.whl,/path/to/example-0.0.3-py3-none-any.whl.asc

# Upload multiple packages from a directory:
$ rspm add --source=local-python-src --path=/path/to/directory

# Upload multiple packages from a directory. Wildcard works when argument uses an '=' sign:
$ rspm add --source=local-python-src --path=/path/to/directory/*

# Upload multiple packages from a directory, keeping any existing packages:
$ rspm add --source=local-python-src --path=/path/to/directory --succeed-on-existing

# Upload multiple packages from a directory, replacing any existing packages:
$ rspm add --source=local-python-src --path=/path/to/directory --replace

Note

Priority order of sources in a repository is important. If there is a package that is in both PyPI and the local Python source and the repository is subscribed to both, the source that subscribed to the repo first takes precedence by default. The order can be re-arranged by using the rspm reorder command. To find out more, refer to the command description in the CLI appendix.

Note

When uploading multiple packages from a directory, any signature files (*.asc) will be automatically included with their respective package files.

Optionally Enabling Remote Authentication#

Advanced

Local Python sources also support remote token authentication. You can use remote authentication to upload Python packages with either the CLI or with twine.

For more information, see the Remote Publishing documentation.