Search code examples
python-3.xgoogle-cloud-platformpython-3.9artifactgoogle-artifact-registry

Request has invalid argument Error on uploading to python Artifact Registry [gcp]


I am trying to upload a python package to GCP's Artifact Registry. I installed keyring and keyrings.google-artifactregistry-auth, added .pypirc and pip.conf files with the url to the private registry on GCP inside of them, and setup the environment variable GOOGLE_APPLICATION_CREDENTIALS as per this documentation.

I created a dummy python package to test the upload to the private pypi. python setup.py install runs successfully. When running twine:

twine upload --verbose -r https://<LOCATION>-python.pkg.dev/<PROJECT_ID>/<REPO_NAME>/ --config-file <PATH_TO_PYPIRC> dist/*

I get the following error:

Uploading distributions to https://<LOCATION>-python.pkg.dev/<PROJECT_ID>/<REPO_NAME>/
  dist/my_library-0.0.1-py3.9.egg (2.6 KB)
username set from keyring
password set from keyring
username: oauth2accesstoken
password: <hidden>
Uploading my_library-0.0.1-py3.9.egg
100%|█████████████████████████████████████████████████| 6.30k/6.30k [00:00<00:00, 47.8kB/s]
Content received from server:
Request has an invalid argument: extension type

HTTPError: 400 Bad Request from https://<LOCATION>-python.pkg.dev/<PROJECT_ID>/<REPO_NAME>/
Bad Request

Solution

  • using wheel instead of eggs made me upload successfully python setup.py bdist_wheel