|
8 | 8 | import sys |
9 | 9 | import argparse |
10 | 10 | import shutil |
| 11 | +from pathlib import Path |
11 | 12 |
|
12 | 13 | SCRIPT_DIR = os.path.dirname(__file__) |
13 | 14 | ROOT_DIR = os.path.abspath(os.getcwd()) |
@@ -44,40 +45,81 @@ def build_wheels(py_envs=DEFAULT_PY_ENVS, cleanup=True, cmake_options=[]): |
44 | 45 |
|
45 | 46 | with push_env(PATH="%s%s%s" % (path, os.pathsep, os.environ["PATH"])): |
46 | 47 |
|
| 48 | + use_scikit_build_core = True |
| 49 | + if Path(os.getcwd()).joinpath('setup.py').exists(): |
| 50 | + use_scikit_build_core = False |
| 51 | + |
47 | 52 | # Install dependencies |
| 53 | + check_call([pip, "install", "pip", "--upgrade"]) |
48 | 54 | requirements_file = os.path.join(ROOT_DIR, "requirements-dev.txt") |
49 | 55 | if os.path.exists(requirements_file): |
50 | 56 | check_call([pip, "install", "--upgrade", "-r", requirements_file]) |
51 | 57 | check_call([pip, "install", "cmake"]) |
52 | | - check_call([pip, "install", "scikit_build", "--upgrade"]) |
53 | | - check_call([pip, "install", "ninja"]) |
| 58 | + if use_scikit_build_core: |
| 59 | + check_call([pip, "install", "scikit-build-core", "--upgrade"]) |
| 60 | + else: |
| 61 | + check_call([pip, "install", "scikit_build", "--upgrade"]) |
| 62 | + |
| 63 | + check_call([pip, "install", "ninja", "--upgrade"]) |
54 | 64 | check_call([pip, "install", "delvewheel"]) |
55 | 65 |
|
56 | | - build_type = "Release" |
57 | 66 | source_path = ROOT_DIR |
58 | 67 | itk_build_path = os.path.abspath("%s/ITK-win_%s" % (os.path.join(SCRIPT_DIR, '..'), py_env)) |
59 | 68 | print('ITKDIR: %s' % itk_build_path) |
60 | 69 |
|
61 | | - # Generate wheel |
62 | | - check_call([ |
63 | | - python_executable, |
64 | | - "setup.py", "bdist_wheel", |
65 | | - "--build-type", build_type, "-G", "Ninja", |
66 | | - "--", |
67 | | - "-DCMAKE_MAKE_PROGRAM:FILEPATH=%s" % ninja_executable, |
68 | | - "-DITK_DIR:PATH=%s" % itk_build_path, |
69 | | - "-DWRAP_ITK_INSTALL_COMPONENT_IDENTIFIER:STRING=PythonWheel", |
70 | | - "-DSWIG_EXECUTABLE:FILEPATH=%s/Wrapping/Generators/SwigInterface/swig/bin/swig.exe" % itk_build_path, |
71 | | - "-DBUILD_TESTING:BOOL=OFF", |
72 | | - "-DCMAKE_INSTALL_LIBDIR:STRING=lib", |
73 | | - "-DPython3_EXECUTABLE:FILEPATH=%s" % python_executable, |
74 | | - "-DPython3_INCLUDE_DIR:PATH=%s" % python_include_dir, |
75 | | - "-DPython3_INCLUDE_DIRS:PATH=%s" % python_include_dir, |
76 | | - "-DPython3_LIBRARY:FILEPATH=%s" % python_library |
77 | | - ] + cmake_options) |
78 | | - # Cleanup |
79 | | - if cleanup: |
80 | | - check_call([python_executable, "setup.py", "clean"]) |
| 70 | + if use_scikit_build_core: |
| 71 | + minor_version = py_env.split("-")[0][1:] |
| 72 | + if int(minor_version) >= 11: |
| 73 | + # Stable ABI |
| 74 | + wheel_py_api = "cp3%s" % minor_version |
| 75 | + else: |
| 76 | + wheel_py_api = "" |
| 77 | + # Generate wheel |
| 78 | + check_call([ |
| 79 | + python_executable, |
| 80 | + "-m", "pip", |
| 81 | + "--verbose", |
| 82 | + "wheel", |
| 83 | + "--wheel-dir", "dist", |
| 84 | + "--no-deps", |
| 85 | + "--config-settings=wheel.py-api=%s" % wheel_py_api, |
| 86 | + "--config-settings=cmake.define.SKBUILD:BOOL=ON", |
| 87 | + "--config-settings=cmake.define.PY_SITE_PACKAGES_PATH:PATH=.", |
| 88 | + "--config-settings=cmake.define.ITK_DIR:PATH=%s" % itk_build_path, |
| 89 | + "--config-settings=cmake.define.WRAP_ITK_INSTALL_COMPONENT_IDENTIFIER:STRING=PythonWheel", |
| 90 | + "--config-settings=cmake.define.SWIG_EXECUTABLE:FILEPATH=%s/Wrapping/Generators/SwigInterface/swig/bin/swig.exe" % itk_build_path, |
| 91 | + "--config-settings=cmake.define.BUILD_TESTING:BOOL=OFF", |
| 92 | + "--config-settings=cmake.define.CMAKE_INSTALL_LIBDIR:STRING=lib", |
| 93 | + "--config-settings=cmake.define.Python3_EXECUTABLE:FILEPATH=%s" % python_executable, |
| 94 | + "--config-settings=cmake.define.Python3_INCLUDE_DIR:PATH=%s" % python_include_dir, |
| 95 | + "--config-settings=cmake.define.Python3_INCLUDE_DIRS:PATH=%s" % python_include_dir, |
| 96 | + "--config-settings=cmake.define.Python3_LIBRARY:FILEPATH=%s" % python_library, |
| 97 | + "--config-settings=cmake.define.Python3_SABI_LIBRARY:FILEPATH=%s" % python_library, |
| 98 | + ] + [o.replace('-D', '--config-settings=cmake.define.') for o in cmake_options] + ['.',]) |
| 99 | + else: |
| 100 | + # scikit-build classic |
| 101 | + build_type = "Release" |
| 102 | + |
| 103 | + # Generate wheel |
| 104 | + check_call([ |
| 105 | + python_executable, |
| 106 | + "setup.py", "bdist_wheel", |
| 107 | + "--build-type", build_type, "-G", "Ninja", |
| 108 | + "--", |
| 109 | + "-DCMAKE_MAKE_PROGRAM:FILEPATH=%s" % ninja_executable, |
| 110 | + "-DITK_DIR:PATH=%s" % itk_build_path, |
| 111 | + "-DWRAP_ITK_INSTALL_COMPONENT_IDENTIFIER:STRING=PythonWheel", |
| 112 | + "-DSWIG_EXECUTABLE:FILEPATH=%s/Wrapping/Generators/SwigInterface/swig/bin/swig.exe" % itk_build_path, |
| 113 | + "-DBUILD_TESTING:BOOL=OFF", |
| 114 | + "-DCMAKE_INSTALL_LIBDIR:STRING=lib", |
| 115 | + "-DPython3_EXECUTABLE:FILEPATH=%s" % python_executable, |
| 116 | + "-DPython3_INCLUDE_DIR:PATH=%s" % python_include_dir, |
| 117 | + "-DPython3_INCLUDE_DIRS:PATH=%s" % python_include_dir, |
| 118 | + "-DPython3_LIBRARY:FILEPATH=%s" % python_library |
| 119 | + ] + cmake_options) |
| 120 | + # Cleanup |
| 121 | + if cleanup: |
| 122 | + check_call([python_executable, "setup.py", "clean"]) |
81 | 123 |
|
82 | 124 | def rename_wheel_init(py_env, filepath): |
83 | 125 | """ |
|
0 commit comments