I've been trying GCP's Artifact Registry, which is currently in alpha for Python packages.
I do the authentication via Keyring along with my service account, as explained in the documentation.
I can successfully upload a package using Twine, and I can successfully download it to a local Python project by installing the following requirements.txt
:
--extra-index-url https://my-region-pypi.pkg.dev/my-project/my-python-repo/simple/
my-package
However, when I deploy a minimal Cloud Function to the same project as my Artifact Registry, with the same requirements.txt
shown above, the deployment fails with the following output:
ERROR: (gcloud.functions.deploy) OperationError: code=3, message=Build failed: `pip_download_wheels` had stderr output:
ERROR: Could not find a version that satisfies the requirement my-package (from -r requirements.txt (line 2)) (from versions: none)
ERROR: No matching distribution found for my-package (from -r requirements.txt (line 2))
I tried with both --extra-index-url
and just plain --index-url
, with no difference. I also tried installing the keyring dependencies with the following requirements.txt
:
--extra-index-url https://my-region-pypi.pkg.dev/my-project/my-python-repo/simple/
keyring
keyrings.google-artifactregistry-auth
my-module
But I get the same error.
I checked the permissions for my default App Engine service account for my project, which is also used for Cloud Functions, and I can confirm that it has the Artifact Registry Reader role, so it doesn't seem to be a permissions issue.
I also tried deploying a minimal App Engine service instead of a Cloud Function, but I get the same error.
Many thanks for the help.
help('modules')
doesn't list my package either). – Romaldagcloud artifacts print-settings python --json-key="somekey.json" --repository=REPO --location=LOCATION
pointingsomekey.json
to a serviceaccount JSON file with the right permissions for the repo. It will generate anextra-index-url
with the auth embedded. Do not put this in a public place as it will contain the JSON SA creds. – Manis403
error when it tries to download the package, but the logs still show that it did find the package as I can see the exact URL for the.whl
file, including version, but the403
is thrown on the download. Note that the SA I used lives in the same project as the repo, with Artifact Registry Reader permissions. – Manis