Skip to content
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

support distribution metadata substitution in write_to path #583

Open
RonnyPfannschmidt opened this issue Jun 16, 2021 · 3 comments
Open

Comments

@RonnyPfannschmidt
Copy link
Contributor

RonnyPfannschmidt commented Jun 16, 2021

unfortunately current packaging practices make it necessary to have the package name yet again in the src folder

practically this means people have to spell the package name in the write_to parameter

they should be able to do something like

[tool.setuptools_scm]
write_to = "src/{toplevel}/_version.py"

Originally suggested by @smarie in #582 (comment)

ideally in future src will directly map to the toplevel of a package

@smarie
Copy link
Contributor

smarie commented Jun 16, 2021

So efficient as always. Thanks @RonnyPfannschmidt !

@ssbarnea
Copy link

ssbarnea commented Nov 12, 2024

I really want to see this happening because it makes much harder to keep pyproject.toml synchronized across projects. Sadly TOML file format does not have support for generic substitutions like tox has. It only supports environment variables substitutions which is of no use for us, as we need to refer to refer to project.name and also to normalize the value as the name might be foo-bar, and it should translate to foo_bar.

On the other hand, I wonder if we could have another generic approach that does not need that and that will use the first module directory, mile write_to = "{module_dir}/_version.py"- module_dir should resolve to ./src/foo_bar.

Any suggestions about approaches that could be implemented easily? -- We don't have to cover for multi-module care from start, as it a very uncommon layout.

Update

I recently sorted another duplication in pyproject.toml by using via

[tool.ruff.lint.isort]
known-first-party = ["src"] # <-- used to be hardcoded name of the package

This makes me think that maybe using glob could be found suitable and also cover for the case where we have multiple python modules:

[tool.setuptools_scm]
write_to = "src/*/_version.py

@RonnyPfannschmidt
Copy link
Contributor Author

I'm not going to support globs in that way unless we have a trustable 3rd party implementation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants