|
22 | 22 |
|
23 | 23 | import numpy as np
|
24 | 24 | import setuptools.command.build_ext as orig_build_ext
|
25 |
| -import setuptools.command.build_py as orig_build_py |
26 | 25 | import setuptools.command.develop as orig_develop
|
27 | 26 | import setuptools.command.install as orig_install
|
28 | 27 | from Cython.Build import cythonize
|
@@ -254,32 +253,35 @@ def run(self):
|
254 | 253 | return super().run()
|
255 | 254 |
|
256 | 255 |
|
257 |
| -class build_py(orig_build_py.build_py): |
258 |
| - def run(self): |
259 |
| - dpctl_src_dir = self.get_package_dir("dpctl") |
260 |
| - dpctl_build_dir = os.path.join(self.build_lib, "dpctl") |
261 |
| - os.makedirs(dpctl_build_dir, exist_ok=True) |
262 |
| - if IS_LIN: |
263 |
| - for fn in glob.glob(os.path.join(dpctl_src_dir, "*.so*")): |
264 |
| - # Check if the file already exists before copying. The check is |
265 |
| - # needed when dealing with symlinks. |
266 |
| - if not os.path.exists( |
267 |
| - os.path.join(dpctl_build_dir, os.path.basename(fn)) |
268 |
| - ): |
269 |
| - shutil.copy( |
270 |
| - src=fn, |
271 |
| - dst=dpctl_build_dir, |
272 |
| - follow_symlinks=False, |
273 |
| - ) |
274 |
| - elif IS_WIN: |
275 |
| - for fn in glob.glob(os.path.join(dpctl_src_dir, "*.lib")): |
276 |
| - shutil.copy(src=fn, dst=dpctl_build_dir) |
277 |
| - |
278 |
| - for fn in glob.glob(os.path.join(dpctl_src_dir, "*.dll")): |
279 |
| - shutil.copy(src=fn, dst=dpctl_build_dir) |
280 |
| - else: |
281 |
| - raise NotImplementedError("Unsupported platform") |
282 |
| - return super().run() |
| 256 | +def get_build_py(orig_build_py): |
| 257 | + class build_py(orig_build_py): |
| 258 | + def run(self): |
| 259 | + dpctl_src_dir = self.get_package_dir("dpctl") |
| 260 | + dpctl_build_dir = os.path.join(self.build_lib, "dpctl") |
| 261 | + os.makedirs(dpctl_build_dir, exist_ok=True) |
| 262 | + if IS_LIN: |
| 263 | + for fn in glob.glob(os.path.join(dpctl_src_dir, "*.so*")): |
| 264 | + # Check if the file already exists before copying. |
| 265 | + # The check is needed when dealing with symlinks. |
| 266 | + if not os.path.exists( |
| 267 | + os.path.join(dpctl_build_dir, os.path.basename(fn)) |
| 268 | + ): |
| 269 | + shutil.copy( |
| 270 | + src=fn, |
| 271 | + dst=dpctl_build_dir, |
| 272 | + follow_symlinks=False, |
| 273 | + ) |
| 274 | + elif IS_WIN: |
| 275 | + for fn in glob.glob(os.path.join(dpctl_src_dir, "*.lib")): |
| 276 | + shutil.copy(src=fn, dst=dpctl_build_dir) |
| 277 | + |
| 278 | + for fn in glob.glob(os.path.join(dpctl_src_dir, "*.dll")): |
| 279 | + shutil.copy(src=fn, dst=dpctl_build_dir) |
| 280 | + else: |
| 281 | + raise NotImplementedError("Unsupported platform") |
| 282 | + return super().run() |
| 283 | + |
| 284 | + return build_py |
283 | 285 |
|
284 | 286 |
|
285 | 287 | class install(orig_install.install):
|
@@ -436,10 +438,10 @@ def run(self):
|
436 | 438 |
|
437 | 439 | def _get_cmdclass():
|
438 | 440 | cmdclass = versioneer.get_cmdclass()
|
| 441 | + cmdclass["build_py"] = get_build_py(cmdclass["build_py"]) |
439 | 442 | cmdclass["install"] = install
|
440 | 443 | cmdclass["develop"] = develop
|
441 | 444 | cmdclass["build_ext"] = build_ext
|
442 |
| - cmdclass["build_py"] = build_py |
443 | 445 | return cmdclass
|
444 | 446 |
|
445 | 447 |
|
|
0 commit comments