Is there a way to "extend" (wrap?) a Pants "shippe...
# plugins
g
Is there a way to "extend" (wrap?) a Pants "shipped" rule from a plugin? I hacked a bit on Rust native components, but I can't seem to get the file into a pex in any way, not even as a direct dependency. As far as I can tell neither a
pex_binary
nor a
python_source
will pickup a "generic" BuiltPackage. 😞
b
I think that sort of extension usually happens via unions, that the rule has to have hard-coded support for. For your particular case, can you turn the file(s) into a "resource"? Potentially the implementation of
experimental_wrap_as_resource(s?)
is relevant inspiration
c
I guess pants needs to see it as a
resource
in order to pull it in…
πŸ‘†
g
Hmm, yeah, I tried the
experimental_wrap_as_resources
but I'd likely need a
experimental_wrap_package_as_resources
to make it work as expected. Will play around with that tomorrow. I'm wondering if there's some nice way of making it "automatic" though... Maybe one can piggyback ontop of codegen? Would be nice to be able to avoid an extra target.
b
yeah, I think there's been a lot of rumblings about simplifying the file vs. resource split, plus how that interacts with packageable targets, e.g. https://github.com/pantsbuild/pants/discussions/19984, and the existence of the various
wrap_..._as_resources
targets and even various "special cased dependency" fields like
runtime_package_dependencies
on
python_test
.
c
agreed, this area is a bit murky and could use a do-over..
codegen is flexible enough to be able to taper over this, I think.. until we have something better that could be an option
g
Codegen ended up working out OK; a bit of overload on config atm which mostly could be inferred
Copy code
python_extension(
    name="native",
    package=["//examples/python-package/native-component#library"],
    module_name="native_component.so",
    output_path="examples/python-package/src/python_package",
)
πŸŽ‰ 2