fix(python): force Poetry buildpack via GOOGLE_PYTHON_PACKAGE_MANAGER#464
Merged
fix(python): force Poetry buildpack via GOOGLE_PYTHON_PACKAGE_MANAGER#464
Conversation
… env var Despite poetry.lock and [tool.poetry] being present, the google-24 buildpack was falling back to the pip layer and auto-detecting gunicorn, leaving fastapi and all other dependencies uninstalled. Setting GOOGLE_PYTHON_PACKAGE_MANAGER=poetry in the pack build step explicitly activates the Poetry buildpack, which installs all dependencies from poetry.lock and uses the [tool.poetry.scripts] start entry as the container entrypoint. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Python Cloud Build configuration to explicitly force Google’s buildpacks builder to use the Poetry package manager during pack build, preventing fallback to pip-based framework auto-detection and missing runtime dependencies.
Changes:
- Adds
--env=GOOGLE_PYTHON_PACKAGE_MANAGER=poetryto thepack buildinvocation for the Python service.
…bility The Poetry buildpack (google.python.poetry@0.1.0) fails to activate in Cloud Run's builder, falling back to pip framework auto-detection which only installs gunicorn without project dependencies. Restoring requirements.txt ensures the pip buildpack installs all dependencies, including OpenTelemetry packages added in #458. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…yaml Reverting the Poetry buildpack override since we're restoring requirements.txt to let the pip buildpack handle dependencies as before. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…entation httpx was in the dev group but is required at runtime by opentelemetry-instrumentation-httpx. Moved to main dependencies and regenerated requirements.txt and poetry.lock. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add a note in src/python/README.md (Cloud Run section) and AGENTS.md explaining that requirements.txt must be regenerated with: poetry export --without-hashes --without dev -f requirements.txt -o requirements.txt after any dependency change, and committed alongside pyproject.toml/poetry.lock. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Starlette raises "Cannot add middleware after an application has started" when instrument_app() is called inside the lifespan handler. Middleware must be registered before the app starts, so moved the call to module level immediately after the FastAPI app is created. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
poetry.lockand[tool.poetry]being present, thegoogle-24buildpack was falling back to the pip layer and auto-detecting gunicorn — leavingfastapiand all other dependencies uninstalled at runtime--env=GOOGLE_PYTHON_PACKAGE_MANAGER=poetryto thepack buildstep to explicitly activate the Poetry buildpackpoetry.lockis used to install all dependencies and[tool.poetry.scripts] startbecomes the container entrypoint (poetry run start→openapi_server.cli:main)Root cause
The Google Cloud buildpack documentation states the Poetry buildpack activates automatically when
poetry.lock+pyproject.tomlor[tool.poetry]is present — but in practice thegoogle-24builder was ignoring these signals and falling back to pip framework auto-detection.Test plan
/layers/google.python.poetry/) instead of pip layerfastapiandopentelemetry-*are installedpoetry run startand uvicorn (not gunicorn)GET /healthreturns 200🤖 Generated with Claude Code