Skip to content

Docs feedback: PyPI publishing doesn't seem to be right (multiple issues)

I'm trying to follow the instructions on https://docs.gitlab.com/ee/user/packages/pypi_repository but I can't get it to work.

Issues I have encountered:

  • at https://docs.gitlab.com/ee/user/packages/pypi_repository/#authenticate-with-a-ci-job-token it recommends to check a ~/.pypirc file into Gitlab. I read that as project root, but it turns out it really means home directory, which I can't check in (or can I?). Referencing the file explicitly with --config-file on the twine call fails with the environment variables not being resolved but being taken literally.
  • the whole documentation uses gitlab.example.com URLs. I can't see what the real one should be for cloud-hosted, I ended up assuming it's just gitlab.com -- it would be good to know.
  • after a few more attempts I ended up with this call: TWINE_PASSWORD=${CI_JOB_TOKEN} TWINE_USERNAME=gitlab-ci-token python -m twine upload --repository-url https://gitlab.com/api/v4/projects/${CI_PROJECT_ID}/packages/pypi dist/* -- but that ends in a 400 Bad Request

Right now I still have no idea how to fix that.

In case you are happy to turn this into a bit of support and/or need more detail: here are my attempts at making the build work: https://gitlab.com/bhp-cloudfactory/aws-apps/paspo/application/paspo-common