rules_python icon indicating copy to clipboard operation
rules_python copied to clipboard

tweak(whl_library): capture arbitrary files as data

Open arrdem opened this issue 1 year ago • 10 comments

This fixes wheels like ruff which want to emplace bin/ and other dirs used as library data.

arrdem avatar Jan 30 '24 01:01 arrdem

Thanks for the PR @arrdem, could you please fix the tests and add a CHANGELOG item so that we can merge it? This looks like a really useful feature.

aignas avatar Jan 31 '24 05:01 aignas

Wilco. Work's a bit crazy atm just wanted to get this patch in the upstream pipe before I forgot about it since it was trivial.

arrdem avatar Jan 31 '24 16:01 arrdem

There we go. Ready @aignas.

arrdem avatar Feb 14 '24 22:02 arrdem

Could you add a Changelog note so that I can merge?

aignas avatar Apr 06 '24 03:04 aignas

Hrm. Reading through https://peps.python.org/pep-0491/#file-contents, I'm wondering if this actually makes sense. It feels like while it may well make sense to have a :data filegroup, we probably want to handle at lest data, scripts and include separately. While for my purposes it's good enough to just have a build rule that encloses the ruff binary it would be better if we could identify scripts as part of unpacking the wheel and make them usable as entrypoint rules rather than just files.

On the same note whether the data should be a dependency of the library seems arguable.

arrdem avatar Apr 19 '24 04:04 arrdem

Looking at https://peps.python.org/pep-0491/#install-paths I am wondering if the right way to fix this would be to add the extra filegroup targets for each item listed in the UNIX install scheme.

That said, we may want to include all of those filegroups into the py_library so that the library can work correctly - Python can do whatever and assume that the files are installed in site-packages so I am wondering if adding the filegroups on the other hand would be not effective at all.

That said having the filegroups exposed would make the numpy header inclusion easier and users would not need to use whl_filegroup in their build graph to just extract a few files.

aignas avatar Jul 26 '24 04:07 aignas

Missclick.

That makes sense to me. The main other thing I want to do is to teach the wheel installer to identify scripts/binaries already in the bin/ tree and add entrypoint metdata for them automagically. Will try to revisit this.

arrdem avatar Jul 26 '24 18:07 arrdem

Thanks! Is it so that you could later use the py_console_script_binary to use those scripts?

aignas avatar Jul 27 '24 05:07 aignas