- Create a Gitlab PAT here: link, having the
read_api
scope.
- Modify (or create)
~/.pip/pip.conf
on your machine, and replace with your token and <GROUP_ID> with the project's group id:
[global]
index-url = https://pypi.org/simple
extra-index-url = https://__token__:<PAT>@gitlab.com/api/v4/groups/<GROUP_ID>/-/packages/pypi/simple
- Confirm that packages can be found:
pip index versions <MY_PACKAGE>
- Create a
~/.pypirc
file containing a different (having api
permissions):
[distutils]
index-servers =
gitlab
[gitlab]
repository = https://gitlab.com/api/v4/projects/<GROUP_ID>/packages/pypi
username = __token__
password = <PAT>
- Run
twine upload --repository gitlab dist/*