Skip to content

Add prefix to paths and remove explicit file list - #709

Merged
jpodivin merged 1 commit into
packit:mainfrom
jpodivin:fix_package
Jul 28, 2026
Merged

Add prefix to paths and remove explicit file list#709
jpodivin merged 1 commit into
packit:mainfrom
jpodivin:fix_package

Conversation

@jpodivin

Copy link
Copy Markdown
Collaborator

The list of files in ymir-common was out of date again. I don't think that full restructuring of the layout is warranted at this point, but we can at least make situation slightly less brittle.

Hatch allows for rewriting of paths. This way we can pretend that our pyproject.toml files are actually two levels higher than they are. With this prefix in place, we can safely select files by a glob and do away with the list.

https://hatch.pypa.io/latest/config/build/#rewriting-paths

@jpodivin
jpodivin requested review from TomasKorbar and nforro July 24, 2026 08:54
@qodo-for-packit

Copy link
Copy Markdown

PR Summary by Qodo

Use Hatch sources prefix + glob includes to avoid brittle wheel file lists

⚙️ Configuration changes 🕐 10-20 Minutes

Grey Divider

AI Description

• Switch Hatch wheel builds to include Python sources via glob patterns.
• Add Hatch sources path rewrite so nested pyprojects map to correct package roots.
• Remove manual force-include file lists that frequently drift out of date.
Diagram

graph TD
  C["ymir/common/pyproject.toml"] --> B(["Hatch wheel build"]) --> W[["Wheel artifact"]]
  T["ymir/tools/pyproject.toml"] --> B
  B --> S["sources prefix rewrite"]
  B --> G["include/exclude globs"]

  subgraph Legend
    direction LR
    _f["Config file"] ~~~ _p(["Build step"]) ~~~ _a[["Output artifact"]]
  end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Restructure to a single top-level pyproject (monorepo workspace)
  • ➕ Removes need for path rewriting; build config lives at the real project root
  • ➕ Easier to share common build settings across subpackages
  • ➖ Bigger layout change; may ripple through tooling/CI and release process
  • ➖ Higher migration cost than this targeted fix
2. Rely on Hatch/packaging package discovery (`packages`/src-layout) instead of globs
  • ➕ More explicit package semantics; avoids accidentally including non-package Python files
  • ➕ Often aligns better with standard packaging expectations
  • ➖ May still require layout adjustments (e.g., src/) to be robust
  • ➖ Could be more work than desired if current structure is intentionally nonstandard
3. Keep `force-include`, but generate it (script/CI check)
  • ➕ Very explicit wheel contents; tight control of what ships
  • ➕ Can prevent accidental additions to artifacts
  • ➖ Still brittle unless generation is enforced; adds maintenance/CI complexity
  • ➖ Doesn’t address path-root mismatch that sources rewrite cleanly solves

Recommendation: The chosen approach (sources path rewrite + glob include/exclude) is the best incremental improvement: it fixes the root/path mismatch cleanly and removes the recurring maintenance burden of manual file lists without requiring a disruptive repo layout change. If artifact strictness becomes a concern later, consider switching from broad **/*.py to narrower globs (e.g., only under the intended packages) or adopting standard package discovery.

Files changed (2) +8 / -48

Other (2) +8 / -48
pyproject.tomlReplace force-included file list with glob include/exclude + sources mapping +4/-12

Replace force-included file list with glob include/exclude + sources mapping

• Removes the explicit 'force-include' mapping and switches the wheel build to 'include = ["**/*.py"]' with 'exclude = ["tests/**"]'. Adds a '[tool.hatch.build.targets.wheel.sources]' entry mapping the build root to 'ymir/common' so paths are rewritten correctly during packaging.

ymir/common/pyproject.toml

pyproject.tomlUse glob-based wheel contents and add sources rewrite for ymir/tools +4/-36

Use glob-based wheel contents and add sources rewrite for ymir/tools

• Drops the long 'force-include' list in favor of 'include = ["**/*.py"]' and 'exclude = ["**/tests/**"]'. Adds a wheel 'sources' mapping to treat 'ymir/tools' as the effective build root, making file selection robust to new modules/subpackages.

ymir/tools/pyproject.toml

@qodo-for-packit

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Qodo Logo

@jpodivin
jpodivin force-pushed the fix_package branch 2 times, most recently from b3d4211 to 8ea2cb4 Compare July 26, 2026 15:48
@jpodivin jpodivin mentioned this pull request Jul 26, 2026
Signed-off-by: Jiri Podivin <jpodivin@redhat.com>
@jpodivin
jpodivin merged commit 088cd5d into packit:main Jul 28, 2026
11 checks passed
@jpodivin
jpodivin deleted the fix_package branch July 28, 2026 07:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants