Skip to content

Commit

Permalink
Failsafe find_package(PythonLibs REQUIRED)
Browse files Browse the repository at this point in the history
Add cmake to conda env

Fix CI build issues

setup.py docs fix

Debug CI test issues
  • Loading branch information
chudur-budur committed Aug 10, 2023
1 parent d138d8b commit a81228c
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 30 deletions.
24 changes: 24 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
#[=======================================================================[.rst:
numba_dpex
-----------
A cmake file to compile the ``_dpexrt_python`` Python C extension for
``numba_dpex``. You can build this component locally in-place by invoking these
commands:
.. code-block:: cmake
~$ cmake .
~$ cmake --build . --verbose
Once compiled, the _dpexrt_python library will be in ``numba_dpex/core/runtime``
folder.
This ``CMakeLists.txt`` file will be used by ``setup.py``.
#]=======================================================================]

cmake_minimum_required(VERSION 3.21...3.27 FATAL_ERROR)

if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.24")
Expand All @@ -11,4 +29,10 @@ project(numba-dpex
VERSION ${NUMBA_DPEX_VERSION}
)

if(IS_INSTALL)
install(DIRECTORY numba_dpex
DESTINATION ${CMAKE_INSTALL_PREFIX}
FILES_MATCHING PATTERN "*.py")
endif()

add_subdirectory(numba_dpex)
1 change: 1 addition & 0 deletions conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ requirements:
- python
- setuptools >=63.*
- scikit-build
- cmake
- numba >=0.57*
- dpctl >=0.14*
- dpnp >=0.11*
Expand Down
3 changes: 2 additions & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ channels:
- nodefaults
dependencies:
- python=3.9
- scikit-build
- gxx_linux-64
- dpcpp_linux-64
- numba >=0.57*
Expand All @@ -17,6 +16,8 @@ dependencies:
- mkl >=2021.3.0 # for dpnp
- dpcpp-llvm-spirv
- packaging
- scikit-build
- cmake
- pytest
- pip
- pip:
Expand Down
1 change: 1 addition & 0 deletions environment/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ dependencies:
- pytest-xdist
- pexpect
- scikit-build
- cmake
3 changes: 1 addition & 2 deletions numba_dpex/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ endif()

if(IS_INSTALL)
install(DIRECTORY examples
DESTINATION numba_dpex
FILES_MATCHING PATTERN "*.py")
DESTINATION numba_dpex)
endif()

if(IS_INSTALL)
Expand Down
74 changes: 48 additions & 26 deletions numba_dpex/core/runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
#[=======================================================================[.rst:
_dpexrt_python
---------------
A cmake file to compile the ``_dpexrt_python`` Python C extension for
``numba_dpex``. You can build this component locally in-place by invoking these
commands:
.. code-block:: cmake
~$ cmake .
~$ cmake --build . --verbose
Once compiled, the _dpexrt_python library will be in ``numba_dpex/core/runtime``
folder.
#]=======================================================================]

cmake_minimum_required(VERSION 3.21...3.27 FATAL_ERROR)

if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.24")
Expand All @@ -9,43 +25,49 @@ project(_dpexrt_python
)

# Get numba include path
execute_process(
COMMAND python -c "import numba; print(numba.extending.include_path());"
OUTPUT_VARIABLE Numba_INCLUDE_DIRS
RESULT_VARIABLE RET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NOT DEFINED Numba_INCLUDE_DIRS)
execute_process(
COMMAND python -c "import numba; print(numba.extending.include_path());"
OUTPUT_VARIABLE Numba_INCLUDE_DIRS
RESULT_VARIABLE RET
OUTPUT_STRIP_TRAILING_WHITESPACE
)

if(RET EQUAL "1")
message(FATAL_ERROR "Module \'numba\' not found.")
if(RET EQUAL "1")
message(FATAL_ERROR "Module \'numba\' not found.")
endif()
endif()

# Get dpctl library path
execute_process(
COMMAND python -c "import dpctl; import os; print(os.path.dirname(dpctl.__file__));"
OUTPUT_VARIABLE DPCTL_LIBRARY_PATH
RESULT_VARIABLE RET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NOT DEFINED DPCTL_LIBRARY_PATH)
execute_process(
COMMAND python -c "import dpctl; import os; print(os.path.dirname(dpctl.__file__));"
OUTPUT_VARIABLE DPCTL_LIBRARY_PATH
RESULT_VARIABLE RET
OUTPUT_STRIP_TRAILING_WHITESPACE
)

if(RET EQUAL "1")
message(FATAL_ERROR "Module \'dpctl\' not found.")
if(RET EQUAL "1")
message(FATAL_ERROR "Module \'dpctl\' not found.")
endif()
endif()

# Update CMAKE_MODULE_PATH
set(DPCTL_MODULE_PATH ${DPCTL_LIBRARY_PATH}/resources/cmake)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${DPCTL_MODULE_PATH})

# Get scikit-build path
execute_process(
COMMAND python -c "import skbuild; print(skbuild.__path__[0]);"
OUTPUT_VARIABLE SKBUILD_PATH
RESULT_VARIABLE RET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NOT DEFINED SKBUILD_PATH)
execute_process(
COMMAND python -c "import skbuild; print(skbuild.__path__[0]);"
OUTPUT_VARIABLE SKBUILD_PATH
RESULT_VARIABLE RET
OUTPUT_STRIP_TRAILING_WHITESPACE
)

if(RET EQUAL "1")
message(FATAL_ERROR "Module \'skbuild\' not found.")
if(RET EQUAL "1")
message(FATAL_ERROR "Module \'skbuild\' not found.")
endif()
endif()

# Update CMAKE_MODULE_PATH
Expand All @@ -63,7 +85,7 @@ find_package(Dpctl REQUIRED)

# Includes
include(GNUInstallDirs)
include_directories(${PYTHON_INCLUDE_DIRS})
include_directories(${Python_INCLUDE_DIRS})
include_directories(${NumPy_INCLUDE_DIRS})
include_directories(${Numba_INCLUDE_DIRS})
include_directories(${Dpctl_INCLUDE_DIRS})
Expand All @@ -79,7 +101,7 @@ link_directories(${DPCTL_LIBRARY_PATH})
add_library(${PROJECT_NAME} MODULE ${SOURCES})

# Link the static library to python libraries and DPCTLSyclInterface
target_link_libraries(${PROJECT_NAME} ${PYTHON_LIBRARIES})
target_link_libraries(${PROJECT_NAME} ${Python_LIBRARIES})
target_link_libraries(${PROJECT_NAME} DPCTLSyclInterface)

# Build python extension module
Expand Down
5 changes: 5 additions & 0 deletions numba_dpex/tests/core/types/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# SPDX-FileCopyrightText: 2020 - 2023 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0

from . import *
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ requires = [
"scikit-build>=0.13",
"cmake>=3.18",
"ninja",
"numba>=0.57",
"versioneer-518"
]
build-backend = "setuptools.build_meta"
9 changes: 8 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
# SPDX-License-Identifier: Apache-2.0


import os
import sys

import dpctl
import numba
import skbuild
from setuptools import find_packages
from skbuild import setup

Expand All @@ -25,6 +29,9 @@
`develop` command:
~$ python setup.py develop
To uninstall:
~$ pip uninstall numba-dpex
NOTE: This script doesn't support pypa/build, pypa/installer or other
standards-based tools like pip, yet.
Expand Down Expand Up @@ -82,7 +89,7 @@ def to_cmake_format(version):
author="Intel Corporation",
url="https://github.com/IntelPython/numba-dpex",
install_requires=["numba >={0:s}".format("0.57"), "dpctl", "packaging"],
packages=find_packages(["numba_dpex", "numba_dpex.*"]),
packages=find_packages("."),
include_package_data=True,
zip_safe=False,
cmake_args=[
Expand Down

0 comments on commit a81228c

Please sign in to comment.