Discover sample packages instead of listing them - #333
Open
brianstrauch wants to merge 1 commit into
Open
Conversation
Hatchling's `packages` setting takes literal paths and does not accept patterns, so the wheel target listed every sample by hand. That list drifted: an entry naming a directory that does not exist is ignored without a warning, so `nexus` (added in #174, where the directory was actually `hello_nexus`) never matched anything, and 14 sample directories added since the uv migration were never shipped — including `google_adk_agents` and `openai_agents`. The sdist shipped no samples at all. Switch to setuptools, whose `packages.find` discovers them declaratively, so adding a sample requires no build config change. Namespace discovery is needed because some samples have subdirectories without an `__init__.py`. Verified: the wheel and sdist each contain exactly the 652 tracked sample .py files (the wheel previously had 405 from 33 hand-listed entries; the sdist had none), with no venv, cache, or lambda_worker content; a wheel install and an editable install both import samples the old list omitted; the AI sample tests pass against the reinstalled editable project. Co-Authored-By: Claude Opus 5 (1M context) <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.
Problem
The wheel target listed every sample directory by hand, and hatchling's
packagessetting takes literal paths — it does not accept patterns — so the list had to be maintained manually. It drifted, silently: an entry naming a directory that does not exist is ignored without a warning.nexuswas added in Nexus samples #174, where the directory was actuallyhello_nexus, so it has never matched anything.google_adk_agentsandopenai_agents.#170 called this out when it introduced the list: "contributors will have to explicitly add samples to this list... I haven't yet found a way to automatically add top-level directories matching a pattern as packages." Poetry's previous config globbed (
{include = "**/*.py", from = "."}); the hatchling translation could not.Change
Switch the build backend to setuptools and let
packages.finddiscover the samples, so adding a sample needs no build config change:Net
-51lines: the 33-entry list, both hatch build targets, thesourcesmapping, and[tool.hatch.metadata]all go away.setuptools>=77is the floor for PEP 639 (license = "MIT"as a string), verified by building under that constraint.Namespace discovery (the default) is required:
openai_agents/*andmessage_passing/update_with_start/lazy_initializationhave subdirectories without an__init__.py, andnamespaces = falsedrops 122 files.Verification
.pyfiles — a set match againstgit ls-files— with no venv, cache,lambda_worker, or.githubcontent. The wheel previously had 405; the sdist had none.google_adk_agents,openai_agents); running a sample script by path still resolves its absolute imports.pytest tests/strands_plugin tests/langgraph_plugin tests/google_adk_agents— 27 passed against the reinstalled editable project.Notes
temporalio_samples.egg-info/into the working tree, hence the.gitignoreaddition..pth, so a brand-new sample directory is not importable by path untiluv syncre-runs. CI is unaffected (it syncs after checkout), and pytest is unaffected (rootdir goes onsys.path).uv_builddocuments no support for multiple top-level modules (itsmodule-namelist form is discouraged, and would be the same 47-entry enumeration); uv's recommended workspace layout would need 47 member manifests plus nesting every sample a level deeper, which changes 237 documenteduv run <path>commands and every deep link.🤖 Generated with Claude Code