Skip to content

Commit 71901c7

Browse files
Merge pull request #1660 from IntelPython/feature/pyproject
Metadata improvements
2 parents 2b427d6 + c243318 commit 71901c7

18 files changed

+355
-2498
lines changed

.github/workflows/generate-coverage.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ jobs:
9292
- name: Install dpctl dependencies
9393
shell: bash -l {0}
9494
run: |
95-
pip install numpy"<1.26.0" cython setuptools pytest pytest-cov scikit-build cmake coverage[toml]
95+
pip install numpy"<1.26.0" cython setuptools pytest pytest-cov scikit-build cmake coverage[toml] versioneer[toml]==0.29
9696
9797
- name: Build dpctl with coverage
9898
shell: bash -l {0}

.github/workflows/generate-docs.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ jobs:
5656
run: |
5757
pip install numpy cython setuptools scikit-build cmake sphinx"<7.2" pydot graphviz furo \
5858
sphinxcontrib-programoutput sphinxcontrib-googleanalytics sphinx-design \
59-
sphinxcontrib-jsmath sphinx-copybutton sphinxcontrib-spelling
59+
sphinxcontrib-jsmath sphinx-copybutton sphinxcontrib-spelling \
60+
versioneer[toml]==0.29
6061
- name: Checkout repo
6162
uses: actions/[email protected]
6263
with:

.github/workflows/os-llvm-sycl-build.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ jobs:
110110
- name: Install dpctl dependencies
111111
shell: bash -l {0}
112112
run: |
113-
pip install numpy"<1.26.0" cython setuptools pytest scikit-build cmake ninja
113+
pip install numpy"<1.26.0" cython setuptools pytest scikit-build cmake ninja versioneer[toml]==0.29
114114
115115
- name: Checkout repo
116116
uses: actions/[email protected]
@@ -164,4 +164,6 @@ jobs:
164164
SYCL_CACHE_PERSISTENT: 1
165165
run: |
166166
source set_allvars.sh
167-
python -m pytest -v dpctl/tests
167+
# Skip the test that checks if there is only one hard
168+
# copy of DPCTLSyclInterface library
169+
python -m pytest -v dpctl/tests --no-sycl-interface-test

.pre-commit-config.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,8 @@ repos:
3737
hooks:
3838
- id: clang-format
3939
args: ["-i"]
40+
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
41+
rev: v2.12.0
42+
hooks:
43+
- id: pretty-format-toml
44+
args: [--autofix]

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ FetchContent_Declare(
7171
pybind11
7272
URL https://github.com/pybind/pybind11/archive/refs/tags/v2.12.0.tar.gz
7373
URL_HASH SHA256=bf8f242abd1abcd375d516a7067490fb71abd79519a282d22b6e4d19282185a7
74+
FIND_PACKAGE_ARGS NAMES pybind11
7475
)
7576
FetchContent_MakeAvailable(pybind11)
7677

conda-recipe/bld.bat

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ set "LIB=%BUILD_PREFIX%\Library\lib;%BUILD_PREFIX%\compiler\lib;%LIB%"
44
set "INCLUDE=%BUILD_PREFIX%\include;%INCLUDE%"
55

66
"%PYTHON%" setup.py clean --all
7-
set "SKBUILD_ARGS=-G Ninja -- -DCMAKE_C_COMPILER:PATH=icx -DCMAKE_CXX_COMPILER:PATH=icx -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON"
87

98
REM Overriding IPO is useful for building in resources constrained VMs (public CI)
109
if DEFINED OVERRIDE_INTEL_IPO (
11-
set "SKBUILD_ARGS=%SKBUILD_ARGS% -DCMAKE_INTERPROCEDURAL_OPTIMIZATION:BOOL=FALSE"
10+
set "CMAKE_ARGS=%CMAKE_ARGS% -DCMAKE_INTERPROCEDURAL_OPTIMIZATION:BOOL=FALSE"
1211
)
1312

1413
FOR %%V IN (14.0.0 14 15.0.0 15 16.0.0 16 17.0.0 17) DO @(
@@ -32,20 +31,39 @@ if EXIST "%PLATFORM_DIR%" (
3231
if errorlevel 1 exit 1
3332
)
3433

34+
set "CC=icx"
35+
set "CXX=icx"
36+
37+
set "CMAKE_GENERATOR=Ninja"
38+
:: Make CMake verbose
39+
set "VERBOSE=1"
40+
41+
set "CMAKE_ARGS=%CMAKE_ARGS% -DDPCTL_LEVEL_ZERO_INCLUDE_DIR=%PREFIX:\=/%/Library/include/level_zero"
42+
43+
%PYTHON% -m build -w -n -x
44+
if %ERRORLEVEL% neq 0 exit 1
45+
46+
:: `pip install dist\numpy*.whl` does not work on windows,
47+
:: so use a loop; there's only one wheel in dist/ anyway
48+
for /f %%f in ('dir /b /S .\dist') do (
49+
%PYTHON% -m wheel tags --remove --build %GIT_DESCRIBE_NUMBER% %%f
50+
if %ERRORLEVEL% neq 0 exit 1
51+
)
52+
53+
:: wheel file was renamed
54+
for /f %%f in ('dir /b /S .\dist') do (
55+
%PYTHON% -m pip install %%f ^
56+
--no-build-isolation ^
57+
--no-deps ^
58+
--only-binary :all: ^
59+
--no-index ^
60+
--prefix %PREFIX% ^
61+
-vv
62+
if %ERRORLEVEL% neq 0 exit 1
63+
)
64+
65+
:: Copy wheel package
3566
if NOT "%WHEELS_OUTPUT_FOLDER%"=="" (
36-
rem Install and assemble wheel package from the build bits
37-
"%PYTHON%" setup.py install bdist_wheel --build-number %GIT_DESCRIBE_NUMBER% %SKBUILD_ARGS%
38-
if errorlevel 1 exit 1
3967
copy dist\dpctl*.whl %WHEELS_OUTPUT_FOLDER%
4068
if errorlevel 1 exit 1
41-
) ELSE (
42-
rem Only install
43-
"%PYTHON%" setup.py install %SKBUILD_ARGS%
44-
if errorlevel 1 exit 1
45-
)
46-
47-
if EXIST "%PLATFORM_DIR%" (
48-
rem copy back
49-
copy /Y "%FN%" "%PLATFORM_DIR%\%FN%"
50-
if errorlevel 1 exit 1
5169
)

conda-recipe/build.sh

Lines changed: 60 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,69 @@ echo "--gcc-toolchain=${BUILD_PREFIX} --sysroot=${BUILD_PREFIX}/${HOST}/sysroot
88
export ICPXCFG="$(pwd)/icpx_for_conda.cfg"
99
export ICXCFG="$(pwd)/icpx_for_conda.cfg"
1010

11+
read -r GLIBC_MAJOR GLIBC_MINOR <<<"$(conda list '^sysroot_linux-64$' \
12+
| tail -n 1 | awk '{print $2}' | grep -oP '\d+' | head -n 2 | tr '\n' ' ')"
13+
1114
if [ -e "_skbuild" ]; then
1215
${PYTHON} setup.py clean --all
1316
fi
14-
export CMAKE_GENERATOR="Ninja"
15-
SKBUILD_ARGS="-- -DCMAKE_C_COMPILER:PATH=icx -DCMAKE_CXX_COMPILER:PATH=icpx -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON"
16-
echo "${PYTHON} setup.py install ${SKBUILD_ARGS}"
17-
18-
if [ -n "${WHEELS_OUTPUT_FOLDER}" ]; then
19-
# Install packages and assemble wheel package from built bits
20-
WHEELS_BUILD_ARGS="-p manylinux_2_28_x86_64 --build-number ${GIT_DESCRIBE_NUMBER}"
21-
${PYTHON} setup.py install bdist_wheel ${WHEELS_BUILD_ARGS} ${SKBUILD_ARGS}
22-
cp dist/dpctl*.whl ${WHEELS_OUTPUT_FOLDER}
23-
else
24-
# Perform regular install
25-
${PYTHON} setup.py install ${SKBUILD_ARGS}
17+
18+
export CC=icx
19+
export CXX=icpx
20+
21+
export CMAKE_GENERATOR=Ninja
22+
# Make CMake verbose
23+
export VERBOSE=1
24+
25+
CMAKE_ARGS="${CMAKE_ARGS} -DDPCTL_LEVEL_ZERO_INCLUDE_DIR=${PREFIX}/include/level_zero"
26+
27+
# -wnx flags mean: --wheel --no-isolation --skip-dependency-check
28+
${PYTHON} -m build -w -n -x
29+
30+
pushd dist
31+
${PYTHON} -m wheel unpack -d dpctl_wheel dpctl*.whl
32+
export lib_name=libDPCTLSyclInterface
33+
export so_full_path=$(find dpctl_wheel -regextype posix-extended -regex "^.*${lib_name}\.so")
34+
export sox_full_path=$(find dpctl_wheel -regextype posix-extended -regex "^.*${lib_name}\.so\.[0-9]*$")
35+
export soxxx_full_path=$(find dpctl_wheel -regextype posix-extended -regex "^.*${lib_name}\.so\.[0-9]*\.[0-9]*$")
36+
37+
rm -rf ${so_full_path} ${soxxx_full_path}
38+
39+
export so_name=$(basename ${so_full_path})
40+
export sox_name=$(basename ${sox_full_path})
41+
export soxxx_name=$(basename ${soxxx_full_path})
42+
export wheel_path=$(dirname $(dirname ${so_full_path}))
43+
44+
# deal with hard copies
45+
${PYTHON} -m wheel pack ${wheel_path}
46+
47+
rm -rf dpctl_wheel
48+
popd
49+
50+
${PYTHON} -m wheel tags --remove --build "$GIT_DESCRIBE_NUMBER" \
51+
--platform-tag "manylinux_${GLIBC_MAJOR}_${GLIBC_MINOR}_x86_64" \
52+
dist/dpctl*.whl
53+
54+
${PYTHON} -m pip install dist/dpctl*.whl \
55+
--no-build-isolation \
56+
--no-deps \
57+
--only-binary :all: \
58+
--no-index \
59+
--prefix "${PREFIX}" \
60+
-vv
61+
62+
export libdir=$(find $PREFIX -name 'libDPCTLSyclInterface*' -exec dirname \{\} \;)
63+
64+
# Recover symbolic links
65+
# libDPCTLSyclInterface.so.0 -> libDPCTLSyclInterface.so.0.17
66+
# libDPCTLSyclInterface.so -> libDPCTLSyclInterface.so.0
67+
mv ${libdir}/${sox_name} ${libdir}/${soxxx_name}
68+
ln -s ${libdir}/${soxxx_name} ${libdir}/${sox_name}
69+
ln -s ${libdir}/${sox_name} ${libdir}/${so_name}
70+
71+
# Copy wheel package
72+
if [[ -d "${WHEELS_OUTPUT_FOLDER}" ]]; then
73+
cp dist/dpctl*.whl "${WHEELS_OUTPUT_FOLDER[@]}"
2674
fi
2775

2876
# need to create this folder so ensure that .dpctl-post-link.sh can work correctly

conda-recipe/meta.yaml

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
{% set excluded_compiler_version2 = "2024.0.2" %}
44
{% set excluded_compiler_version3 = "2024.0.3" %}
55

6+
{% set pyproject = load_file_data('pyproject.toml') %}
7+
{% set py_build_deps = pyproject.get('build-system', {}).get('requires', []) %}
8+
69
package:
710
name: dpctl
811
version: {{ GIT_DESCRIBE_TAG }}
@@ -17,26 +20,43 @@ build:
1720
- OVERRIDE_INTEL_IPO # [win]
1821

1922
requirements:
23+
# TODO: keep in sync with /pyproject.toml
2024
build:
2125
- {{ compiler('cxx') }}
2226
- {{ compiler('dpcpp') }} >={{ required_compiler_version }},!={{ excluded_compiler_version1 }},!={{ excluded_compiler_version2 }},!={{ excluded_compiler_version3 }} # [win]
2327
- {{ compiler('dpcpp') }} >={{ required_compiler_version }},!={{ excluded_compiler_version1 }},!={{ excluded_compiler_version2 }} # [linux]
2428
- sysroot_linux-64 >=2.28 # [linux]
2529
host:
26-
- setuptools
27-
- cmake >=3.21
28-
- ninja
29-
- git
30-
- cython
3130
- python
32-
- scikit-build
33-
- numpy
34-
- wheel
31+
- pip >=24.0
32+
- level-zero-devel >=1.16
33+
- pybind11 >=2.12
34+
- {{ pin_compatible('dpcpp-cpp-rt', min_pin='x.x', max_pin='x') }}
35+
# Ensure we are using latest version of setuptools, since we don't need
36+
# editable environments for release.
37+
- setuptools >=69
38+
{% for dep in py_build_deps %}
39+
{% if dep.startswith('ninja') %}
40+
- {{ dep.split(';')[0] }} # [not win]
41+
{% elif dep.startswith('cmake') %}
42+
# We need to pin cmake version on Windows, because we are patching
43+
# cmake files distributed with it.
44+
- cmake=3.26 # [win]
45+
- {{ dep }} # [not win]
46+
{% elif dep.startswith('build>=') %}
47+
- {{ 'python-' ~ dep }}
48+
{% else %}
49+
- {{ dep|replace('_','-') }}
50+
{% endif %}
51+
{% endfor %}
52+
# versioneer dependency
53+
- tomli # [py<311]
3554
run:
3655
- python
56+
- {{ pin_compatible('dpcpp-cpp-rt', min_pin='x.x', max_pin='x') }}
57+
- {{ pin_compatible('intel-cmplr-lib-rt', min_pin='x.x', max_pin='x') }}
3758
- {{ pin_compatible('numpy', min_pin='x.x', max_pin='x') }}
38-
- dpcpp-cpp-rt >={{ required_compiler_version }}
39-
- level-zero # [linux]
59+
- {{ pin_compatible('level-zero', min_pin='x.x', max_pin='x') }} # [linux]
4060

4161
test:
4262
requires:
@@ -67,3 +87,4 @@ extra:
6787
- diptorupd
6888
- oleksandr-pavlyk
6989
- ndgrigorian
90+
- ZzEeKkAa

0 commit comments

Comments
 (0)