Skip to content

Commit f2dc847

Browse files
committed
Switch from setup.py to python -m build
1 parent 4880f9a commit f2dc847

File tree

2 files changed

+70
-38
lines changed

2 files changed

+70
-38
lines changed

conda-recipe/bld.bat

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,22 @@
11
REM A workaround for activate-dpcpp.bat issue to be addressed in 2021.4
2-
SET "LIB=%BUILD_PREFIX%\Library\lib;%BUILD_PREFIX%\compiler\lib;%LIB%"
3-
SET "INCLUDE=%BUILD_PREFIX%\include;%INCLUDE%"
2+
set "LIB=%BUILD_PREFIX%\Library\lib;%BUILD_PREFIX%\compiler\lib;%LIB%"
3+
set "INCLUDE=%BUILD_PREFIX%\include;%INCLUDE%"
44

55
"%PYTHON%" setup.py clean --all
66

77
set "MKLROOT=%PREFIX%/Library"
88
set "TBB_ROOT_HINT=%PREFIX%/Library"
99
set "DPL_ROOT_HINT=%PREFIX%/Library"
1010

11-
set "SKBUILD_ARGS=-G Ninja -- -DCMAKE_C_COMPILER:PATH=icx -DCMAKE_CXX_COMPILER:PATH=icx -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON"
12-
set "SKBUILD_ARGS=%SKBUILD_ARGS% -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON"
13-
1411
REM Overriding IPO is useful for building in resources constrained VMs (public CI)
1512
if DEFINED OVERRIDE_INTEL_IPO (
16-
set "SKBUILD_ARGS=%SKBUILD_ARGS% -DCMAKE_INTERPROCEDURAL_OPTIMIZATION:BOOL=FALSE"
13+
set "CMAKE_ARGS=%CMAKE_ARGS% -DCMAKE_INTERPROCEDURAL_OPTIMIZATION:BOOL=FALSE"
1714
)
1815

19-
FOR %%V IN (17.0.0 17 18.0.0 18 19.0.0 19) DO @(
16+
FOR %%V IN (17.0.0 17 18.0.0 18 19.0.0 19 20.0.0 20 21.0.0 21) DO @(
2017
REM set DIR_HINT if directory exists
2118
IF EXIST "%BUILD_PREFIX%\Library\lib\clang\%%V\" (
22-
SET "SYCL_INCLUDE_DIR_HINT=%BUILD_PREFIX%\Library\lib\clang\%%V"
19+
set "SYCL_INCLUDE_DIR_HINT=%BUILD_PREFIX%\Library\lib\clang\%%V"
2320
)
2421
)
2522

@@ -37,21 +34,37 @@ if EXIST "%PLATFORM_DIR%" (
3734
if errorlevel 1 exit 1
3835
)
3936

40-
if NOT "%WHEELS_OUTPUT_FOLDER%"=="" (
41-
rem Install and assemble wheel package from the build bits
42-
"%PYTHON%" setup.py install bdist_wheel %SKBUILD_ARGS%
43-
if errorlevel 1 exit 1
44-
copy dist\dpnp*.whl %WHEELS_OUTPUT_FOLDER%
45-
if errorlevel 1 exit 1
46-
) ELSE (
47-
rem Only install
48-
"%PYTHON%" setup.py install %SKBUILD_ARGS%
49-
if errorlevel 1 exit 1
37+
set "CC=icx"
38+
set "CXX=icx"
39+
40+
set "CMAKE_GENERATOR=Ninja"
41+
:: Make CMake verbose
42+
set "VERBOSE=1"
43+
44+
%PYTHON% -m build -w -n -x
45+
if %ERRORLEVEL% neq 0 exit 1
46+
47+
:: `pip install dist\numpy*.whl` does not work on windows,
48+
:: so use a loop; there's only one wheel in dist/ anyway
49+
for /f %%f in ('dir /b /S .\dist') do (
50+
%PYTHON% -m wheel tags --remove --build %GIT_DESCRIBE_NUMBER% %%f
51+
if %ERRORLEVEL% neq 0 exit 1
5052
)
5153

52-
rem copy back
53-
if EXIST "%PLATFORM_DIR%" (
54-
rem copy back
55-
copy /Y "%FN%" "%PLATFORM_DIR%\%FN%"
56-
if errorlevel 1 exit 1
54+
:: wheel file was renamed
55+
for /f %%f in ('dir /b /S .\dist') do (
56+
%PYTHON% -m pip install %%f ^
57+
--no-build-isolation ^
58+
--no-deps ^
59+
--only-binary :all: ^
60+
--no-index ^
61+
--prefix %PREFIX% ^
62+
-vv
63+
if %ERRORLEVEL% neq 0 exit 1
64+
)
65+
66+
:: Copy wheel package
67+
if NOT "%WHEELS_OUTPUT_FOLDER%"=="" (
68+
copy dist\dpnp*.whl %WHEELS_OUTPUT_FOLDER%
69+
if %ERRORLEVEL% neq 0 exit 1
5770
)

conda-recipe/build.sh

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,38 @@ export ICPXCFG
1212
ICXCFG="$(pwd)/icpx_for_conda.cfg"
1313
export ICXCFG
1414

15-
export CMAKE_GENERATOR="Ninja"
16-
export TBB_ROOT_HINT=$PREFIX
17-
export DPL_ROOT_HINT=$PREFIX
18-
export MKL_ROOT_HINT=$PREFIX
19-
SKBUILD_ARGS=(-- "-DCMAKE_C_COMPILER:PATH=icx" "-DCMAKE_CXX_COMPILER:PATH=icpx" "-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON")
20-
SKBUILD_ARGS=("${SKBUILD_ARGS[@]}" "-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON")
21-
SKBUILD_ARGS=("${SKBUILD_ARGS[@]}" "-DDPNP_WITH_REDIST:BOOL=ON")
22-
23-
# Build wheel package
24-
WHEELS_BUILD_ARGS=("-p" "manylinux_2_28_x86_64")
25-
if [ -n "${WHEELS_OUTPUT_FOLDER}" ]; then
26-
$PYTHON setup.py install bdist_wheel "${WHEELS_BUILD_ARGS[@]}" "${SKBUILD_ARGS[@]}"
27-
cp dist/dpnp*.whl "${WHEELS_OUTPUT_FOLDER}"
28-
else
29-
$PYTHON setup.py install "${SKBUILD_ARGS[@]}"
15+
read -r GLIBC_MAJOR GLIBC_MINOR <<<"$(conda list '^sysroot_linux-64$' \
16+
| tail -n 1 | awk '{print $2}' | grep -oP '\d+' | head -n 2 | tr '\n' ' ')"
17+
18+
if [ -e "_skbuild" ]; then
19+
${PYTHON} setup.py clean --all
20+
fi
21+
22+
export CC=icx
23+
export CXX=icpx
24+
25+
export CMAKE_GENERATOR=Ninja
26+
# Make CMake verbose
27+
export VERBOSE=1
28+
29+
CMAKE_ARGS="${CMAKE_ARGS} -DDPNP_WITH_REDIST:BOOL=ON"
30+
31+
# -wnx flags mean: --wheel --no-isolation --skip-dependency-check
32+
${PYTHON} -m build -w -n -x
33+
34+
${PYTHON} -m wheel tags --remove --build "$GIT_DESCRIBE_NUMBER" \
35+
--platform-tag "manylinux_${GLIBC_MAJOR}_${GLIBC_MINOR}_x86_64" \
36+
dist/dpnp*.whl
37+
38+
${PYTHON} -m pip install dist/dpnp*.whl \
39+
--no-build-isolation \
40+
--no-deps \
41+
--only-binary :all: \
42+
--no-index \
43+
--prefix "${PREFIX}" \
44+
-vv
45+
46+
# Copy wheel package
47+
if [[ -d "${WHEELS_OUTPUT_FOLDER}" ]]; then
48+
cp dist/dpnp*.whl "${WHEELS_OUTPUT_FOLDER[@]}"
3049
fi

0 commit comments

Comments
 (0)