Skip to content

Instantly share code, notes, and snippets.

@Menziess
Created January 9, 2025 14:15
Show Gist options
  • Save Menziess/ffa5054d471901e569a854e413d50cce to your computer and use it in GitHub Desktop.
Save Menziess/ffa5054d471901e569a854e413d50cce to your computer and use it in GitHub Desktop.

Gitlab PyPi Repo

Downloading

  • 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>

Uploading

  • 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/*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment