Skip to content
Permalink
Browse files
Changes to support wheels on Windows
  • Loading branch information
jmalkin committed Sep 3, 2021
1 parent 18fbdcf commit 40342e5a025cf0d18578ed600a380ed7c8bbf780
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 14 deletions.
@@ -35,6 +35,8 @@ set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
#set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_MACOSX_RPATH ON)

set(CMAKE_CXX_STANDARD 11)

# enable compiler warnings globally
# derived from https://foonathan.net/blog/2018/10/17/cmake-warnings.html
# and https://arne-mertz.de/2018/07/cmake-properties-options/
@@ -1,9 +1,10 @@
[build-system]
requires = ["wheel",
"setuptools >= 30.3.0",
"setuptools_scm",
"cmake >= 3.12",
"pybind11[global] >= 2.6.0"]
"pip >= 10.0",
"pybind11 >= 2.6.0"]
build-backend = "setuptools.build_meta"

[tool.tox]
legacy_tox_ini = """
@@ -13,7 +14,7 @@ envlist = py3
[testenv]
deps = pytest
numpy
pybind11[global] >= 2.6.0
pybind11 >= 2.6.0
changedir = python/tests
commands = pytest
"""
@@ -15,18 +15,19 @@
# specific language governing permissions and limitations
# under the License.

# TODO: Can we force python version >= 3.0?
find_package(Python3 COMPONENTS Interpreter Development)

# only Windows+MSVC seems to have trouble locating pybind11
if (MSVC)
set(PYBIND11_CPP_STANDARD /std:c++11)
else()
set(PYBIND11_CPP_STANDARD -std=c++11)
execute_process(COMMAND cmd.exe /c ${CMAKE_CURRENT_SOURCE_DIR}/pybind11Path.cmd "${Python3_EXECUTABLE}"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE EXTRA_PACKAGE_PATH)
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${EXTRA_PACKAGE_PATH})
endif()

find_package(Python3 COMPONENTS Interpreter Development)
find_package(pybind11 CONFIG)
#add_subdirectory(pybind11)
find_package(pybind11 CONFIG REQUIRED)

#pybind11_add_module(python MODULE EXCLUDE_FROM_ALL SYSTEM THIN_LTO)
pybind11_add_module(python MODULE EXCLUDE_FROM_ALL THIN_LTO)

target_link_libraries(python
@@ -0,0 +1,3 @@
@echo off
:: Takes path to the Python interpreter and returns the path to pybind11
%1 -m pip show pybind11 | %1 -c "import sys,re;[sys.stdout.write(re.sub('^Location:\\s+','',line)) for line in sys.stdin if re.search('^Location:\\s+',line)]"
@@ -60,7 +60,8 @@ def build_extension(self, ext):
cfg.upper(),
extdir)]
if sys.maxsize > 2**32:
cmake_args += ['-A', 'x64']
cmake_args += ['-T', 'host=x64']
cmake_args += ['DCMAKE_GENERATOR_PLATFORM=x64']
build_args += ['--', '/m']
else:
cmake_args += ['-DCMAKE_BUILD_TYPE=' + cfg]
@@ -75,7 +76,7 @@ def build_extension(self, ext):
subprocess.check_call(['cmake', ext.sourcedir] + cmake_args,
cwd=self.build_temp, env=env)
subprocess.check_call(['cmake', '--build', '.', '--target', 'python'] + build_args,
cwd=self.build_temp)
cwd=self.build_temp, env=env)
print() # add an empty line to pretty print

setup(
@@ -92,6 +93,6 @@ def build_extension(self, ext):
# may need to add all source paths for sdist packages w/o MANIFEST.in
ext_modules=[CMakeExtension('datasketches')],
cmdclass={'build_ext': CMakeBuild},
setup_requires=['setuptools_scm','tox-setuptools'],
install_requires=['numpy', 'pybind11 >= 2.6.0'],
zip_safe=False
)

0 comments on commit 40342e5

Please sign in to comment.