Example #1
0
def test_read_from_dylib():
    dirname = os.path.dirname(__file__)
    dylib_dir = os.path.join(dirname, "testdata",
                             "macosx_minimal_system_version")
    versions = [
        ("test_lib_10_6_fat.dylib", "10.6.0"),
        ("test_lib_10_10_fat.dylib", "10.10.0"),
        ("test_lib_10_14_fat.dylib", "10.14.0"),
        ("test_lib_10_6.dylib", "10.6.0"),
        ("test_lib_10_10.dylib", "10.10.0"),
        ("test_lib_10_14.dylib", "10.14.0"),
        ("test_lib_10_6_386.dylib", "10.6.0"),
        ("test_lib_10_10_386.dylib", "10.10.0"),
        ("test_lib_10_14_386.dylib", "10.14.0"),
        ("test_lib_multiple_fat.dylib", "10.14.0"),
        ("test_lib_10_10_10.dylib", "10.10.10"),
        ("test_lib_11.dylib", "11.0.0"),
        ("test_lib_10_9_universal2.dylib", "10.9.0"),
    ]
    for file_name, ver in versions:
        extracted = extract_macosx_min_system_version(
            os.path.join(dylib_dir, file_name))
        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, "libb.dylib")) is None)
Example #2
0
def mac_osx_setenv():
    """Set MacOS environment to build high-compat wheels"""
    try:
        # Also ensure wheel package is avail
        import wheel
    except ImportError:
        from setuptools.dist import Distribution

        Distribution().fetch_build_eggs(["wheel"])
    from wheel.macosx_libfile import extract_macosx_min_system_version

    sdk_root = (subprocess.check_output(
        ["xcrun", "--sdk", "macosx", "--show-sdk-path"]).decode().strip())
    log.info("Setting SDKROOT=%s", sdk_root)
    os.environ["SDKROOT"] = sdk_root

    # Match Python OSX framework
    py_osx_framework = extract_macosx_min_system_version(sys.executable)
    if py_osx_framework is None:
        py_osx_framework = [10, 9]
    if py_osx_framework[1] > 9:
        log.warn(
            "[ WARNING ] You are building a wheel with a Python built"
            " for a recent MACOS version (from brew?). Your wheel won't be portable."
            " Consider using an official Python build from python.org")
    macos_target = "%d.%d" % tuple(py_osx_framework[:2])
    log.info("Setting MACOSX_DEPLOYMENT_TARGET=%s", macos_target)
    os.environ["MACOSX_DEPLOYMENT_TARGET"] = macos_target
Example #3
0
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
Example #4
0
import os, sys
from wheel.macosx_libfile import extract_macosx_min_system_version

for (dirpath, dirnames, filenames) in os.walk(sys.argv[1]):
    for filename in filenames:
        if filename.endswith('.dylib') or filename.endswith('.so'):
            lib_path = os.path.join(dirpath, filename)
            min_ver = extract_macosx_min_system_version(lib_path)
            if min_ver is not None:
                print(min_ver, lib_path)