Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 28 additions & 6 deletions tests/test_macosx_libfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from wheel.pep425tags import get_platform


def test_read_from_dynlib():
def test_read_from_dylib():
dirname = os.path.dirname(__file__)
dylib_dir = os.path.join(dirname, "testdata",
"macosx_minimal_system_version")
Expand All @@ -20,17 +20,23 @@ def test_read_from_dynlib():
("test_lib_10_6_386.dylib", "10.6"),
("test_lib_10_10_386.dylib", "10.10"),
("test_lib_10_14_386.dylib", "10.14"),
("test_lib_multiple_fat.dylib", "10.14")
("test_lib_multiple_fat.dylib", "10.14"),
Comment thread
Czaki marked this conversation as resolved.
Outdated
("test_lib_10_10_10.dylib", "10.10.10")
]
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])
if extracted[-1] == 0:
extracted = extracted[:-1]
Comment thread
Czaki marked this conversation as resolved.
Outdated
str_ver = ".".join([str(x) for x in extracted])
assert str_ver == ver
assert extract_macosx_min_system_version(
os.path.join(dylib_dir, "test_lib.c")
) is None
assert extract_macosx_min_system_version(
os.path.join(dylib_dir, "test_lib.c")
) is None
assert extract_macosx_min_system_version(
os.path.join(dylib_dir, "libb.dylib")
) is None


def return_factory(return_val):
Expand Down Expand Up @@ -95,6 +101,22 @@ def test_bump_platform_tag_by_env_variable(self, monkeypatch, capsys):
captured = capsys.readouterr()
assert captured.err == ""

def test_bugfix_release_platform_tag(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.dylib", "test_lib_10_6_fat.dylib",
"test_lib_10_10_10.dylib"])]
))
assert get_platform(dylib_dir) == "macosx_10_10_x86_64"
captured = capsys.readouterr()
assert "This wheel needs higher macosx version" in captured.err
monkeypatch.setenv("MACOSX_DEPLOYMENT_TARGET", "10.9")
assert get_platform(dylib_dir) == "macosx_10_10_x86_64"
captured = capsys.readouterr()
assert "This wheel needs higher macosx version" in 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")
Expand Down
Binary file not shown.
Binary file not shown.
12 changes: 5 additions & 7 deletions wheel/pep425tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,15 @@ def calculate_macosx_platform_tag(archive_root, platform_tag):
for filename in filenames:
if filename.endswith('.dylib') or filename.endswith('.so'):
lib_path = os.path.join(dirpath, filename)
versions_dict[lib_path] = extract_macosx_min_system_version(lib_path)
min_ver = extract_macosx_min_system_version(lib_path)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think the last field of the version tuple is irrelevant to the compatibility question? If so, should it be moved up here i.e. min_ver = min_ver[0:2]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It need changes in more places. I push this changes in separate commit.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍

if min_ver is not None:
versions_dict[lib_path] = min_ver

if len(versions_dict) > 0:
base_version = max(base_version, max(versions_dict.values()))

if base_version[-1] == 0:
fin_base_version = base_version[:-1]
else:
fin_base_version = base_version

fin_base_version = "_".join([str(x) for x in fin_base_version])
# macosx platform tag do not support minor bugfix release
fin_base_version = "_".join([str(x) for x in base_version[:-1]])
if start_version < base_version:
problematic_files = [k for k, v in versions_dict.items() if v > start_version]
problematic_files = "\n".join(problematic_files)
Expand Down