-
-
Notifications
You must be signed in to change notification settings - Fork 306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature Request] Better project template configuration options #1701
Comments
Although not documented, it is possible to create plugins that augment, or completely replace the built in templating. You'll need make a class derived from TemplateInterface and set up the hooks / entry points as described in the plugins section of the docs. Reading the source for the default template will give you a good idea of how to do it. Once you've created your plugin, you'll need to update your hatch config and add your plugin and its configuration (you can find your configuration with [template.plugins.YOUR-PLUGIN] # <<<< add your plugin here
my-opt1 = true
[template.plugins.default] # <<<< remove this entire section if you want to completely replace the default template
tests = true
ci = false
src-layout = true |
Ok, where exactly does the code for my plugin have to be in order for hatch to locate it? Is there a plugin directory somewhere? Do I have to publish it and it gets installed? The plugin section of the docs answers none of these questions. |
These are python-isms, not necessarily just hatch things. The plugin has to be accessible to the build system, to do that, declare the plugin as a build time dependency in your pyproject.toml. Typically, these are pip installable, however, you can also specify python distributions that exist locally. [build-system]
requires = ["hatchling", "hatch-your-plugin @ <PATH_TO_YOUR_PLUGIN>"]
build-backend = "hatchling.build" |
Okay this is what doesn't make any sense to me. This is like a chicken-and-egg problem. The point is that the plugin augments the behavior of I assume I need to tell hatchling about my plugin in hatch's global configuration file. Is this not the case? |
Sorry yes, you're correct. You'll need to install your template plugin into whatever environment hatch is running from. If you installed hatch with pipx, you can use |
Hmm. I'm using the binary distribution from the .tar.gz Thanks for all the help! |
I really like hatch. In fact, I've been using it a lot.
However, the one area where hatch is weakest is in project templates. We have almost no ability to modify how project templates are created (or at least, none documented). The documentation for the configuration options is lacking, and the blogposts don't seem to be paying any attention to it, either.
First, licenses should be always put in the LICENSES/ directory regardless if there is more than one license. This is in accordance with the REUSE spec. If there is one license, it is fine to have it in the project root as well, but the creation of the LICENSES directory should not be conditional.
Second, there is currently no way to adjust the copyright text in headers. For instance, it always uses the author for the copyright text. This is insufficient for a good percentage of projects, where the author is different from the copyright holder (e.g., where work done is copyrighted by the company and not the author).
Third, is there support for defining arbitrary project template structures? What if I want to add, say, a .editorconfig to the project root. Or maybe I want a default .gitignore, or to change the placeholder text in README.md. If there are ways of doing this already, they are not communicated to the user.
The text was updated successfully, but these errors were encountered: