Skip to content

Commit

Permalink
Make macOS deployment target check robust against float precision err…
Browse files Browse the repository at this point in the history
…ors. (#52)
  • Loading branch information
LinZhihao-723 authored Mar 17, 2024
1 parent af051e6 commit bbc6a43
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
1 change: 0 additions & 1 deletion .github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ jobs:
uses: pypa/[email protected]
env:
CIBW_ARCHS_LINUX: auto aarch64
MACOSX_DEPLOYMENT_TARGET: 10.15

- uses: actions/upload-artifact@v3
with:
Expand Down
17 changes: 12 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import platform
import sys
from setuptools import setup, Extension
from typing import List, Optional
from typing import List, Optional, Tuple

ir_native: Extension = Extension(
name="clp_ffi_py.ir.native",
Expand Down Expand Up @@ -44,15 +44,22 @@
if "__main__" == __name__:
try:
if "Darwin" == platform.system():
target: Optional[str] = os.environ.get("MACOSX_DEPLOYMENT_TARGET")
if None is target or float(target) < 10.15:
os.environ["MACOSX_DEPLOYMENT_TARGET"] = "10.15"
target_env_var_name: str = "MACOSX_DEPLOYMENT_TARGET"
min_target_version: Tuple[int, int] = (10, 15)

target_str: Optional[str] = os.environ.get(target_env_var_name)
target: Tuple[int, ...] = ()
if target_str is not None:
target = tuple(int(part) for part in target_str.split("."))
if target < min_target_version:
target = min_target_version
os.environ[target_env_var_name] = ".".join(str(part) for part in target)

project_name: str = "clp_ffi_py"
description: str = "CLP FFI Python Interface"
extension_modules: List[Extension] = [ir_native]
if (3, 7) > sys.version_info:
sys.exit(f"The minimum Python version required is Python3.7")
sys.exit("The minimum Python version required is Python3.7")
else:
setup(
name=project_name,
Expand Down

0 comments on commit bbc6a43

Please sign in to comment.