Skip to content

Commit cb63490

Browse files
Packaging milestone
1. installation script copies backends/include/* into dpctl/ 2. Use MANIFEST.in to include dpctl/include and dpctl/libDPPL*Inteface.* into installation layout 3. Added dpctl.get_include() function to provide location of includes needed to build extension linked to dpCtl 4. Provide dpctl/__init__.pxd allowing to do `cimport dptcl` to access relevant entities like dpctl.SyclQueue, etc.
1 parent f372028 commit cb63490

File tree

7 files changed

+70
-16
lines changed

7 files changed

+70
-16
lines changed

MANIFEST.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
11
include versioneer.py
2+
recursive-include dpctl/include *.h *.hpp
3+
include dpctl/*.pxd
4+
include dpctl/*DPPL*Interface.*
5+
global-exclude *.cpp

conda-recipe/bld.bat

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ ninja install
2525
IF %ERRORLEVEL% NEQ 0 exit 1
2626

2727
cd ..
28+
mkdir dpctl\include
29+
xcopy backends\include dpctl\include /E /Y
2830

2931
REM required by dpglue
3032
set "DPPL_OPENCL_INTERFACE_LIBDIR=%LIBRARY_PREFIX%/lib"

conda-recipe/build.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ cmake \
3232
make -j 4 && make install
3333

3434
cd ..
35+
mkdir -p dpctl/include
36+
cp -r backends/include/* dpctl/include
3537

3638
# required by dpctl.opencl_core
3739
export DPPL_OPENCL_INTERFACE_LIBDIR=${PREFIX}
@@ -46,7 +48,6 @@ export DPPL_SYCL_INTERFACE_INCLDIR=${PREFIX}/include
4648
# FIXME: How to pass this using setup.py? This flags is needed when
4749
# dpcpp compiles the generated cpp file.
4850
export CFLAGS="-fPIC -O3 ${CFLAGS}"
49-
export LDFLAGS="-L OpenCL_LIBDIR ${LDFLAGS}"
51+
export LDFLAGS="-L ${OpenCL_LIBDIR} ${LDFLAGS}"
5052
${PYTHON} setup.py clean --all
51-
${PYTHON} setup.py build
52-
${PYTHON} setup.py install
53+
${PYTHON} setup.py build install

dpctl/__init__.pxd

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
##===------------- sycl_core.pxd - dpctl module --------*- Cython -*-------===##
2+
##
3+
## Data Parallel Control (dpCtl)
4+
##
5+
## Copyright 2020 Intel Corporation
6+
##
7+
## Licensed under the Apache License, Version 2.0 (the "License");
8+
## you may not use this file except in compliance with the License.
9+
## You may obtain a copy of the License at
10+
##
11+
## http://www.apache.org/licenses/LICENSE-2.0
12+
##
13+
## Unless required by applicable law or agreed to in writing, software
14+
## distributed under the License is distributed on an "AS IS" BASIS,
15+
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
## See the License for the specific language governing permissions and
17+
## limitations under the License.
18+
##
19+
##===----------------------------------------------------------------------===##
20+
##
21+
## \file
22+
## This file declares the extension types and functions for the Cython API
23+
## implemented in sycl_core.pyx.
24+
##
25+
##===----------------------------------------------------------------------===##
26+
27+
# distutils: language = c++
28+
# cython: language_level=3
29+
30+
from dpctl._sycl_core cimport *

dpctl/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,15 @@
4949
from ._sycl_core import *
5050
from ._version import get_versions
5151

52+
def get_include():
53+
"""
54+
Return the directory that contains the dpCtl *.h header files.
55+
56+
Extension modules that need to be compiled against dpCtl should use
57+
this function to locate the appropriate include directory.
58+
"""
59+
import os.path
60+
return os.path.join(__file__, 'include')
61+
5262
__version__ = get_versions()['version']
5363
del get_versions

scripts/build_for_develop.sh

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,19 @@ make V=1 -n -j 4 && make install
2828
popd
2929
cp install/lib/*.so dpctl/
3030

31-
export DPPL_OPENCL_INTERFACE_LIBDIR=${INSTALL_PREFIX}/lib
32-
export DPPL_OPENCL_INTERFACE_INCLDIR=${INSTALL_PREFIX}/include
31+
mkdir -p dpctl/include
32+
cp -r backends/include/* dpctl/include
33+
34+
export DPPL_OPENCL_INTERFACE_LIBDIR=dpctl
35+
export DPPL_OPENCL_INTERFACE_INCLDIR=dpctl/include
3336
export OpenCL_LIBDIR=/usr/lib/x86_64-linux-gnu/
34-
export DPPL_SYCL_INTERFACE_LIBDIR=${INSTALL_PREFIX}/lib
35-
export DPPL_SYCL_INTERFACE_INCLDIR=${INSTALL_PREFIX}/include
37+
export DPPL_SYCL_INTERFACE_LIBDIR=dpctl
38+
export DPPL_SYCL_INTERFACE_INCLDIR=dpctl/include
3639

3740
export CC=clang
3841
export CXX=dpcpp
3942
# FIXME: How to pass this using setup.py? The fPIC flag is needed when
4043
# dpcpp compiles the Cython generated cpp file.
4144
export CFLAGS=-fPIC
4245
python setup.py clean --all
43-
python setup.py build_ext --inplace
44-
python setup.py develop
46+
python setup.py build develop

setup.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
### This file builds the dpctl and dpctl.ocldrv extension modules.
2323
##===----------------------------------------------------------------------===##
2424
import os
25+
import os.path
2526
import sys
2627
import versioneer
2728

@@ -30,7 +31,6 @@
3031

3132
import numpy as np
3233

33-
3434
requirements = [
3535
'cffi>=1.0.0',
3636
'cython',
@@ -100,22 +100,25 @@ def extensions():
100100
librarys = [dppl_sycl_interface_lib]
101101

102102
if IS_LIN or IS_MAC:
103-
runtime_library_dirs = [os.path.abspath('dpctl')]
103+
runtime_library_dirs = ["$ORIGIN"]
104104
elif IS_WIN:
105105
runtime_library_dirs = []
106106

107107
extension_args = {
108108
"depends": [dppl_sycl_interface_include,],
109109
"include_dirs": [np.get_include(), dppl_sycl_interface_include],
110110
"extra_compile_args": eca + get_other_cxxflags(),
111-
"extra_link_args": ela, "libraries": libs, "library_dirs": librarys,
112-
"runtime_library_dirs": runtime_library_dirs, "language": 'c++',
111+
"extra_link_args": ela,
112+
"libraries": libs,
113+
"library_dirs": librarys,
114+
"runtime_library_dirs": runtime_library_dirs,
115+
"language": 'c++',
113116
}
114117

115118
extensions = [
116-
Extension('dpctl._sycl_core', [os.path.abspath('dpctl/sycl_core.pyx'),],
119+
Extension('dpctl._sycl_core', [os.path.join('dpctl', 'sycl_core.pyx'),],
117120
**extension_args),
118-
Extension('dpctl._memory', [os.path.abspath('dpctl/_memory.pyx'),],
121+
Extension('dpctl._memory', [os.path.join('dpctl', '_memory.pyx'),],
119122
**extension_args),
120123
]
121124

@@ -130,7 +133,8 @@ def extensions():
130133
license="Apache 2.0",
131134
author="Intel Corporation",
132135
url='https://github.com/IntelPython/dpCtl',
133-
packages=find_packages(include=["dpctl", "dpctl.*"]),
136+
packages=find_packages(include=["*"]),
137+
include_package_data=True,
134138
ext_modules = extensions(),
135139
setup_requires=requirements,
136140
cffi_modules=[
@@ -142,5 +146,6 @@ def extensions():
142146
"Development Status :: 3 - Alpha",
143147
'Programming Language :: Python :: 3.6',
144148
'Programming Language :: Python :: 3.7',
149+
'Programming Language :: Python :: 3.8',
145150
]
146151
)

0 commit comments

Comments
 (0)