firebase / firebase/firebase-functions-python

Firebase Functions Python build cannot reliably install private Artifact Registry packages

Offen
#271 3 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
feature-request
Vorherrschende Sprache
Python
Sterne
167
Forks
34
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

## Summary
Deploying Firebase Functions written in Python cannot reliably install private Python packages hosted in Google Artifact Registry using the documented authentication mechanism.

Although Artifact Registry supports authentication via the `keyrings.google-artifactregistry-auth` backend, the Firebase Functions build process installs dependencies in a single `pip` invocation. This creates a bootstrapping problem where the authentication backend must already be installed before pip attempts to resolve private dependencies.

As a result, private packages cannot be consumed out-of-the-box during function deployment causing deployment issues and ultimately meaning private packages cannot be consumed in firebase functions. Private Python packages are a common pattern for shared internal libraries, and the current limitation makes this workflow difficult.

## Expected Behaviour

A Firebase Functions deployment should be able to install private Python packages hosted in Artifact Registry without requiring custom build pipelines, vendored wheels, or containerization.

For example, the following requirements.txt should work:
```
--extra-index-url https://-python.pkg.dev///simple/

private-package==0.0.1
```

provided that:
- the Cloud Build service account has artifactregistry.reader
- the repository contains the package

## Actual Behaviour
The Artifact Registry authentication mechanism requires the keyring backend to be present before pip attempts to fetch packages.

However pip resolves and downloads packages before installing their dependencies, meaning that adding the backend as a dependency does not help.

Example attempt:
```
--extra-index-url https://-python.pkg.dev///simple/

keyring
keyrings.google-artifactregistry-auth
private-package==0.0.1
```

This still fails because pip attempts to resolve `private-package` before installing the keyring backend. This creates a bootstrap race condition

## Why this is a Problem

The current behavior makes it effectively impossible to use private Artifact Registry Python packages with Firebase Functions without workarounds such as:

- vendoring wheels into the repository
- migrating to cloud run where the build process can be controlled

## Environment Details

Builder image:
```
europe-west2-docker.pkg.dev/serverless-runtimes/google-22-full/builder/python:python_20260224_RC00_lightweight
```
Buildpacks used:
```
google.utils.archive-source
google.python.runtime
google.python.functions-framework
google.python.pip
google.utils.label-image
google.python.link-runtime
```
The pip step is executed as:
```
python3 -m pip install --requirement requirements.txt
```
Python runtime:
```
Python 3.13.12
```

## Suggested Solutions

### Option 1: Preinstall Artifact Registry authentication backend

Ensure the build environment includes:
```
keyring
keyrings.google-artifactregistry-auth
```
before the pip install step.

### Option 2: Two-phase dependency install

Modify the Python buildpack to run:
```
pip install keyring keyrings.google-artifactregistry-auth
pip install -r requirements.txt
```

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Start by reviewing the listed google.python.pip buildpack and the command `python3 -m pip install --requirement requirements.txt` in the specified builder image. Reproduce the failure with the example requirements.txt and verify the Cloud Build service account permissions. Done means a Firebase Functions deployment can install the private Artifact Registry package without vendoring, custom pipelines, or containerization.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
google-cloud, python
Bereich
build-system, cloud
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.