hatch icon indicating copy to clipboard operation
hatch copied to clipboard

Builder plugin configuration in pyproject.toml is ignored

Open ssiccha opened this issue 9 months ago • 0 comments

Hi folks, first of all thanks for the awesome project! I'm building a builder plugin - hatch-my-plugin say - and have a problem when I add its target to a test package's pyproject.toml. I test hatch-my-plugin in a separate package and am able to run hatch build -t my-plugin without problems. However when I run hatch build the new target is ignored and it only builds the sdist and wheel targets.

I've set it up like this:

  • hatch-my-plugin has the entry-point configured as in https://hatch.pypa.io/latest/plugins/about/#discovery and the hooks.py and plugin.py as on https://hatch.pypa.io/latest/plugins/builder/reference/#hatchling.builders.plugin.interface.BuilderInterface.
  • dependency-A depends on the plugin in the [build-system] section of the pyproject.toml and has a section [tool.hatch.build.targets.my-plugin].

I can reproduce the same when I test the plugin as described in https://hatch.pypa.io/latest/how-to/plugins/testing-builds/. That is when I subprocess.run [sys.executable, "-m", "hatch", "build", "-t", "my-plugin"] it works fine. When I subprocess.run [sys.executable, "-m", "hatch", "build"] the my-plugin target added to the pyproject.toml gets ignored. I'm using this pyproject.toml for the temporary new_project:

        f"""\
[build-system]
requires = ["hatchling", "my-plugin @ {plugin_dir.as_uri()}"]
build-backend = "hatchling.build"

[project]
name = "my-app"
version = "1.0.0"

[tool.hatch.build.targets.my-plugin]
a = 1
""",

Could I be misconfiguring the plugin somewhere?

One pointer I have is that I set up the test_hooks.py similar to what is in the example [1] linked in the docs, however for me the assert plugin_manager.builder.get("my-plugin") is MyBuilder fails with the left side being None instead of MyBuilder.

[1] https://github.com/dairiki/hatch-zipped-directory/blob/master/tests/test_hooks.py

ssiccha avatar May 08 '25 19:05 ssiccha