Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
16 changes: 15 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,17 @@
import sys
import pybind11
import subprocess
import sysconfig

from setuptools import Extension, setup
from setuptools.command.build_ext import build_ext

def get_ext_suffix():
# Prefer conda-forge provided suffix (cross-compile safe)
if "PYTHON_EXT_SUFFIX" in os.environ:
return os.environ["PYTHON_EXT_SUFFIX"]
return sysconfig.get_config_var("EXT_SUFFIX")

# A CMakeExtension needs a sourcedir instead of a file list.
# The name must be the _single_ output extension from the CMake build.
# If you need multiple extensions, see scikit-build.
Expand All @@ -28,6 +35,8 @@ def build_extension(self, ext):
cfg = "Debug" if self.debug else "Release"
# cfg = "Debug"

ext_suffix = get_ext_suffix()

# Set Python_EXECUTABLE instead if you use PYBIND11_FINDPYTHON
# EXAMPLE_VERSION_INFO shows you how to pass a value into the C++ code
# from Python.
Expand All @@ -36,7 +45,8 @@ def build_extension(self, ext):
"-DPYTHON_EXECUTABLE={}".format(sys.executable),
"-DCMAKE_BUILD_TYPE={}".format(cfg), # not used on MSVC, but no harm
"-DCMAKE_POSITION_INDEPENDENT_CODE=ON",
"-DCMAKE_CXX_STANDARD=14"
"-DCMAKE_CXX_STANDARD=14",
"-DPYTHON_EXT_SUFFIX={}".format(ext_suffix)
]
build_args = []

Expand All @@ -47,6 +57,10 @@ def build_extension(self, ext):
# Add Pybind11 info
cmake_args += [f"-DPYBIND11_DIR={pybind11.get_cmake_dir()}"]

# Handle cross-compilation on conda
if "CMAKE_ARGS" in os.environ:
cmake_args += os.environ["CMAKE_ARGS"].split()

# Set CMAKE_BUILD_PARALLEL_LEVEL to control the parallel build level
# across all generators.
if "CMAKE_BUILD_PARALLEL_LEVEL" not in os.environ:
Expand Down
3 changes: 3 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ if (PYTHON)
${LAPACK_LIBRARIES}
OpenMP::OpenMP_Fortran
)
if(PYTHON_EXT_SUFFIX)
set_target_properties(pyddx PROPERTIES SUFFIX "${PYTHON_EXT_SUFFIX}")
endif()
endif()

#
Expand Down
Loading