ofek / hatch-vcs

Hatch plugin for versioning with your preferred VCS
MIT License
110 stars 15 forks source link

ENH: Determine build contents from VCS file listing #40

Open effigies opened 1 year ago

effigies commented 1 year ago

This is a proof-of-concept. setuptools_scm provides both the version and file listing to setuptools, so this seems like an appropriate place to improve on hatchling's filtering of files based on VCS configuration. This should mean that we get both git and mercurial filtering.

This proposes adding a detect-files boolean flag to [tool.hatch.build.hooks.vcs]. The way this is set up is to accept the file listing from setuptools_scm, run it through the exclusion filters already in place, place the results in artifacts to exempt from exclusion filters, and then set the exclusion filters to universal.

If you have interest in supporting this use-case, I'm happy to update tests (some guidance would be appreciated but I can probably figure it out). I also would change version-file from mandatory to optional.

xref pypa/hatch#304

RonnyPfannschmidt commented 1 year ago

Note that the file finders api is the absolute worst

The plan is to provide a better api later

effigies commented 1 year ago

Duly noted. Are there issues to track to keep tabs on that effort? And do you recommend against this approach in the meantime? The alternative seems to be a full reimplementation of gitignore/hgignore logic inside hatchling itself.

RonnyPfannschmidt commented 1 year ago

No notes yet, the rough plan is to coordinate something after the setuptools_scm 8.x / vcs_versioning transition is done

effigies commented 1 year ago

@ofek Any thoughts on this? I'm happy to commit to adapting to changes in the setuptools_scm 8/vecs_versioning API, when the time comes.

In my tests, it has been helpful at making debugging builds simpler locally, where my repository is less likely to be a clean clone.

RonnyPfannschmidt commented 1 year ago

Absolutely

The rough plan i have in mind is to migrate away from file finders and altering the setuptools commands to include both file lists and scm files

This will include better low level apis

I'd appreciate giving me a little hell/help on the finer details

But also a fair time flow warning

Im on paternity leave, time allocation for open source ain't working at all like I imagined and there is a tunnel vision mistake in setuptools_scm i have to recover from to release the 8.x series

effigies commented 1 year ago

Im on paternity leave, time allocation for open source ain't working at all like I imagined

No worries at all. I completely understand that. And sorry, I wasn't trying to bug you but see if Ofek is interested in this functionality in this particular hatch plugin.

RonnyPfannschmidt commented 1 year ago

Not feeling bugged, but it helps to be aware of surrounding constraints, if my situation was different, we could commit to a vastly different time line

effigies commented 5 months ago

@RonnyPfannschmidt Is there a new file finder API to start playing with? Or discussions you want some input on? Will have time to look into this again in about 3 weeks.

RonnyPfannschmidt commented 5 months ago

No, I'm happy to start exploring this after the pytest sprint next week