Skip to content

Commit

Permalink
BUG: Fix meson build failure due to unchanged inplace auto-generated …
Browse files Browse the repository at this point in the history
…dispatch config headers

  Ensure that the distutils generated config files and wrapped sources,
  derived from dispatch-able sources are consistently generated within the build directory
  when the inplace build option is enabled.

  This change is crucial to prevent conflicts with meson-generated config headers.
  Given that `spin build --clean` does not remove these headers, which
  requires cleaning up the numpy root via `git clean` otherwise
  the build will fails.
  • Loading branch information
seiko2plus committed Aug 20, 2023
1 parent f884cf6 commit e54ed20
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
5 changes: 0 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,6 @@ tools/swig/test/Array.py

# SIMD generated files #
###################################
# config headers of dispatchable sources
*.dispatch.h
# wrapped sources of dispatched targets, e.g. *.dispatch.avx2.c
*.dispatch.*.c
*.dispatch.*.cpp
# _simd module
numpy/core/src/_simd/_simd.dispatch.c
numpy/core/src/_simd/_simd_data.inc
Expand Down
4 changes: 2 additions & 2 deletions numpy/distutils/command/build_clib.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,8 @@ def build_a_library(self, build_info, lib_name, libraries):
dispatch_hpath = os.path.join("numpy", "distutils", "include")
dispatch_hpath = os.path.join(bsrc_dir, dispatch_hpath)
include_dirs.append(dispatch_hpath)

copt_build_src = None if self.inplace else bsrc_dir
# copt_build_src = None if self.inplace else bsrc_dir
copt_build_src = bsrc_dir
for _srcs, _dst, _ext in (
((c_sources,), copt_c_sources, ('.dispatch.c',)),
((c_sources, cxx_sources), copt_cxx_sources,
Expand Down
11 changes: 10 additions & 1 deletion numpy/distutils/command/build_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,16 @@ def build_extension(self, ext):
dispatch_hpath = os.path.join(bsrc_dir, dispatch_hpath)
include_dirs.append(dispatch_hpath)

copt_build_src = None if self.inplace else bsrc_dir
# copt_build_src = None if self.inplace else bsrc_dir
# Always generate the generated config files and dispatch-able sources
# inside the build directory, even if the build option `inplace` is enabled.
# This approach prevents conflicts with Meson-generated config headers.
# Since `spin build --clean` will not remove these headers,
# they might overwrite the generated Meson headers, causing compatibility issues.
# Maintaining separate directories ensures compatibility between
# distutils dispatch config headers and Meson headers, avoiding build disruptions.
# See gh-24450 for more details.
copt_build_src = bsrc_dir
for _srcs, _dst, _ext in (
((c_sources,), copt_c_sources, ('.dispatch.c',)),
((c_sources, cxx_sources), copt_cxx_sources,
Expand Down

0 comments on commit e54ed20

Please sign in to comment.