Skip to content

Commit

Permalink
Merge pull request #39 from kkraus14/update-setup.py
Browse files Browse the repository at this point in the history
[REVIEW] Add cython headers to install, python / cmake packaging cleanup
  • Loading branch information
kkraus14 authored Sep 6, 2019
2 parents 301a9e8 + 0e5efbb commit e84e760
Show file tree
Hide file tree
Showing 8 changed files with 117 additions and 62 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@

## Improvements

- #31 Add Github CODEOWNERS
- PR #31 Add Github CODEOWNERS
- PR #39 Add cython headers to install, python / cmake packaging cleanup

## Bug Fixes

Expand Down
62 changes: 32 additions & 30 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ if(CMAKE_COMPILER_IS_GNUCXX)

option(CMAKE_CXX11_ABI "Enable the GLIBCXX11 ABI" ON)
if(CMAKE_CXX11_ABI)
message(STATUS "CUDF: Enabling the GLIBCXX11 ABI")
message(STATUS "CUSPATIAL: Enabling the GLIBCXX11 ABI")
else()
message(STATUS "CUDF: Disabling the GLIBCXX11 ABI")
message(STATUS "CUSPATIAL: Disabling the GLIBCXX11 ABI")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler -D_GLIBCXX_USE_CXX11_ABI=0")
Expand Down Expand Up @@ -101,20 +101,31 @@ include(FeatureSummary)
include(CheckIncludeFiles)
include(CheckLibraryExists)

###################################################################################################
# - conda environment -----------------------------------------------------------------------------

if("$ENV{CONDA_BUILD}" STREQUAL "1")
set(CMAKE_SYSTEM_PREFIX_PATH "$ENV{BUILD_PREFIX};$ENV{PREFIX};${CMAKE_SYSTEM_PREFIX_PATH}")
set(CONDA_INCLUDE_DIRS "$ENV{BUILD_PREFIX}/include" "$ENV{PREFIX}/include")
set(CONDA_LINK_DIRS "$ENV{BUILD_PREFIX}/lib" "$ENV{PREFIX}/lib")
message(STATUS "Conda build detected, CMAKE_SYSTEM_PREFIX_PATH set to: ${CMAKE_SYSTEM_PREFIX_PATH}")
elseif(DEFINED ENV{CONDA_PREFIX})
set(CMAKE_SYSTEM_PREFIX_PATH "$ENV{CONDA_PREFIX};${CMAKE_SYSTEM_PREFIX_PATH}")
set(CONDA_INCLUDE_DIRS "$ENV{CONDA_PREFIX}/include")
set(CONDA_LINK_DIRS "$ENV{CONDA_PREFIX}/lib")
message(STATUS "Conda environment detected, CMAKE_SYSTEM_PREFIX_PATH set to: ${CMAKE_SYSTEM_PREFIX_PATH}")
endif("$ENV{CONDA_BUILD}" STREQUAL "1")

###################################################################################################
# - RMM -------------------------------------------------------------------------------------------

find_path(RMM_INCLUDE "rmm"
HINTS "$ENV{RMM_ROOT}/include"
"$ENV{CONDA_PREFIX}/include/rmm"
"$ENV{CONDA_PREFIX}/include")
HINTS "$ENV{RMM_ROOT}/include")

find_library(RMM_LIBRARY "rmm"
HINTS "$ENV{RMM_ROOT}/lib"
"$ENV{CONDA_PREFIX}/lib")
HINTS "$ENV{RMM_ROOT}/lib")

message(STATUS "RMM: RMM_ROOT set to $ENV{RMM_ROOT}")
message(STATUS "RMM: CONDA_PREFIX set to $ENV{CONDA_PREFIX}")
message(STATUS "RMM: RMM_LIBRARY set to ${RMM_LIBRARY}")
message(STATUS "RMM: RMM_INCLUDE set to ${RMM_INCLUDE}")

Expand All @@ -126,21 +137,17 @@ endif (RMM_INCLUDE AND RMM_LIBRARY)
# - CUDF -------------------------------------------------------------------------------------------

find_path(CUDF_INCLUDE "cudf"
"$ENV{CUDF_HOME}/cpp/include"
"$ENV{CONDA_PREFIX}/include/cudf"
"$ENV{CONDA_PREFIX}/include")
HINTS "$ENV{CUDF_ROOT}/cpp/include")

find_library(CUDF_LIBRARY "cudf"
"$ENV{CUDF_HOME}/cpp/build"
"$ENV{CONDA_PREFIX}/lib")

SET(CUDF_SRC_INCLUDE "$ENV{CUDF_HOME}/cpp/src")
HINTS "$ENV{CUDF_ROOT}/lib")

SET(CUDF_SRC_INCLUDE "$ENV{CUDF_HOME}/cpp/src")
SET(CUB_INCLUDE "$ENV{CUDF_HOME}/cpp/thirdparty/cub")
SET(JITIFY_INCLUDE "$ENV{CUDF_HOME}/cpp/thirdparty/jitify")
SET(CUDF_TEST_INCLUDE "$ENV{CUDF_HOME}/cpp/")

message(STATUS "CUDF: CUDF_HOME set to $ENV{CUDF_HOME}")
message(STATUS "CUDF: CONDA_PREFIX set to $ENV{CONDA_PREFIX}")
message(STATUS "CUDF: CUDF_LIBRARY set to ${CUDF_LIBRARY}")
message(STATUS "CUDF: CUDF_INCLUDE set to ${CUDF_INCLUDE}")
message(STATUS "CUDF SRC: CUDF_SRC_INCLUDE set to ${CUDF_SRC_INCLUDE}")
Expand All @@ -157,21 +164,16 @@ endif (CUDF_INCLUDE AND CUDF_LIBRARY)
# - NVStrings -------------------------------------------------------------------------------------

find_path(NVSTRINGS_INCLUDE "nvstrings"
HINTS "$ENV{NVSTRINGS_ROOT}/include"
"$ENV{CONDA_PREFIX}/include/nvstrings"
"$ENV{CONDA_PREFIX}/include")
HINTS "$ENV{NVSTRINGS_ROOT}/include")

find_library(NVSTRINGS_LIBRARY "NVStrings"
HINTS "$ENV{NVSTRINGS_ROOT}/lib"
"$ENV{CONDA_PREFIX}/lib")
HINTS "$ENV{NVSTRINGS_ROOT}/lib")

find_library(NVCATEGORY_LIBRARY "NVCategory"
HINTS "$ENV{NVSTRINGS_ROOT}/lib"
"$ENV{CONDA_PREFIX}/lib")
HINTS "$ENV{NVSTRINGS_ROOT}/lib")

find_library(NVTEXT_LIBRARY "NVText"
HINTS "$ENV{NVSTRINGS_ROOT}/lib"
"$ENV{CONDA_PREFIX}/lib")
HINTS "$ENV{NVSTRINGS_ROOT}/lib")

message(STATUS "NVSTRINGS: NVSTRINGS_INCLUDE set to ${NVSTRINGS_INCLUDE}")
message(STATUS "NVSTRINGS: NVSTRINGS_LIBRARY set to ${NVSTRINGS_LIBRARY}")
Expand Down Expand Up @@ -213,9 +215,9 @@ endif(BUILD_TESTS)
# - add google benchmark --------------------------------------------------------------------------

if(BUILD_BENCHMARKS)

include(ConfigureGoogleBenchmark)

if(GBENCH_FOUND)
message(STATUS "Google C++ Benchmarking Framework (Google Benchmark) found in ${GBENCH_ROOT}")
include_directories(${GBENCH_INCLUDE_DIR})
Expand All @@ -236,13 +238,13 @@ endif(CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES)
include_directories("${CMAKE_BINARY_DIR}/include"
"${CMAKE_SOURCE_DIR}/include"
"${CMAKE_SOURCE_DIR}/src"
"${CMAKE_SOURCE_DIR}/thirdparty/cub"
"${CMAKE_SOURCE_DIR}/thirdparty/cub"
"${RMM_INCLUDE}"
"${CUDF_SRC_INCLUDE}"
"${CUDF_INCLUDE}"
"${CUB_INCLUDE}"
"${JITIFY_INCLUDE}")


###################################################################################################
# - library paths ---------------------------------------------------------------------------------
Expand All @@ -264,7 +266,7 @@ add_library(cuspatial SHARED
src/io/soa/timestamp_soa_reader.cu
src/query/spatial_window_points.cu
src/spatial/point_in_polygon.cu
src/spatial/haversine.cu
src/spatial/haversine.cu
src/spatial/hausdorff.cu
src/spatial/lonlat_to_coordinate.cu
src/trajectory/trajectory_spatial_bound.cu
Expand Down
27 changes: 13 additions & 14 deletions cpp/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)

project(CUDF_TESTS LANGUAGES C CXX CUDA)
project(CUSPATIAL_TESTS LANGUAGES C CXX CUDA)

if(NOT CMAKE_CUDA_COMPILER)
message(SEND_ERROR "CMake cannot locate a CUDA compiler")
Expand All @@ -9,17 +9,16 @@ endif()
###################################################################################################
# - common test utils -----------------------------------------------------------------------------

add_library(cudftestutil STATIC
"${CUDF_TEST_INCLUDE}/tests/utilities/cudf_test_utils.cu"
"${CUDF_TEST_INCLUDE}/tests/utilities/valid_vectors.cpp"
"${CUDF_TEST_INCLUDE}/tests/utilities/nvcategory_utils.cu")
find_library(CUDFTESTUTIL_LIBRARY "libcudftestutil.a"
HINTS "$ENV{CUDF_ROOT}/lib")

target_link_libraries(cudftestutil cudf cuspatial rmm cudart cuda nvrtc NVCategory NVStrings)
message(STATUS "CUDFTESTUTIL: CUDFTESTUTIL_LIBRARY set to ${CUDFTESTUTIL_LIBRARY}")
message(STATUS "CUDFTESTUTIL: CUDF_TEST_INCLUDE set to ${CUDF_TEST_INCLUDE}")

if(USE_NVTX)
target_link_libraries(cudftestutil ${NVTX_LIBRARY})
endif(USE_NVTX)
add_library(cudftestutil STATIC IMPORTED ${CUDFTESTUTIL_LIBRARY})
if (CUDF_TEST_INCLUDE AND CUDFTESTUTIL_LIBRARY)
set_target_properties(cudftestutil PROPERTIES IMPORTED_LOCATION ${CUDFTESTUTIL_LIBRARY})
endif (CUDF_TEST_INCLUDE AND CUDFTESTUTIL_LIBRARY)

###################################################################################################
# - compiler function -----------------------------------------------------------------------------
Expand All @@ -28,7 +27,7 @@ function(ConfigureTest CMAKE_TEST_NAME CMAKE_TEST_SRC)
add_executable(${CMAKE_TEST_NAME}
${CMAKE_TEST_SRC})
set_target_properties(${CMAKE_TEST_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_link_libraries(${CMAKE_TEST_NAME} gmock gtest gmock_main gtest_main pthread cudf
target_link_libraries(${CMAKE_TEST_NAME} gmock gtest gmock_main gtest_main pthread cuspatial cudf
cudftestutil rmm cudart cuda "${ARROW_LIB}" ${ZLIB_LIBRARIES} NVCategory
NVStrings nvrtc)
if(USE_NVTX)
Expand All @@ -39,14 +38,14 @@ function(ConfigureTest CMAKE_TEST_NAME CMAKE_TEST_SRC)
add_test(NAME ${CMAKE_TEST_NAME} COMMAND ${CMAKE_TEST_NAME})
endfunction(ConfigureTest)

option(CMAKE_ENABLE_BENCHMARKS "Enable building cuDF benchmarks" OFF)
option(CMAKE_ENABLE_BENCHMARKS "Enable building cuSpatial benchmarks" OFF)

function(ConfigureBench CMAKE_BENCH_NAME CMAKE_BENCH_SRC)
if(CMAKE_ENABLE_BENCHMARKS)
add_executable(${CMAKE_BENCH_NAME}
${CMAKE_BENCH_SRC})
set_target_properties(${CMAKE_BENCH_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_link_libraries(${CMAKE_BENCH_NAME} cudf cudftestutil)
target_link_libraries(${CMAKE_BENCH_NAME} cuspatial cudf cudftestutil)
set_target_properties(${CMAKE_BENCH_NAME} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bench")
add_test(NAME ${CMAKE_BENCH_NAME} COMMAND ${CMAKE_BENCH_NAME})
Expand Down Expand Up @@ -80,7 +79,7 @@ include_directories("${CMAKE_BINARY_DIR}/include"

link_directories("${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}" # CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES is an undocumented/unsupported variable containing the link directories for nvcc
"${CMAKE_BINARY_DIR}/lib"
"${GTEST_LIBRARY_DIR}"
"${GTEST_LIBRARY_DIR}"
"${RMM_LIBRARY}"
"${CUDF_LIBRARY}"
"${CUSPATIAL_LIBRARY}"
Expand Down
19 changes: 19 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[tool.black]
line-length = 79
target-version = ["py36"]
include = '\.py?$'
exclude = '''
/(
thirdparty |
\.eggs |
\.git |
\.hg |
\.mypy_cache |
\.tox |
\.venv |
_build |
buck-out |
build |
dist
)/
'''
29 changes: 29 additions & 0 deletions python/cuspatial/.flake8.cython
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#
# Copyright (c) 2018-2019, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

[flake8]
filename = *.pyx, *.pxd
exclude = *.egg, build, docs, .git
ignore = E999, E225, E226, E227, W503, W504, E211

# Rules ignored:
# E999: invalid syntax (works for Python, not Cython)
# E211: whitespace before '(' (used in multi-line imports)
# E225: Missing whitespace around operators (breaks cython casting syntax like <int>)
# E226: Missing whitespace around arithmetic operators (breaks cython pointer syntax like int*)
# E227: Missing whitespace around bitwise or shift operator (Can also break casting syntax)
# W503: line break before binary operator (breaks lines that start with a pointer)
# W504: line break after binary operator (breaks lines that end with a pointer)
24 changes: 11 additions & 13 deletions python/cuspatial/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,13 @@ ignore =
# whitespace before :
E203

known_third_party=
cython,
msgpack,
numba,
numpy,
packaging,
pandas,
pyarrow,
pytest,
setuptools,
six,
toolz,
versioneer
[isort]
line_length=79
multi_line_output=3
include_trailing_comma=True
force_grid_wrap=0
combine_as_imports=True
order_by_type=True
known_dask=
dask
distributed
Expand All @@ -46,6 +40,9 @@ known_rapids=
cugraph
cudf
dask_cudf
known_first_party=
cuspatial
default_section=THIRDPARTY
sections=FUTURE,STDLIB,THIRDPARTY,DASK,RAPIDS,FIRSTPARTY,LOCALFOLDER
skip=
thirdparty
Expand All @@ -59,3 +56,4 @@ skip=
buck-out
build
dist
__init__.py
8 changes: 4 additions & 4 deletions python/cuspatial/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@
sources=cython_files,
include_dirs=[
"../../cpp/include/cuspatial",
os.environ['CONDA_PREFIX']+"/include/cudf",
os.path.dirname(sysconfig.get_path("include")),
np.get_include()
np.get_include(),
],
library_dirs=[get_python_lib()],
libraries=["cudf","cuspatial"],
libraries=["cudf", "cuspatial"],
language="c++",
extra_compile_args=["-std=c++14"]
extra_compile_args=["-std=c++14"],
)
]

Expand All @@ -50,6 +49,7 @@
setup_requires=["cython"],
ext_modules=cythonize(extensions),
packages=find_packages(include=["cuspatial", "cuspatial.*"]),
package_data={"cuspatial._lib": ["*.pxd"]},
cmdclass=versioneer.get_cmdclass(),
install_requires=install_requires,
zip_safe=False,
Expand Down
7 changes: 7 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[flake8]
exclude = img,thirdparty,__init__.py,build
ignore =
# line break before binary operator
W503
# whitespace before :
E203

0 comments on commit e84e760

Please sign in to comment.