@@ -60,17 +60,17 @@ class CMakeBuild(build_ext):
6060 def build_extension (self , ext ):
6161 extdir = os .path .abspath (os .path .dirname (self .get_ext_fullpath (ext .name )))
6262
63- # required for auto-detection of auxiliary "native" libs
63+ # required for auto-detection & inclusion of auxiliary "native" libs
6464 if not extdir .endswith (os .path .sep ):
6565 extdir += os .path .sep
6666
67- cfg = "Debug" if self .debug else "Release"
67+ debug = int (os .environ .get ("DEBUG" , 0 )) if self .debug is None else self .debug
68+ cfg = "Debug" if debug else "Release"
6869
6970 # CMake lets you override the generator - we need to check this.
7071 # Can be set with Conda-Build, for example.
7172 cmake_generator = os .environ .get ("CMAKE_GENERATOR" , "" )
7273
73- # Set Python_EXECUTABLE instead if you use PYBIND11_FINDPYTHON
7474 cmake_args = [
7575 "-DCMAKE_LIBRARY_OUTPUT_DIRECTORY={}" .format (extdir ),
7676 "-DPython_EXECUTABLE={}" .format (sys .executable ),
@@ -81,11 +81,14 @@ def build_extension(self, ext):
8181 "-DOCIO_BUILD_APPS=OFF" ,
8282 "-DOCIO_BUILD_TESTS=OFF" ,
8383 "-DOCIO_BUILD_GPU_TESTS=OFF" ,
84- # Install pybind11 via pip to avoid issue on Windows where
85- # ExternalProject pybind11 build detect the wrong version
86- "-DOCIO_INSTALL_EXT_PACKAGES=MISSING" ,
84+ # Make sure we build everything for the requested architecture(s)
85+ "-DOCIO_INSTALL_EXT_PACKAGES=ALL" ,
8786 ]
8887 build_args = []
88+ # Adding CMake arguments set as environment variable
89+ # (needed e.g. to build for ARM OSx on conda-forge)
90+ if "CMAKE_ARGS" in os .environ :
91+ cmake_args += [item for item in os .environ ["CMAKE_ARGS" ].split (" " ) if item ]
8992
9093 if self .compiler .compiler_type != "msvc" :
9194 # Using Ninja-build since it a) is available as a wheel and b)
@@ -94,7 +97,12 @@ def build_extension(self, ext):
9497 # Users can override the generator with CMAKE_GENERATOR in CMake
9598 # 3.15+.
9699 if not cmake_generator :
97- cmake_args += ["-GNinja" ]
100+ try :
101+ import ninja # noqa: F401
102+
103+ cmake_args += ["-GNinja" ]
104+ except ImportError :
105+ pass
98106
99107 else :
100108
@@ -117,6 +125,12 @@ def build_extension(self, ext):
117125 ]
118126 build_args += ["--config" , cfg ]
119127
128+ if sys .platform .startswith ("darwin" ):
129+ # Cross-compile support for macOS - respect ARCHFLAGS if set
130+ archs = re .findall (r"-arch (\S+)" , os .environ .get ("ARCHFLAGS" , "" ))
131+ if archs :
132+ cmake_args += ["-DCMAKE_OSX_ARCHITECTURES={}" .format (";" .join (archs ))]
133+
120134 # Set CMAKE_BUILD_PARALLEL_LEVEL to control the parallel build level
121135 # across all generators.
122136 if "CMAKE_BUILD_PARALLEL_LEVEL" not in os .environ :
0 commit comments