-
Notifications
You must be signed in to change notification settings - Fork 182
Better discovery of macos system version to determine proper platform tag #314
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
99a8bbf
read minimal macos version from from mach-O header
a3da68d
add check macos version to code
93f1809
Add tests for get_platform, warning on update of macosx minimal versi…
9144297
fix error for undefined fin_base_version varaible
d4ad3d9
add more verbose output to inform which files forced to bump version
306cde9
Fix errors pointed in review.
Czaki be741f7
change tests to use monkeypatching instead pytest-mock
1cde26c
fix typo in testdata sub folder. Refactor tests to be clear what they…
Czaki b1dd2c4
extract macos platform tag calculation to separated function
Czaki File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| import os | ||
| import sys | ||
| import distutils.util | ||
|
|
||
| from wheel.macosx_libfile import extract_macosx_min_system_version | ||
| from wheel.pep425tags import get_platform | ||
|
|
||
|
|
||
| def test_read_from_dynlib(): | ||
| dirname = os.path.dirname(__file__) | ||
| dylib_dir = os.path.join(dirname, "testdata", | ||
| "macosx_minimal_system_version") | ||
| versions = [ | ||
| ("test_lib_10_6_fat.dynlib", "10.6"), | ||
| ("test_lib_10_10_fat.dynlib", "10.10"), | ||
| ("test_lib_10_14_fat.dynlib", "10.14"), | ||
| ("test_lib_10_6.dynlib", "10.6"), | ||
| ("test_lib_10_10.dynlib", "10.10"), | ||
| ("test_lib_10_14.dynlib", "10.14"), | ||
| ("test_lib_10_6_386.dynlib", "10.6"), | ||
| ("test_lib_10_10_386.dynlib", "10.10"), | ||
| ("test_lib_10_14_386.dynlib", "10.14"), | ||
| ("test_lib_multiple_fat.dynlib", "10.14") | ||
| ] | ||
| for file_name, ver in versions: | ||
| extracted = extract_macosx_min_system_version( | ||
| os.path.join(dylib_dir, file_name) | ||
| ) | ||
| str_ver = str(extracted[0]) + "." + str(extracted[1]) | ||
| assert str_ver == ver | ||
| assert extract_macosx_min_system_version( | ||
| os.path.join(dylib_dir, "test_lib.c") | ||
| ) is None | ||
|
|
||
|
|
||
| def return_factory(return_val): | ||
| def fun(*args, **kwargs): | ||
| return return_val | ||
|
|
||
| return fun | ||
|
|
||
|
|
||
| class TestGetPlatformMacosx: | ||
| def test_simple(self, monkeypatch): | ||
| dirname = os.path.dirname(__file__) | ||
| dylib_dir = os.path.join(dirname, "testdata", "macosx_minimal_system_version") | ||
| monkeypatch.setattr(distutils.util, "get_platform", return_factory("macosx-10.14-x86_64")) | ||
| assert get_platform(dylib_dir) == "macosx_10_14_x86_64" | ||
|
|
||
| def test_version_bump(self, monkeypatch, capsys): | ||
| dirname = os.path.dirname(__file__) | ||
| dylib_dir = os.path.join(dirname, "testdata", "macosx_minimal_system_version") | ||
| monkeypatch.setattr(distutils.util, "get_platform", return_factory("macosx-10.9-x86_64")) | ||
| assert get_platform(dylib_dir) == "macosx_10_14_x86_64" | ||
| captured = capsys.readouterr() | ||
| assert "[WARNING] This wheel needs higher macosx version than" in captured.err | ||
|
|
||
| def test_information_about_problematic_files_python_version(self, monkeypatch, capsys): | ||
| dirname = os.path.dirname(__file__) | ||
| dylib_dir = os.path.join(dirname, "testdata", "macosx_minimal_system_version") | ||
| monkeypatch.setattr(distutils.util, "get_platform", return_factory("macosx-10.9-x86_64")) | ||
| monkeypatch.setattr(os, "walk", return_factory( | ||
| [(dylib_dir, [], ["test_lib_10_6.dynlib", "test_lib_10_10_fat.dynlib"])] | ||
| )) | ||
| assert get_platform(dylib_dir) == "macosx_10_10_x86_64" | ||
| captured = capsys.readouterr() | ||
| assert "[WARNING] This wheel needs higher macosx version than" in captured.err | ||
| assert "your python is compiled against." in captured.err | ||
| assert "test_lib_10_10_fat.dynlib" in captured.err | ||
|
|
||
| def test_information_about_problematic_files_env_variable(self, monkeypatch, capsys): | ||
| dirname = os.path.dirname(__file__) | ||
| dylib_dir = os.path.join(dirname, "testdata", "macosx_minimal_system_version") | ||
| monkeypatch.setattr(distutils.util, "get_platform", return_factory("macosx-10.9-x86_64")) | ||
| monkeypatch.setenv("MACOSX_DEPLOYMENT_TARGET", "10.8") | ||
| monkeypatch.setattr(os, "walk", return_factory( | ||
| [(dylib_dir, [], ["test_lib_10_6.dynlib", "test_lib_10_10_fat.dynlib"])] | ||
| )) | ||
| assert get_platform(dylib_dir) == "macosx_10_10_x86_64" | ||
| captured = capsys.readouterr() | ||
| assert "[WARNING] This wheel needs higher macosx version than" in captured.err | ||
| assert "is set in MACOSX_DEPLOYMENT_TARGET variable." in captured.err | ||
| assert "test_lib_10_10_fat.dynlib" in captured.err | ||
|
|
||
| def test_bump_platform_tag_by_env_variable(self, monkeypatch, capsys): | ||
| dirname = os.path.dirname(__file__) | ||
| dylib_dir = os.path.join(dirname, "testdata", "macosx_minimal_system_version") | ||
| monkeypatch.setattr(distutils.util, "get_platform", return_factory("macosx-10.9-x86_64")) | ||
| monkeypatch.setattr(os, "walk", return_factory( | ||
| [(dylib_dir, [], ["test_lib_10_6.dynlib", "test_lib_10_6_fat.dynlib"])] | ||
| )) | ||
| assert get_platform(dylib_dir) == "macosx_10_9_x86_64" | ||
| monkeypatch.setenv("MACOSX_DEPLOYMENT_TARGET", "10.10") | ||
| assert get_platform(dylib_dir) == "macosx_10_10_x86_64" | ||
| captured = capsys.readouterr() | ||
| assert captured.err == "" | ||
|
|
||
| def test_warning_on_to_low_env_variable(self, monkeypatch, capsys): | ||
| dirname = os.path.dirname(__file__) | ||
| dylib_dir = os.path.join(dirname, "testdata", "macosx_minimal_system_version") | ||
| monkeypatch.setattr(distutils.util, "get_platform", return_factory("macosx-10.9-x86_64")) | ||
| monkeypatch.setenv("MACOSX_DEPLOYMENT_TARGET", "10.8") | ||
| monkeypatch.setattr(os, "walk", return_factory( | ||
| [(dylib_dir, [], ["test_lib_10_6.dynlib", "test_lib_10_6_fat.dynlib"])] | ||
| )) | ||
| assert get_platform(dylib_dir) == "macosx_10_9_x86_64" | ||
| captured = capsys.readouterr() | ||
| assert "MACOSX_DEPLOYMENT_TARGET is set to lower value than your python" in captured.err | ||
|
|
||
|
|
||
| def test_get_platform_linux(monkeypatch): | ||
| monkeypatch.setattr(distutils.util, "get_platform", return_factory("linux_x86_64")) | ||
| monkeypatch.setattr(sys, "maxsize", 2147483647) | ||
| assert get_platform(None) == "linux_i686" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| int num_of_letters(char* text){ | ||
| int num = 0; | ||
| char * lett = text; | ||
| while (lett != 0){ | ||
| if (*lett >= 'a' && *lett <= 'z'){ | ||
| num += 1; | ||
| } else if (*lett >= 'A' && *lett <= 'Z'){ | ||
| num += 1; | ||
| } | ||
| lett += 1; | ||
| } | ||
| return num; | ||
| } |
Binary file not shown.
Binary file added
BIN
+668 Bytes
tests/testdata/macosx_minimal_system_version/test_lib_10_10_386.dynlib
Binary file not shown.
Binary file added
BIN
+8.74 KB
tests/testdata/macosx_minimal_system_version/test_lib_10_10_fat.dynlib
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+676 Bytes
tests/testdata/macosx_minimal_system_version/test_lib_10_14_386.dynlib
Binary file not shown.
Binary file added
BIN
+8.75 KB
tests/testdata/macosx_minimal_system_version/test_lib_10_14_fat.dynlib
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+668 Bytes
tests/testdata/macosx_minimal_system_version/test_lib_10_6_386.dynlib
Binary file not shown.
Binary file added
BIN
+8.74 KB
tests/testdata/macosx_minimal_system_version/test_lib_10_6_fat.dynlib
Binary file not shown.
Binary file added
BIN
+8.75 KB
tests/testdata/macosx_minimal_system_version/test_lib_multiple_fat.dynlib
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.