Skip to content

Commit f5059ac

Browse files
committed
More tweaks
1 parent 16b9f51 commit f5059ac

File tree

3 files changed

+21
-12
lines changed

3 files changed

+21
-12
lines changed

cmake/yup_dependencies.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ endfunction()
114114

115115
#==============================================================================
116116

117-
function (_yup_fetch_python root_dir use_static_libs)
118-
if (TARGET Python::Python)
117+
function (_yup_fetch_python root_dir use_static_libs modules)
118+
if (TARGET Python::Python OR TARGET Python::Module)
119119
return()
120120
endif()
121121

@@ -124,7 +124,7 @@ function (_yup_fetch_python root_dir use_static_libs)
124124
endif()
125125

126126
set (Python_USE_STATIC_LIBS "${use_static_libs}")
127-
find_package (Python REQUIRED Development Interpreter)
127+
find_package (Python COMPONENTS ${modules} REQUIRED)
128128

129129
endfunction()
130130

cmake/yup_modules.cmake

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,13 +523,24 @@ function (yup_add_module module_path modules_definitions module_group)
523523

524524
# ==== Fetch Python if needed
525525
if (module_needs_python)
526-
_yup_fetch_python ("${Python_ROOT_DIR}" "${YUP_ENABLE_STATIC_PYTHON_LIBS}")
526+
set (python_modules "")
527527
if (NOT YUP_BUILD_WHEEL)
528+
set (python_modules "Interpreter;Development.Embed")
528529
list (APPEND module_libs Python::Python)
529530
if (YUP_PLATFORM_MAC)
530531
list (APPEND module_link_options "-Wl,-weak_reference_mismatches,weak")
531532
endif()
533+
else()
534+
if (DEFINED ENV{CIBW_ENVIRONMENT_LINUX})
535+
set (python_modules "Interpreter;Development.Module")
536+
else()
537+
set (python_modules "Interpreter;Development")
538+
endif()
539+
list (APPEND module_libs Python::Module)
532540
endif()
541+
542+
_yup_fetch_python ("${Python_ROOT_DIR}" "${YUP_ENABLE_STATIC_PYTHON_LIBS}" "${python_modules}")
543+
533544
if (NOT "${Python_INCLUDE_DIRS}" STREQUAL "")
534545
list (APPEND module_include_paths "${Python_INCLUDE_DIRS}")
535546
endif()

python/setup.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,12 @@ def build_extension(self, ext):
120120
f"-DPython_INCLUDE_DIRS={get_python_includes_path()}",
121121
f"-DPython_LIBRARY_DIRS={get_python_lib_path()}"
122122
]
123-
else:
124-
cmake_args += [f"-DPYTHON_EXECUTABLE={sys.executable}"]
123+
124+
if platform.system() == 'Darwin':
125+
cmake_args += [
126+
f"-DCMAKE_OSX_ARCHITECTURES:STRING={self.build_osx_architectures}",
127+
f"-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING={self.build_osx_deployment_target}"
128+
]
125129

126130
if self.build_for_coverage:
127131
cmake_args += ["-DYUP_ENABLE_COVERAGE:BOOL=ON"]
@@ -132,12 +136,6 @@ def build_extension(self, ext):
132136
if self.build_with_lto:
133137
cmake_args += ["-DYUP_ENABLE_LTO:BOOL=ON"]
134138

135-
if platform.system() == 'Darwin':
136-
cmake_args += [
137-
f"-DCMAKE_OSX_ARCHITECTURES:STRING={self.build_osx_architectures}",
138-
f"-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING={self.build_osx_deployment_target}"
139-
]
140-
141139
try:
142140
os.chdir(str(build_temp))
143141
make_command = ["cmake", str(os.path.join(cwd, ".."))] + cmake_args

0 commit comments

Comments
 (0)