-
Notifications
You must be signed in to change notification settings - Fork 59
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
Ignore unparseable static libraries #235
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #235 +/- ##
==========================================
- Coverage 97.06% 96.84% -0.22%
==========================================
Files 16 16
Lines 1361 1365 +4
==========================================
+ Hits 1321 1322 +1
- Misses 40 43 +3 ☔ View full report in Codecov by Sentry. |
Something to add to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one looks fine to me. For my own benefit, the changes here are:
- Checking for, ignoring a known error from
macholib
when parsing static libraries. - Using the
-m
flag tootool
, therefore allowing parentheses in input file names. - Elevating some deprecation warnings to errors.
The only question I had was - is ignoring the static libraries the right thing? I guess it is, in that they cannot by definition be necessary for execution.
I don't think I've promoted any deprecation warnings to errors. Any deleted warning code was moved to a
This still checks static libraries. It's just that |
There isn't a perfect solution to static libraries. Whether the static library is possibly loaded as part of the package logic or is solely used to create but not run other tools depends on the specific package. It should be a simple change if we want to skip over static libraries during this minimum version analyses. It can even be toggled with a flag to delocate. Maybe count static libs by default but allow using a flag to ignore them. |
Ah - yes - sorry - thanks for the clarification. |
That sounds good - do you think the function should error when it can't detect minimum version from static libs - as it does now - unless the ignore flag is set? |
I don't have a preference on that, but the error is that There's not much that can be done other than to fix the issue upstream: ronaldoussoren/macholib#49 |
Decorator warnings are more modern and work better for linters and IDE's
Documentation shows that this is needed to disable special handling of file names which would prevent the loading of paths with parentheses. Added tests for this. Verified the test will fail without the new flag.
machomacomangler and bindepend are not currently being used
528480a
to
529158a
Compare
Macholib raises ValueError when failing to parse files which can be used to detect if the file is a Mach-O object. It is also raised on Mach-O objects it doesn't know how to handle. Checking for this error means `_is_macho_file` is redundant. Add min version tests for various file types. These tests clarify that static libraries don't have min version info.
529158a
to
6b809ff
Compare
I added tests to verify ignoring static library info but it turns out these new tests demonstrate that static libraries do not have the Keeping this in mind, there's no difference between a static library and any non-library file as far as I've added |
Ok - thanks for persisting. Is this one ready to go in now? You have an outstanding "Ensure new features are covered by tests" checkbox - did you mean (above) that you don't think you can practically do that? |
I was considering the |
Turns out I did have tests for |
Also verified that removing `-m` causes these tests to fail
9969877
to
d247830
Compare
I also attempted to cover the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks.
Pull Request Checklist
This branch was an attempt to remove
macholib
and write a betterotool
parser but I underestimated how difficult the output ofotool
was. I wasn't able to resolve cases where it'd decide to not return the architecture info in its output because it decided it was the current systems architecture. In the end I decided it was more reliable to suppress the error from macholib instead of trying to remove the library.This suppresses
ValueError: Unknown Mach-O header
which fixes #229, fixes #227. I don't have a fat static binary to test this such as an archive (.a
) compiled for botharm64
andx86_64
.While working on this I noticed the
-m
flag onotool
and enabled it because delocate is always working with the whole file at once. This flag is documented as:I also looked at the previous install dependencies,
machomacomangler
andbindepend
, and removed them because there was no code using them. These looked like previous attempts at cross-platform handling of MacOS binary files.