Skip to content

Commit 239470f

Browse files
committed
Failsafe find_package(PythonLibs REQUIRED)
Add cmake to conda env Fix CI build issues setup.py docs fix Debug github CI test issues Fix jenkins
1 parent 70b73f4 commit 239470f

File tree

9 files changed

+90
-33
lines changed

9 files changed

+90
-33
lines changed

CMakeLists.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
#[=======================================================================[.rst:
2+
numba_dpex
3+
-----------
4+
5+
A cmake file to compile the ``_dpexrt_python`` Python C extension for
6+
``numba_dpex``. You can build this component locally in-place by invoking these
7+
commands:
8+
9+
.. code-block:: cmake
10+
~$ cmake .
11+
~$ cmake --build . --verbose
12+
13+
Once compiled, the _dpexrt_python library will be in ``numba_dpex/core/runtime``
14+
folder.
15+
16+
This ``CMakeLists.txt`` file will be used by ``setup.py``.
17+
#]=======================================================================]
18+
119
cmake_minimum_required(VERSION 3.21...3.27 FATAL_ERROR)
220

321
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.24")
@@ -11,4 +29,10 @@ project(numba-dpex
1129
VERSION ${NUMBA_DPEX_VERSION}
1230
)
1331

32+
if(IS_INSTALL)
33+
install(DIRECTORY numba_dpex
34+
DESTINATION ${CMAKE_INSTALL_PREFIX}
35+
FILES_MATCHING PATTERN "*.py")
36+
endif()
37+
1438
add_subdirectory(numba_dpex)

conda-recipe/meta.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ requirements:
1818
- python
1919
- setuptools >=63.*
2020
- scikit-build
21+
- cmake
2122
- numba >=0.57*
2223
- dpctl >=0.14*
2324
- dpnp >=0.11*

environment.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ channels:
88
- nodefaults
99
dependencies:
1010
- python=3.9
11-
- scikit-build
1211
- gxx_linux-64
1312
- dpcpp_linux-64
1413
- numba >=0.57*
@@ -17,6 +16,8 @@ dependencies:
1716
- mkl >=2021.3.0 # for dpnp
1817
- dpcpp-llvm-spirv
1918
- packaging
19+
- scikit-build
20+
- cmake
2021
- pytest
2122
- pip
2223
- pip:

environment/coverage.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ dependencies:
2121
- pytest-xdist
2222
- pexpect
2323
- scikit-build
24+
- cmake

numba_dpex/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ endif()
2020

2121
if(IS_INSTALL)
2222
install(DIRECTORY examples
23-
DESTINATION numba_dpex
24-
FILES_MATCHING PATTERN "*.py")
23+
DESTINATION numba_dpex)
2524
endif()
2625

2726
if(IS_INSTALL)

numba_dpex/core/runtime/CMakeLists.txt

Lines changed: 48 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
#[=======================================================================[.rst:
2+
_dpexrt_python
3+
---------------
4+
5+
A cmake file to compile the ``_dpexrt_python`` Python C extension for
6+
``numba_dpex``. You can build this component locally in-place by invoking these
7+
commands:
8+
9+
.. code-block:: cmake
10+
~$ cmake .
11+
~$ cmake --build . --verbose
12+
13+
Once compiled, the _dpexrt_python library will be in ``numba_dpex/core/runtime``
14+
folder.
15+
#]=======================================================================]
16+
117
cmake_minimum_required(VERSION 3.21...3.27 FATAL_ERROR)
218

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

1127
# Get numba include path
12-
execute_process(
13-
COMMAND python -c "import numba; print(numba.extending.include_path());"
14-
OUTPUT_VARIABLE Numba_INCLUDE_DIRS
15-
RESULT_VARIABLE RET
16-
OUTPUT_STRIP_TRAILING_WHITESPACE
17-
)
28+
if(NOT DEFINED Numba_INCLUDE_DIRS)
29+
execute_process(
30+
COMMAND python -c "import numba; print(numba.extending.include_path());"
31+
OUTPUT_VARIABLE Numba_INCLUDE_DIRS
32+
RESULT_VARIABLE RET
33+
OUTPUT_STRIP_TRAILING_WHITESPACE
34+
)
1835

19-
if(RET EQUAL "1")
20-
message(FATAL_ERROR "Module \'numba\' not found.")
36+
if(RET EQUAL "1")
37+
message(FATAL_ERROR "Module \'numba\' not found.")
38+
endif()
2139
endif()
2240

2341
# Get dpctl library path
24-
execute_process(
25-
COMMAND python -c "import dpctl; import os; print(os.path.dirname(dpctl.__file__));"
26-
OUTPUT_VARIABLE DPCTL_LIBRARY_PATH
27-
RESULT_VARIABLE RET
28-
OUTPUT_STRIP_TRAILING_WHITESPACE
29-
)
42+
if(NOT DEFINED DPCTL_LIBRARY_PATH)
43+
execute_process(
44+
COMMAND python -c "import dpctl; import os; print(os.path.dirname(dpctl.__file__));"
45+
OUTPUT_VARIABLE DPCTL_LIBRARY_PATH
46+
RESULT_VARIABLE RET
47+
OUTPUT_STRIP_TRAILING_WHITESPACE
48+
)
3049

31-
if(RET EQUAL "1")
32-
message(FATAL_ERROR "Module \'dpctl\' not found.")
50+
if(RET EQUAL "1")
51+
message(FATAL_ERROR "Module \'dpctl\' not found.")
52+
endif()
3353
endif()
3454

3555
# Update CMAKE_MODULE_PATH
3656
set(DPCTL_MODULE_PATH ${DPCTL_LIBRARY_PATH}/resources/cmake)
3757
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${DPCTL_MODULE_PATH})
3858

3959
# Get scikit-build path
40-
execute_process(
41-
COMMAND python -c "import skbuild; print(skbuild.__path__[0]);"
42-
OUTPUT_VARIABLE SKBUILD_PATH
43-
RESULT_VARIABLE RET
44-
OUTPUT_STRIP_TRAILING_WHITESPACE
45-
)
60+
if(NOT DEFINED SKBUILD_PATH)
61+
execute_process(
62+
COMMAND python -c "import skbuild; print(skbuild.__path__[0]);"
63+
OUTPUT_VARIABLE SKBUILD_PATH
64+
RESULT_VARIABLE RET
65+
OUTPUT_STRIP_TRAILING_WHITESPACE
66+
)
4667

47-
if(RET EQUAL "1")
48-
message(FATAL_ERROR "Module \'skbuild\' not found.")
68+
if(RET EQUAL "1")
69+
message(FATAL_ERROR "Module \'skbuild\' not found.")
70+
endif()
4971
endif()
5072

5173
# Update CMAKE_MODULE_PATH
@@ -63,7 +85,7 @@ find_package(Dpctl REQUIRED)
6385

6486
# Includes
6587
include(GNUInstallDirs)
66-
include_directories(${PYTHON_INCLUDE_DIRS})
88+
include_directories(${Python_INCLUDE_DIRS})
6789
include_directories(${NumPy_INCLUDE_DIRS})
6890
include_directories(${Numba_INCLUDE_DIRS})
6991
include_directories(${Dpctl_INCLUDE_DIRS})
@@ -79,7 +101,7 @@ link_directories(${DPCTL_LIBRARY_PATH})
79101
add_library(${PROJECT_NAME} MODULE ${SOURCES})
80102

81103
# Link the static library to python libraries and DPCTLSyclInterface
82-
target_link_libraries(${PROJECT_NAME} ${PYTHON_LIBRARIES})
104+
target_link_libraries(${PROJECT_NAME} ${Python_LIBRARIES})
83105
target_link_libraries(${PROJECT_NAME} DPCTLSyclInterface)
84106

85107
# Build python extension module
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# SPDX-FileCopyrightText: 2020 - 2023 Intel Corporation
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
from . import *

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ requires = [
5151
"scikit-build>=0.13",
5252
"cmake>=3.18",
5353
"ninja",
54+
"numba>=0.57",
5455
"versioneer-518"
5556
]
5657
build-backend = "setuptools.build_meta"

setup.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
`develop` command:
2626
~$ python setup.py develop
2727
28+
To uninstall:
29+
~$ pip uninstall numba-dpex
30+
2831
NOTE: This script doesn't support pypa/build, pypa/installer or other
2932
standards-based tools like pip, yet.
3033
@@ -54,16 +57,16 @@ def to_cmake_format(version):
5457

5558

5659
# Set project auxilary data like readme and licence files
57-
with open("README.md") as f:
58-
__readme_file__ = f.read()
60+
with open("README.md", "r") as f:
61+
__readme__ = "".join(line for line in f.readlines()[12:35])
5962

6063

6164
# Main setup
6265
setup(
6366
name="numba-dpex",
6467
version=__version__,
6568
description="An extension for Numba to add data-parallel offload capability",
66-
long_description=__readme_file__,
69+
long_description=__readme__,
6770
long_description_content_type="text/markdown",
6871
license="Apache 2.0",
6972
classifiers=[
@@ -82,7 +85,7 @@ def to_cmake_format(version):
8285
author="Intel Corporation",
8386
url="https://github.com/IntelPython/numba-dpex",
8487
install_requires=["numba >={0:s}".format("0.57"), "dpctl", "packaging"],
85-
packages=find_packages(["numba_dpex", "numba_dpex.*"]),
88+
packages=find_packages("."),
8689
include_package_data=True,
8790
zip_safe=False,
8891
cmake_args=[

0 commit comments

Comments
 (0)