Skip to content

Commit 26f0ceb

Browse files
committed
Migrate package build to python-build
1 parent 86056f6 commit 26f0ceb

File tree

4 files changed

+73
-28
lines changed

4 files changed

+73
-28
lines changed

conda-recipe/bld.bat

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ set "DPBENCH_SYCL=1"
1717
set "CMAKE_GENERATOR=Ninja"
1818
set "CC=icx"
1919
set "CXX=icx"
20-
21-
"%PYTHON%" setup.py clean --all
20+
:: Make CMake verbose
21+
set "VERBOSE=1"
2222

2323
FOR %%V IN (14.0.0 14 15.0.0 15 16.0.0 16 17.0.0 17) DO @(
2424
REM set DIR_HINT if directory exists
@@ -41,18 +41,41 @@ if EXIST "%PLATFORM_DIR%" (
4141
if errorlevel 1 exit 1
4242
)
4343

44-
@REM TODO: switch to pip build. Currently results in broken binary
45-
@REM %PYTHON% -m pip install --no-index --no-deps --no-build-isolation . -v
44+
:: -wnx flags mean: --wheel --no-isolation --skip-dependency-check
45+
%PYTHON% -m build -w -n -x
46+
if %ERRORLEVEL% neq 0 exit 1
47+
48+
:: `pip install dist\dpbench*.whl` does not work on windows,
49+
:: so use a loop; there's only one wheel in dist/ anyway
50+
for /f %%f in ('dir /b /S .\dist') do (
51+
%PYTHON% -m wheel tags --remove --build %GIT_DESCRIBE_NUMBER% %%f
52+
if %ERRORLEVEL% neq 0 exit 1
53+
)
54+
55+
:: wheel file was renamed
56+
for /f %%f in ('dir /b /S .\dist') do (
57+
%PYTHON% -m pip install %%f ^
58+
--no-build-isolation ^
59+
--no-deps ^
60+
--only-binary :all: ^
61+
--no-index ^
62+
--prefix %PREFIX% ^
63+
-vv
64+
if %ERRORLEVEL% neq 0 exit 1
65+
)
66+
67+
:: Must be consistent with pyproject.toml project.scritps. Currently pip does
68+
:: not allow to ignore scripts installation, so we have to remove them manually.
69+
:: https://github.com/pypa/pip/issues/3980
70+
:: We have to let conda-build manage it for use in order to set proper python
71+
:: path.
72+
:: https://docs.conda.io/projects/conda-build/en/stable/resources/define-metadata.html#python-entry-points
73+
rm %PREFIX%\Scripts\dpbench.exe
74+
75+
:: Copy wheel package
4676
if NOT "%WHEELS_OUTPUT_FOLDER%"=="" (
47-
rem Install and assemble wheel package from the build bits
48-
"%PYTHON%" setup.py install --single-version-externally-managed --record=record.txt bdist_wheel --build-number %GIT_DESCRIBE_NUMBER%
49-
if errorlevel 1 exit 1
5077
copy dist\dpbench*.whl %WHEELS_OUTPUT_FOLDER%
5178
if errorlevel 1 exit 1
52-
) ELSE (
53-
rem Only install
54-
"%PYTHON%" setup.py install --single-version-externally-managed --record=record.txt
55-
if errorlevel 1 exit 1
5679
)
5780

5881
rem copy back

conda-recipe/build.sh

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,30 @@ export CMAKE_GENERATOR="Ninja"
1616
export CC=icx
1717
export CXX=icpx
1818

19-
if [ -e "_skbuild" ]; then
20-
${PYTHON} setup.py clean --all
21-
fi
22-
2319
# TODO: switch to pip build. Currently results in broken binary on Windows
2420
# $PYTHON -m pip install --no-index --no-deps --no-build-isolation . -v
2521

26-
# Build wheel package
27-
if [ -n "${WHEELS_OUTPUT_FOLDER}" ]; then
28-
$PYTHON setup.py install --single-version-externally-managed --record=record.txt bdist_wheel -p manylinux2014_x86_64 --build-number $GIT_DESCRIBE_NUMBER
29-
mkdir -p ${WHEELS_OUTPUT_FOLDER}
30-
cp dist/dpbench*.whl ${WHEELS_OUTPUT_FOLDER}
31-
else
32-
$PYTHON setup.py install --single-version-externally-managed --record=record.txt
22+
# -wnx flags mean: --wheel --no-isolation --skip-dependency-check
23+
${PYTHON} -m build -w -n -x
24+
${PYTHON} -m wheel tags --remove --build "$GIT_DESCRIBE_NUMBER" \
25+
--platform-tag manylinux2014_x86_64 dist/dpbench*.whl
26+
${PYTHON} -m pip install dist/dpbench*.whl \
27+
--no-build-isolation \
28+
--no-deps \
29+
--only-binary :all: \
30+
--no-index \
31+
--prefix ${PREFIX} \
32+
-vv
33+
34+
# Must be consistent with pyproject.toml project.scritps. Currently pip does
35+
# not allow to ignore scripts installation, so we have to remove them manually.
36+
# https://github.com/pypa/pip/issues/3980
37+
# We have to let conda-build manage it for use in order to set proper python
38+
# path.
39+
# https://docs.conda.io/projects/conda-build/en/stable/resources/define-metadata.html#python-entry-points
40+
rm ${PREFIX}/bin/dpbench
41+
42+
# Copy wheel package
43+
if [[ -v WHEELS_OUTPUT_FOLDER ]]; then
44+
cp dist/dpbench*.whl "${WHEELS_OUTPUT_FOLDER[@]}"
3345
fi

conda-recipe/meta.yaml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
{% set pyproject = load_file_data('pyproject.toml') %}
66
{% set py_deps = pyproject.get('project', {}).get('dependencies', []) %}
77
{% set py_build_deps = pyproject.get('build-system', {}).get('requires', []) %}
8+
{% set project_scripts = pyproject.get('project', {}).get('scripts', {}) %}
89

910
package:
1011
name: dpbench
@@ -17,6 +18,10 @@ build:
1718
number: {{ GIT_DESCRIBE_NUMBER }}
1819
script_env:
1920
- WHEELS_OUTPUT_FOLDER
21+
entry_points:
22+
{% for script, module in project_scripts | dictsort %}
23+
- {{ script ~ " = " ~ module }}
24+
{% endfor %}
2025

2126
requirements:
2227
build:
@@ -26,9 +31,15 @@ requirements:
2631
- sysroot_linux-64 >=2.28 # [linux]
2732
host:
2833
- python
34+
- pip
2935
{% for dep in py_build_deps %}
3036
{% if dep.startswith('ninja') %}
3137
- {{ dep.split(';')[0] }} # [not win]
38+
{% elif dep.startswith('cmake') %}
39+
- cmake=3.26 # [win]
40+
- {{ dep }} # [not win]
41+
{% elif dep.startswith('build>=') %}
42+
- {{ 'python-' ~ dep }}
3243
{% else %}
3344
- {{ dep|replace('_','-') }}
3445
{% endif %}
@@ -39,12 +50,8 @@ requirements:
3950
{% endfor %}
4051

4152
test:
42-
requires:
43-
- dpctl
44-
- dpnp
45-
- numba-dpex
46-
- numba
47-
- numpy
53+
commands:
54+
- dpbench --help
4855

4956
about:
5057
home: https://github.com/IntelPython/dpbench

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,15 @@ expected-failure = ["tomlkit"]
5555
"Homepage" = "https://https://github.com/IntelPython/dpbench"
5656

5757
[project.scripts]
58+
# Keep consistent with conda build scripts
5859
dpbench = "dpbench.console.entry:main"
5960

6061
[build-system]
6162
# TODO: make it optional for no sycl build. Workaround: `--no-deps`.
6263
# https://github.com/scikit-build/scikit-build/issues/981
6364
requires = [
65+
"wheel>=0.43",
66+
"build>=1.1",
6467
"setuptools>=63.0.0",
6568
"scikit-build>=0.17.0", # sycl build dep
6669
"ninja>=1.11.1; platform_system!='Windows'", # sycl build dep

0 commit comments

Comments
 (0)