Skip to content
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

Add --exclude option to delocate-wheel #106

Merged
merged 3 commits into from
Nov 22, 2023

Conversation

rossant
Copy link
Contributor

@rossant rossant commented May 26, 2021

Same motivation as pypa/auditwheel#310

I need this to remove libvulkan from the repaired wheel.

Copy link
Owner

@matthew-brett matthew-brett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay. Some thoughts. Can you think of a test?

def copy_filt(name):
if not exclude:
return filter_system_libs(name)
return filter_system_libs(name) and not _is_in_list(name, exclude)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you are doing a substring search here? Is that what you intended? Or did you mean

and not name in exclude

?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The substring search by rossant is intentional. The main alternative is to allow RegEx, which is usually overkill.

@@ -37,6 +45,8 @@ def main():
action="store_true",
help="Only analyze files with known dynamic library "
"extensions"),
Option("-e", "--exclude",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or allow multiple --exclude options with action="append"?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've rewritten the code to use action="append" but I haven't tested it.

@codecov-commenter
Copy link

codecov-commenter commented Sep 10, 2022

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (27f7b64) 94.93% compared to head (0442d5c) 95.11%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #106      +/-   ##
==========================================
+ Coverage   94.93%   95.11%   +0.18%     
==========================================
  Files          14       15       +1     
  Lines        1125     1167      +42     
==========================================
+ Hits         1068     1110      +42     
  Misses         57       57              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Owner

@matthew-brett matthew-brett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All looks good - but it still needs some tests - maybe in delocate/tests/test_scripts.py ?

@HexDecimal
Copy link
Collaborator

Maybe. I wish the script running tests were using a standard tool rather than ScriptRunner. I'll probably come back to this later.

@matthew-brett
Copy link
Owner

Yes, I wrote my own script testing framework around 2016, before there were others available - or at least - before I knew there were others available.

@pengzhendong
Copy link

Any progress?

@HexDecimal HexDecimal removed their assignment Nov 25, 2022
@HexDecimal
Copy link
Collaborator

Won't merge until tests are made which is a reasonable request. The new tests can use ScriptRunner like the current tests, or pytest-console-scripts which is more standard.

@PhilipGarnero
Copy link
Contributor

Can we merge this please ?
I know it's untested but it's still better than nothing. It's just one click away from being useful to people 🙇‍♂️

@PhilipGarnero
Copy link
Contributor

I took a few minutes to write something that should do ok as a test :

@pytest.mark.xfail(sys.platform != "darwin", reason="Needs macOS linkage.")
def test_fix_wheel_with_excluded_dylibs():
    with InTemporaryDirectory() as tmpdir:
        fixed_wheel, stray_lib = _fixed_wheel(tmpdir)
        _rename_module(fixed_wheel, "module.other", "test.whl")
        shutil.copyfile("test.whl", "test2.whl")
        # We exclude the stray library so it shouldn't be present in the wheel
        code, stdout, stderr = run_command(["delocate-wheel", "-e", "extfunc", "test.whl"])
        with InWheel("test.whl"): 
            dylibs = pjoin("plat_pkg", "fakepkg1", ".dylibs")
            assert_equal(os.listdir(dylibs), [])
        # We exclude a library that does not exist so we should have a normal behavior
        code, stdout, stderr = run_command(["delocate-wheel", "-e", "doesnotexist", "test2.whl"])
        _check_wheel("test2.whl", ".dylibs")

@HexDecimal HexDecimal self-assigned this Nov 21, 2023
HexDecimal and others added 2 commits November 20, 2023 19:43
Co-authored-by: rossant <rossant@users.noreply.github.com>
Co-authored-by: Philip Garnero <philip.garnero@gmail.com>
@HexDecimal
Copy link
Collaborator

I've added the test and cleaned up the commits. It could be better but now I think it's good enough to merge.

Adds new exlucde argument to delocate-path

Makes verbosity work the same among all commands
@HexDecimal
Copy link
Collaborator

Moved some CLI logic to a shared module so that any new code can apply to both delocate-wheel and delocate-path without having to copy that code across both modules.

@HexDecimal HexDecimal merged commit 082ab1e into matthew-brett:master Nov 22, 2023
19 checks passed
@webknjaz
Copy link
Contributor

Moved some CLI logic to a shared module so that any new code can apply to both delocate-wheel and delocate-path without having to copy that code across both modules.

Hey @HexDecimal, I think the changes in this PR may have resulted in breaking the delocate CLI extending a glob-style paths arg: #71 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants