Skip to content

Commit f345b4c

Browse files
committed
vendor all C++ dependencies at build time, fixes #2075, closes #2076,
update python lints for newest black version
1 parent 225da00 commit f345b4c

File tree

7 files changed

+77
-128
lines changed

7 files changed

+77
-128
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
cmake_minimum_required(VERSION 3.7.2)
2+
3+
# ##################################################
4+
# Helper to grab dependencies from remote sources #
5+
# ##################################################
6+
function(psp_build_dep name cmake_file)
7+
if(EXISTS ${CMAKE_BINARY_DIR}/${name}-build)
8+
psp_build_message("${Cyan}Dependency found - not rebuilding - ${CMAKE_BINARY_DIR}/${name}-build${ColorReset}")
9+
else()
10+
configure_file(${cmake_file} ${name}-download/CMakeLists.txt)
11+
12+
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
13+
RESULT_VARIABLE result
14+
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/${name}-download)
15+
16+
if(result)
17+
message(FATAL_ERROR "CMake step for ${name} failed: ${result}")
18+
endif()
19+
20+
execute_process(COMMAND ${CMAKE_COMMAND} --build .
21+
RESULT_VARIABLE result
22+
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/${name}-download)
23+
24+
if(result)
25+
message(FATAL_ERROR "Build step for ${name} failed: ${result}")
26+
endif()
27+
endif()
28+
29+
if(${name} STREQUAL arrow)
30+
# Overwrite arrow's CMakeLists with our custom, minimal CMakeLists.
31+
configure_file(${PSP_CMAKE_MODULE_PATH}/${name}/CMakeLists.txt ${CMAKE_BINARY_DIR}/${name}-src/cpp/ COPYONLY)
32+
configure_file(${PSP_CMAKE_MODULE_PATH}/${name}/config.h ${CMAKE_BINARY_DIR}/${name}-src/cpp/src/arrow/util/ COPYONLY)
33+
add_subdirectory(${CMAKE_BINARY_DIR}/${name}-src/cpp/
34+
${CMAKE_BINARY_DIR}/${name}-build
35+
EXCLUDE_FROM_ALL)
36+
37+
include_directories(${CMAKE_BINARY_DIR}/${name}-src/cpp/src/)
38+
elseif(${name} STREQUAL exprtk)
39+
# no cmakelists - just include the header
40+
include_directories(${CMAKE_BINARY_DIR}/${name}-src)
41+
elseif(${name} STREQUAL re2)
42+
# Overwrite re2's CMakeLists with our custom CMakeLists.
43+
configure_file(${PSP_CMAKE_MODULE_PATH}/${name}/CMakeLists.txt ${CMAKE_BINARY_DIR}/${name}-src/ COPYONLY)
44+
include_directories(${CMAKE_BINARY_DIR}/${name}-src)
45+
46+
add_subdirectory(${CMAKE_BINARY_DIR}/${name}-src
47+
${CMAKE_BINARY_DIR}/${name}-build
48+
EXCLUDE_FROM_ALL)
49+
else()
50+
add_subdirectory(${CMAKE_BINARY_DIR}/${name}-src
51+
${CMAKE_BINARY_DIR}/${name}-build
52+
EXCLUDE_FROM_ALL)
53+
54+
include_directories(${CMAKE_BINARY_DIR}/${name}-src/extras/${name}/include)
55+
include_directories(${CMAKE_BINARY_DIR}/${name}-src/include)
56+
include_directories(${CMAKE_BINARY_DIR}/${name}-src)
57+
endif()
58+
59+
if(NOT PSP_WASM_BUILD AND (MACOS OR NOT MANYLINUX))
60+
if(${name} STREQUAL arrow OR ${name} STREQUAL flatbuffers OR ${name} STREQUAL double-conversion OR ${name} STREQUAL re2)
61+
target_compile_options(${name} PRIVATE -fvisibility=hidden)
62+
endif()
63+
endif()
64+
endfunction()
65+
66+
# #############################

cpp/perspective/CMakeLists.txt

Lines changed: 7 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -59,69 +59,11 @@ function(psp_build_message message)
5959
set(BUILD_MESSAGE "${BUILD_MESSAGE}\n${message}")
6060
endfunction()
6161

62-
# ##################################################
63-
# Helper to grab dependencies from remote sources #
64-
# ##################################################
65-
function(psp_build_dep name cmake_file)
66-
if(EXISTS ${CMAKE_BINARY_DIR}/${name}-build)
67-
psp_build_message("${Cyan}Dependency found - not rebuilding - ${CMAKE_BINARY_DIR}/${name}-build${ColorReset}")
68-
else()
69-
configure_file(${cmake_file} ${name}-download/CMakeLists.txt)
70-
71-
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
72-
RESULT_VARIABLE result
73-
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/${name}-download)
74-
75-
if(result)
76-
message(FATAL_ERROR "CMake step for ${name} failed: ${result}")
77-
endif()
78-
79-
execute_process(COMMAND ${CMAKE_COMMAND} --build .
80-
RESULT_VARIABLE result
81-
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/${name}-download)
82-
83-
if(result)
84-
message(FATAL_ERROR "Build step for ${name} failed: ${result}")
85-
endif()
86-
endif()
87-
88-
if(${name} STREQUAL arrow)
89-
# Overwrite arrow's CMakeLists with our custom, minimal CMakeLists.
90-
configure_file(${PSP_CMAKE_MODULE_PATH}/${name}/CMakeLists.txt ${CMAKE_BINARY_DIR}/${name}-src/cpp/ COPYONLY)
91-
configure_file(${PSP_CMAKE_MODULE_PATH}/${name}/config.h ${CMAKE_BINARY_DIR}/${name}-src/cpp/src/arrow/util/ COPYONLY)
92-
add_subdirectory(${CMAKE_BINARY_DIR}/${name}-src/cpp/
93-
${CMAKE_BINARY_DIR}/${name}-build
94-
EXCLUDE_FROM_ALL)
95-
96-
include_directories(${CMAKE_BINARY_DIR}/${name}-src/cpp/src/)
97-
elseif(${name} STREQUAL exprtk)
98-
# no cmakelists - just include the header
99-
include_directories(${CMAKE_BINARY_DIR}/${name}-src)
100-
elseif(${name} STREQUAL re2)
101-
# Overwrite re2's CMakeLists with our custom CMakeLists.
102-
configure_file(${PSP_CMAKE_MODULE_PATH}/${name}/CMakeLists.txt ${CMAKE_BINARY_DIR}/${name}-src/ COPYONLY)
103-
include_directories(${CMAKE_BINARY_DIR}/${name}-src)
104-
105-
add_subdirectory(${CMAKE_BINARY_DIR}/${name}-src
106-
${CMAKE_BINARY_DIR}/${name}-build
107-
EXCLUDE_FROM_ALL)
108-
else()
109-
add_subdirectory(${CMAKE_BINARY_DIR}/${name}-src
110-
${CMAKE_BINARY_DIR}/${name}-build
111-
EXCLUDE_FROM_ALL)
112-
113-
include_directories(${CMAKE_BINARY_DIR}/${name}-src/extras/${name}/include)
114-
include_directories(${CMAKE_BINARY_DIR}/${name}-src/include)
115-
include_directories(${CMAKE_BINARY_DIR}/${name}-src)
116-
endif()
117-
endfunction()
118-
119-
# #############################
120-
12162
# ######################
12263
# BUILD CONFIGURATION #
12364
# ######################
12465
find_package(Color)
66+
find_package(InstallDependency)
12567

12668
# OPTIONS
12769
option(CMAKE_BUILD_TYPE "Release/Debug build" RELEASE)
@@ -391,29 +333,7 @@ elseif(PSP_CPP_BUILD OR PSP_PYTHON_BUILD)
391333
psp_build_message("${Cyan}Using Python ${Python_VERSION}, \nPython_INCLUDE_DIRS: ${Python_INCLUDE_DIRS}, \nPython_LIBRARIES: ${Python_LIBRARIES}, \nPython_EXECUTABLE: ${Python_EXECUTABLE} ${ColorReset}")
392334
include_directories(${Python_INCLUDE_DIRS})
393335

394-
if(MACOS)
395-
# on mac, use the vanilla pybind11 finder
396-
find_package(pybind11)
397-
398-
if(pybind11_FOUND)
399-
# Found PyBind installed by Homebrew
400-
set(PYTHON_PYBIND_FOUND pybind11_FOUND)
401-
else()
402-
# Check if pip installed PyBind is available
403-
find_package(Pybind)
404-
endif()
405-
else()
406-
# On Linux/Docker, look for pip installed PyBind only
407-
find_package(Pybind)
408-
endif()
409-
410-
if(NOT PYTHON_PYBIND_FOUND)
411-
psp_build_message("${Red}PyBind11 could not be located - building from external source${ColorReset}")
412-
psp_build_dep("pybind11" "${PSP_CMAKE_MODULE_PATH}/Pybind.txt.in")
413-
else()
414-
psp_build_message("${Cyan}Found PyBind11 in ${PYTHON_PYBIND_INCLUDE_DIR}${ColorReset}")
415-
include_directories(${PYTHON_PYBIND_INCLUDE_DIR})
416-
endif()
336+
psp_build_dep("pybind11" "${PSP_CMAKE_MODULE_PATH}/Pybind.txt.in")
417337

418338
find_package(NumPy)
419339

@@ -439,47 +359,18 @@ message("${Cyan}Building minimal Apache Arrow${ColorReset}")
439359
# Build arrow dependencies
440360
psp_build_dep("rapidjson" "${PSP_CMAKE_MODULE_PATH}/rapidjson.txt.in")
441361
psp_build_dep("double-conversion" "${PSP_CMAKE_MODULE_PATH}/double-conversion.txt.in")
442-
443-
# FIXME: this is a hack to get Flatbuffers working on Azure Win64 by making the
444-
# headers accessible. The actual flatc executable is installed using
445-
# Chocolatey for our Azure Windows job.
446-
find_package(Flatbuffers)
447-
448-
if(NOT FLATBUFFERS_FOUND)
449-
psp_build_message("${Cyan}Could not find Flatbuffers${ColorReset}")
450-
psp_build_dep("flatbuffers" "${PSP_CMAKE_MODULE_PATH}/flatbuffers.txt.in")
451-
else()
452-
psp_build_message("${Cyan}Found Flatbuffers in ${FLATBUFFERS_INCLUDE_DIR}${ColorReset}")
453-
include_directories(${FLATBUFFERS_INCLUDE_DIR})
454-
endif()
362+
psp_build_dep("flatbuffers" "${PSP_CMAKE_MODULE_PATH}/flatbuffers.txt.in")
455363

456364
# Build minimal arrow itself
457365
psp_build_dep("arrow" "${PSP_CMAKE_MODULE_PATH}/arrow.txt.in")
458366

459367
# Build re2 as our regex library
460-
find_package(re2)
461-
462-
if(NOT re2_FOUND)
463-
psp_build_message("${Cyan}Could not find Re2${ColorReset}")
464-
465-
# this is a workaround for some re2-specific weirdness
466-
add_definitions(-DTARGET_OS_OSX=1)
467-
psp_build_dep("re2" "${PSP_CMAKE_MODULE_PATH}/re2.txt.in")
468-
else()
469-
psp_build_message("${Cyan}Found re2 in ${RE2_INCLUDE_DIR}${ColorReset}")
470-
include_directories(${RE2_INCLUDE_DIR})
471-
endif()
368+
# this is a workaround for some re2-specific weirdness
369+
add_definitions(-DTARGET_OS_OSX=1)
370+
psp_build_dep("re2" "${PSP_CMAKE_MODULE_PATH}/re2.txt.in")
472371

473372
# Build exprtk for expression parsing
474-
find_package(exprtk)
475-
476-
if(NOT exprtk_FOUND)
477-
psp_build_message("${Cyan}Could not find exprtk${ColorReset}")
478-
psp_build_dep("exprtk" "${PSP_CMAKE_MODULE_PATH}/exprtk.txt.in")
479-
else()
480-
psp_build_message("${Cyan}Found exprtk in ${EXPRTK_INCLUDE_DIR}${ColorReset}")
481-
include_directories(${EXPRTK_INCLUDE_DIR})
482-
endif()
373+
psp_build_dep("exprtk" "${PSP_CMAKE_MODULE_PATH}/exprtk.txt.in")
483374

484375
# ####################
485376
set(CMAKE_C_FLAGS_RELEASE " \
@@ -689,10 +580,6 @@ elseif(PSP_CPP_BUILD OR PSP_PYTHON_BUILD)
689580
set_property(TARGET psp PROPERTY INSTALL_RPATH ${CMAKE_INSTALL_RPATH} ${module_origin_path})
690581
set_property(TARGET binding PROPERTY INSTALL_RPATH ${CMAKE_INSTALL_RPATH} ${module_origin_path})
691582

692-
target_compile_options(arrow PRIVATE -fvisibility=hidden)
693-
target_compile_options(flatbuffers PRIVATE -fvisibility=hidden)
694-
target_compile_options(double-conversion PRIVATE -fvisibility=hidden)
695-
target_compile_options(re2 PRIVATE -fvisibility=hidden)
696583
target_compile_options(psp PRIVATE -fvisibility=hidden)
697584
target_compile_options(binding PRIVATE -fvisibility=hidden)
698585
else()

python/perspective/bench/runtime/bench.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ def after_each(self):
144144

145145

146146
class Runner(object):
147-
148147
ITERATIONS = 10
149148

150149
def __init__(self, suite):
@@ -165,12 +164,12 @@ def __init__(self, suite):
165164
class_attrs = self._suite.__class__.__dict__.items()
166165
instance_attrs = self._suite.__dict__.items()
167166

168-
for (k, v) in class_attrs:
167+
for k, v in class_attrs:
169168
if hasattr(v, "benchmark") and getattr(v, "benchmark") is True:
170169
logging.info("Registering {0}".format(k))
171170
self._benchmarks.append(v)
172171

173-
for (k, v) in instance_attrs:
172+
for k, v in instance_attrs:
174173
if hasattr(v, "benchmark") and getattr(v, "benchmark") is True:
175174
logging.info("Registering {0}".format(k))
176175
self._benchmarks.append(v)

python/perspective/bench/runtime/perspective_benchmark.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ def empty_callback(port_id):
3838

3939

4040
class PerspectiveBenchmark(Suite):
41-
4241
AGG_OPTIONS = [
4342
[{"column": "Sales", "op": "sum"}],
4443
[{"column": "State", "op": "dominant"}],

python/perspective/perspective/client/websocket.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ async def close(self):
4646

4747

4848
class PerspectiveWebsocketClient(PerspectiveClient):
49-
5049
# Ping the server every 30 seconds
5150
PING_TIMEOUT = 15 * 1000
5251

python/perspective/perspective/manager/manager_internal.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ def default(self, obj):
3434

3535

3636
class _PerspectiveManagerInternal(object):
37-
3837
# Commands that should be blocked from execution when the manager is in
3938
# `locked` mode, i.e. its tables and views made immutable from remote
4039
# modification.

python/perspective/perspective/table/table.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,13 +200,13 @@ def validate_expressions(self, expressions, as_string=False):
200200
# full expression string in the UI.
201201
validated["expression_alias"][expression[0]] = expression[1]
202202

203-
for (alias, dtype) in expression_schema.items():
203+
for alias, dtype in expression_schema.items():
204204
if not as_string:
205205
dtype = _str_to_pythontype(dtype)
206206

207207
validated["expression_schema"][alias] = expression_schema[alias]
208208

209-
for (alias, error) in expression_errors.items():
209+
for alias, error in expression_errors.items():
210210
error_dict = {}
211211
error_dict["error_message"] = error.error_message
212212
error_dict["line"] = error.line

0 commit comments

Comments
 (0)