Repository navigation
Conversation
Without an explicit package list, setuptools falls back to flat-layout
auto-discovery, which sees two candidate top-level directories at the repo
root (`cloudflare/` and `gemini_web2api/`) and aborts:
error: Multiple top-level packages discovered in a flat-layout:
['cloudflare', 'gemini_web2api']
`cloudflare/` is a JavaScript Cloudflare Worker (no Python at all), but the
discovery heuristic only checks for a directory, so it wins alphabetically
and the build dies before the wheel is written.
This affects every installer path that builds a distribution: `uv build`,
`pip install .`, `pip install "gemini-web2api @ git+https://..."`,
`uv tool install`, and PyPI publishing. Running the single-file script and
the Docker image are unaffected because neither installs a package.
Use `packages.find` with an include pattern rather than a hardcoded list so
that future subpackages (and the `tests/` package, which must stay out) are
handled automatically.
The existing workflow only builds the Docker image, and the Dockerfile copies `gemini_web2api/` directly and runs it with `python -m`, so nothing in CI ever exercises the pyproject build. That is how the broken flat-layout discovery shipped unnoticed. This job builds both distributions, installs the wheel with the `[streaming]` extra in a clean venv, and asserts the console script runs and that httpx was actually pulled in.
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.
Problem
Every packaging path fails on
main:pyproject.tomlhas no[tool.setuptools]section, so setuptools uses flat-layout auto-discovery. It finds two candidate top-level directories —cloudflare/andgemini_web2api/— and refuses to guess.cloudflare/is a JavaScript Cloudflare Worker with no Python in it, but the heuristic only looks for a directory, so it is counted (and wins alphabetically before the real package is even considered).Why it went unnoticed
Nothing in the repo builds a distribution:
python gemini_web2api.pyCOPY gemini_web2api/+python -mSo only users on the
pip install/uv tool installpaths hit the error.Change
Using
packages.findwith an include pattern rather than a hardcodedpackages = ["gemini_web2api"]list so future subpackages are picked up automatically. The pattern also keepstests/(which does have an__init__.py) out of the distribution.Verification
On a clean checkout of this branch:
uv build→gemini_web2api-1.1.0-py3-none-any.whl+gemini_web2api-1.1.0.tar.gzgemini_web2api/*.pyfiles plusdist-info;tests/andcloudflare/are absent,top_level.txtis a single linegemini_web2api/_tmpsub/) makes it appear in the wheel automatically, then removing it makes it disappearpip install dist/gemini_web2api-1.1.0.tar.gzinto a clean venv →gemini-web2api --versionprintsgemini-web2api 1.1.0uv tool install --python 3.13 --with httpx .→Installed 1 executable: gemini-web2apipytest tests→ 18 passedpython gemini_web2api.py(single-file path documented in README) is untouched by this changeThe second commit adds a
Buildworkflow so this class of failure cannot recur: it builds both distributions, installs the wheel with the[streaming]extra into a clean venv, runs the console script, and asserts httpx was resolved.Related (not fixed here, separate PRs welcome)
gemini_web2api/__main__.pyprintsListening: http://0.0.0.0:{port}unconditionally, ignoringCONFIG["host"]— a server bound to127.0.0.1reports0.0.0.0, and vice versa.dependencies = []with httpx behind thestreamingextra meanspip install gemini-web2apisilently yields buffered SSE; the README's Quick Start tells users topip install httpxbut the package path never mentions it.