Configuring PyPI to work with the SourceCraft registry
-
Create a personal access token (PAT).
-
In the user’s root directory, create a file named
~/.pypircwith the following content and specify the token in it:[distutils] index-servers = sourcecraft [sourcecraft] repository = https://pkg.sourcecraft.tech/pypi/<organization_slug>/<registry_ID>/legacy/ username = iam password = <personal_access_token>Tip
You can find the organization slug and registry ID on the registry page in the SourceCraft UI.
-
To push the prepared pip package to the SourceCraft registry, run this command:
Note
The package must be assembled in a Python virtual environment.
python3 -m twine upload <path_to_package> \ --repository sourcecraftResult:
Uploading distributions to https://pkg.sourcecraft.tech/pypi/myorg/cn1bgtp9c21b********/legacy/ Uploading my_package-0.0.1-py3-none-any.whl 100% ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.1/4.1 kB • 00:00 • ? Uploading my_package-0.0.1.tar.gz 100% ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.7/3.7 kB • 00:00 • ? -
To install a pip package from the SourceCraft registry:
-
Create an environment variable containing the SourceCraft personal access token (PAT):
export PAT_TOKEN="<personal_access_token>" -
Run this command:
pip install \ --index-url https://iam:${PAT_TOKEN}@pkg.sourcecraft.tech/pypi/<organization_slug>/<registry_ID>/simple/ \ <package_name>Result:
Looking in indexes: https://iam:****@pkg.sourcecraft.tech/pypi/myorg/cn1bgtp9c21b********/simple/ Collecting my-package Downloading https://pkg.sourcecraft.tech/pypi/myorg/cn1bgtp9c21b********/simple/my-package/0.0.1/-/my_package-0.0.1-py3-none-any.whl (1.6 kB) Installing collected packages: my-package Successfully installed my-package-0.0.1
-
See also
- SourceCraft resource relationships
- Creating a registry in SourceCraft
- Connecting a registry to a SourceCraft repository
- Configuring Maven to work with a SourceCraft registry
- Configuring npm to work with a SourceCraft registry
- Configuring NuGet to work with a SourceCraft registry
- Configuring Docker to work with a SourceCraft registry
Was the article helpful?
Previous