RFC: add an experimental bindeps backend
#22396
Replies: 2 comments 2 replies
-
|
Targets that a backend like
I suppose it could also do third party requirements ( |
Beta Was this translation helpful? Give feedback.
-
|
I think this sounds interesting! Some possible use cases:
I think I would use the first two, but skeptical I would actually do anything so magical as the last one
It might be a little terse for something on the esoteric side but |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Would anyone be interested in a
bindepsbackend that can analyze binaries to list which shared libs it is linked with?The
bindepsbackendThe
bindepsbackend would be functionally similar todpkg-shlibdepsin debian, andrpmdeps+elfdepsin EL distros. But, it would not require the native packaging tooling to run it. I imagine it would be most useful when using thenfpmbackend (which wrapsnFPM) to create native system packages (.deb,.rpm, ...) becausenfpmdoes not analyze included binaries like the native deb/rpm tooling does. But it could also be useful to audit/lint generated binaries before distributing them.What I have so far:
So far, I have code that can
pex_binary,elfdeps📦 (the python lib, not the native rpmbuild binary) to get the list of SONAMEs used by any binaries in the package.I also have code that can take the list of SONAMEs and map them to deb package names using the debian package search API (for debian or ubuntu) instead of querying via native packaging tool(s) like
dpkg -S. This is important because debdependsexpects package names, not SONAMEs. This package lookup is not needed for rpm whererequirestakes a list of SONAMEs in addition to package names.For the rules I've written so far, the only python-specific bits handle extracting wheels from a
pex_binaryand using zipfile to make the wheel contents available forelfdepsto inspect. The actualelfdependency inspection logic and the deb package search are not python-specific and could easily be used to inspect binaries from other pants package targetsNote
I looked at a variety of python libs before settling on
elfdeps. For example,lddcollect, usesdpkk -Sto map SONAME to deb package name. But that would require running the tool on every target distro version (in a docker container or similar) instead of just running on whatever host pants happens to be running on. I also looked at using parts ofauditwheel, but that is too python-specific and it abstracts away some of the underlying elf metadata (frompyelftools📦) I needed to generate package dependency metadata.auditwheelmight still be very useful (see below), but not for imitatingdpkg-shlibdepsorrpmdeps.Potential scope of the
bindepsbackend:I'm calling this a
bindepsbackend, because it does not need to be specific toelfbinaries/libs. In figuring out how best to analyze linux wheels, I also found these projects which would fit nicely under abindepsbackend (though I haven't written the code to make them part of a pants backend) - perhaps ascheckorfixtools that take packaged binaries as input:These 3 can analyze a wheel's included python extensions (binaries / shared libs) and "repair" the wheel by copying the shared lib(s) into a copy of the wheel so that no system deps are required.
delocate📦: this is MacOS-specific, so it works with dynamic libraries. It can also combine anarm64wheel with anx86_64wheel to make auniversal2wheel that supports both architectures.auditwheel📦: this is linux-specific, so it works with ELF binaries /.sofiles. It can also audits the wheels'manylinuxtag, if any, to ensure that the wheel follows the system dep requirements to use thatmanylinuxtag.delvewheel📦: this is Windows-specific, so it works with DLLs.repairwheel📦: This lib combines the 3 above libs, (so it is cross-platform) focusing on using pure python libs instead of system binaries to modify any libs in the wheel. It also promises to be more host-agnostic so that it can hermetically create the same changes on any host platform.abi3audit📦: Another wheel audit tool. This one audits a wheel'sabi3tag to see if python extensions in the wheel only use python symbols stabalized in the target python version or earlier.Request for feedback
bindepsname make sense for a backend of this scope? At first, I thought I would useelfdeps, but that doesn't leave room for cross-platform expansion in the future.pants.backend.experimental.bindeps?Beta Was this translation helpful? Give feedback.
All reactions