Skip to content

Sharing state across plugins #1029

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

Closed
jwodder opened this issue Nov 4, 2023 · 5 comments
Closed

Sharing state across plugins #1029

jwodder opened this issue Nov 4, 2023 · 5 comments

Comments

@jwodder
Copy link
Contributor

jwodder commented Nov 4, 2023

I'm the author of the setuptools plugin versioningit, and I'm currently adding support for hatch to it. At the moment, I'm having trouble converting versioningit's "onbuild" step, which embeds the project version and other details in sdists & wheels by modifying the files in the artifacts as they're being built. The text thus inserted can be templated using a number of variables containing VCS data, which is fetched by versioningit when computing the project version earlier in the build. Unfortunately, it appears that hatch's current API does not provide a facility for a build hook to access non-version data returned by a version source, which means that I would have to run a bunch of git commands twice, which I'd rather not do, as it feels redundant and would slow things down (and I've previously gotten issues about speed).

Is there a way for a build hook to access extra version source details that I'm missing? If not, could one be added?

@ofek
Copy link
Collaborator

ofek commented Nov 4, 2023

Can you please paste your build hook code showing an attempted access? I can then give you the proper path to get the object.

@jwodder
Copy link
Contributor Author

jwodder commented Nov 4, 2023

@ofek I haven't attempted access or written any code for the build hook yet, as I didn't see a way to get the behavior I'd want from the documentation. The build hook would just inherit BuildHookInterface and define initialize() to obtain the VCS data somehow, get the user config from self.config, and then go to town on self.directory.

@ofek
Copy link
Collaborator

ofek commented Nov 4, 2023

@jwodder
Copy link
Contributor Author

jwodder commented Nov 5, 2023

@ofek That works, thanks! It seems hook classes have a number of undocumented attributes that could use some documenting.

@jwodder jwodder closed this as completed Nov 5, 2023
@rob-smallshire
Copy link

I open an issue w.r.t. the undocumented metadata attribute. #1932

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

No branches or pull requests

3 participants