Skip to content

Commit

Permalink
Merge pull request #332 from rapidsai/branch-21.08
Browse files Browse the repository at this point in the history
  • Loading branch information
ajschmidt8 committed Sep 22, 2021
2 parents 05b6ede + 955fa5e commit 90f6b4b
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 14 deletions.
3 changes: 3 additions & 0 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ endif()
##############################################################################
# - install targets-----------------------------------------------------------
rapids_cmake_install_lib_dir( lib_dir )

include(CPack)

add_library(raft INTERFACE)
add_library(raft::raft ALIAS raft)
target_include_directories(raft INTERFACE "$<BUILD_INTERFACE:${RAFT_SOURCE_DIR}/include>"
Expand Down
78 changes: 64 additions & 14 deletions python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,31 @@
import shutil
import sys
import sysconfig
import versioneer

# Must import in this order:
# setuptools -> Cython.Distutils.build_ext -> setuptools.command.build_ext
# Otherwise, setuptools.command.build_ext ends up inheriting from
# Cython.Distutils.old_build_ext which we do not want
import setuptools

try:
from Cython.Distutils.build_ext import new_build_ext as _build_ext
except ImportError:
from setuptools.command.build_ext import build_ext as _build_ext

from distutils.sysconfig import get_python_lib
from pathlib import Path
from setuptools import find_packages
from setuptools import setup

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

from setuputils import clean_folder
from setuputils import get_environment_option
from setuputils import get_cli_option

try:
from Cython.Distutils.build_ext import new_build_ext as build_ext
except ImportError:
from setuptools.command.build_ext import build_ext
from pathlib import Path

import versioneer


##############################################################################
Expand Down Expand Up @@ -99,23 +109,63 @@
"../cpp/include/",
os.path.dirname(sysconfig.get_path("include"))]

cmdclass = dict()
cmdclass.update(versioneer.get_cmdclass())
cmdclass["build_ext"] = build_ext

extensions = [
Extension("*",
sources=["raft/**/**/*.pyx"],
sources=["raft/**/*.pyx"],
include_dirs=include_dirs,
library_dirs=[get_python_lib()],
runtime_library_dirs=[cuda_lib_dir,
os.path.join(os.sys.prefix, "lib")],
libraries=libs,
language='c++',
extra_compile_args=['-std=c++14'])
extra_compile_args=['-std=c++17'])
]


class build_ext_no_debug(_build_ext):

def build_extensions(self):
def remove_flags(compiler, *flags):
for flag in flags:
try:
compiler.compiler_so = list(
filter((flag).__ne__, compiler.compiler_so)
)
except Exception:
pass
# Full optimization
self.compiler.compiler_so.append("-O3")
# No debug symbols, full optimization, no '-Wstrict-prototypes' warning
remove_flags(
self.compiler, "-g", "-G", "-O1", "-O2", "-Wstrict-prototypes"
)
super().build_extensions()

def finalize_options(self):
if self.distribution.ext_modules:
# Delay import this to allow for Cython-less installs
from Cython.Build.Dependencies import cythonize

nthreads = getattr(self, "parallel", None) # -j option in Py3.5+
nthreads = int(nthreads) if nthreads else None
self.distribution.ext_modules = cythonize(
self.distribution.ext_modules,
nthreads=nthreads,
force=self.force,
gdb_debug=False,
compiler_directives=dict(
profile=False, language_level=3, embedsignature=True
),
)
# Skip calling super() and jump straight to setuptools
setuptools.command.build_ext.build_ext.finalize_options(self)


cmdclass = dict()
cmdclass.update(versioneer.get_cmdclass())
cmdclass["build_ext"] = build_ext_no_debug


##############################################################################
# - Python package generation ------------------------------------------------

Expand Down

0 comments on commit 90f6b4b

Please sign in to comment.