Add hatch/hatchling packaging support with configurable default build tool#722
Add hatch/hatchling packaging support with configurable default build tool#722Copilot wants to merge 7 commits into
Conversation
|
@ copilot, do not hardcode the default package type in different places. Put it in the config |
|
@copilot is the a need or benefit to store the build backend of the package on the database? Also you have not done or at least reported on the fit of different package backendd for this as use. |
Done in commit 55d840c.
Database storage (commit 0b4c224)Yes, there is a concrete need. Changes made:
Build backend comparison for stub-only packages
Recommendation: Hatchling is the best fit going forward. Key reasons for stub-only packages specifically:
Poetry remains the backward-compatible default so existing published packages are unaffected. New packages or projects that opt in via Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot for the folders mip/** and src/stubber/board ignore any changes in this branch , and prefer the changes in the main branch |
... Done in commit 46da93e. Rebased onto |
ba21f46 to
98d07e6
Compare
Codecov Report❌ Patch coverage is ❌ Your patch check has failed because the patch coverage (47.05%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #722 +/- ##
==========================================
- Coverage 72.36% 69.76% -2.60%
==========================================
Files 71 71
Lines 8399 8540 +141
Branches 1541 1555 +14
==========================================
- Hits 6078 5958 -120
- Misses 1823 2102 +279
+ Partials 498 480 -18 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@copilot |Please investigate , and fix ( similar database test issues have been seen and fixed before) |also make sure to run a full test locally before comitting.| Error:| mocker = <pytest_mock.plugin.MockerFixture object at 0x10faf3ba0>
tests/publish/test_publish.py:143: src/stubber/publish/stubpackage.py:1342: in publish_distribution_ifchanged self = micropython-fake-stubs==1.19.1, dry_run = False, production = False
E sqlite3.OperationalError: table packages has no column named package_type src/stubber/publish/stubpackage.py:1391: OperationalError tests/rst/test_rst.py::test_rst_all tests/rst/test_rst.py::test_rst_all tests/rst/test_rst.py::test_rst_all tests/rst/test_rst.py::test_rst_all tests/rst/test_rst.py::test_rst_all tests/rst/test_rst.py::test_rst_all tests/rst/test_rst.py::test_rst_all tests/rst/test_rst.py::test_rst_all -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html Coverage XML written to file results/coverage.xml |
... Fixed in commit a99c23b. The failure was |
ce413c0 to
1de673f
Compare
1de673f to
eff6b61
Compare
Bumps [pytest](https://github.com/pytest-dev/pytest) from 7.4.4 to 9.0.3. - [Release notes](https://github.com/pytest-dev/pytest/releases) - [Changelog](https://github.com/pytest-dev/pytest/blob/main/CHANGELOG.rst) - [Commits](pytest-dev/pytest@7.4.4...9.0.3) --- updated-dependencies: - dependency-name: pytest dependency-version: 9.0.3 dependency-type: direct:development ... Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
… test assertions Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
…lder class, and --package-type CLI option Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
…gurable via pyproject.toml) Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
…igration and pyproject.toml inference Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
eff6b61 to
27827ce
Compare
The stubber packaging pipeline was locked to Poetry with no way to adopt modern PEP 517 build backends. This PR introduces a pluggable build-tool architecture supporting both Poetry (default, backward-compatible) and Hatchling, with the default driven by a single config entry rather than hardcoded in multiple places.
New
PackageTypeenum &HatchBuilderPackageType.POETRY/PackageType.HATCHinpublish/enums.pyHatchBuilder(Builder)instubpackage.py— mirrorsPoetryBuilderbut driveshatch build/hatch publish, writes[tool.hatch.build.targets.wheel] includeinstead of listing individual.pyifiles in[tool.poetry] packages, and reads from the newpyproject_hatch.tomltemplateStubPackagedispatchStubPackageretainsPoetryBuilderinheritance for backward compat but now acceptspackage_typeand overridescreate_update_pyproject_toml(),update_pyproject_stubs(),build_distribution(), andpublish_distribution()to route to the correct builder:Config-driven default
The default build tool lives solely in
StubberConfig.package_type— there is no hardcodedPackageType.POETRYanywhere else:CONFIG.package_type(defaultPackageType.POETRY) is used as the default forStubPackage.__init__,create_package,get_package,build_multiple, andpublish_multiple.show-confignow prints it.CLI
Both
stubber buildandstubber publishgain--package-type [poetry|hatch](default sourced from config):Templates
New
publish/template/pyproject_hatch.tomlfor hatchling packages —[project]+[build-system]withhatchling,[tool.hatch.build.targets.wheel] includepopulated at build time via glob-friendly patterns instead of individual file listings.Database storage of build backend
The
packagesdatabase now storespackage_typealongside every published package record:package_type TEXT DEFAULT 'poetry'_migrate_add_package_type()runs on everyget_database()call, adding the column to pre-existing databases transparently (old rows default to'poetry')from_dict()restores the correct backend when loading a package from the DB; for legacy rows that predate the column,_infer_package_type()auto-detects the backend by reading[build-system].build-backendfrom the on-diskpyproject.tomlThis prevents a correctness bug where reloading a hatch-built package under the Poetry default would attempt to access
[tool.poetry]keys in a hatchling-formatpyproject.toml.Build backend comparison
For stub-only packages, Hatchling is recommended for new packages:
.pyifiles**/*.pyipatternsPoetry remains the default so all existing published packages are unaffected.
Original prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.