diff --git a/CHANGELOG.md b/CHANGELOG.md index dd3031c6547..2a738267346 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ This release is compatible with NumPy 2.4.5. * Fixed `conda build` command syntax in GitHub workflows and documentation to use `conda-build` [#2888](https://github.com/IntelPython/dpnp/pull/2888) * Fixed incorrect `dpnp.tensor.acosh` result for `complex(±0, NaN)` special case to match the Python Array API specification [#2914](https://github.com/IntelPython/dpnp/pull/2914) * Fixed fork PR documentation workflow failures by implementing conditional publishing strategy: upstream PRs publish to GitHub Pages with comment, fork PRs upload artifacts [#2910](https://github.com/IntelPython/dpnp/pull/2910) +* Fixed missing `libtensor` headers in the installed `dpnp` package [#2915](https://github.com/IntelPython/dpnp/pull/2915) ### Security diff --git a/dpnp/__main__.py b/dpnp/__main__.py index 1c9c652109e..349ffcd472f 100644 --- a/dpnp/__main__.py +++ b/dpnp/__main__.py @@ -39,10 +39,19 @@ def _dpnp_dir() -> str: return abs_dpnp_dir +def get_include_dir() -> str: + """Returns path to dpnp include directory containing dpnp4pybind11.hpp""" + return os.path.join(_dpnp_dir(), "backend", "include") + + +def print_include_flags() -> None: + """Prints include flags for dpnp headers""" + print("-I " + get_include_dir()) + + def get_tensor_include_dir() -> str: """Prints path to dpnp libtensor include directory""" - dpnp_dir = _dpnp_dir() - libtensor_dir = os.path.join(dpnp_dir, "tensor", "libtensor", "include") + libtensor_dir = os.path.join(_dpnp_dir(), "tensor", "libtensor", "include") return libtensor_dir @@ -55,6 +64,16 @@ def print_tensor_include_flags() -> None: def main() -> None: """Main entry-point.""" parser = argparse.ArgumentParser() + parser.add_argument( + "--includes", + action="store_true", + help="Include flags for dpnp headers.", + ) + parser.add_argument( + "--include-dir", + action="store_true", + help="Path to dpnp include directory.", + ) parser.add_argument( "--tensor-includes", action="store_true", @@ -68,6 +87,10 @@ def main() -> None: args = parser.parse_args() if not sys.argv[1:]: parser.print_help() + if args.includes: + print_include_flags() + if args.include_dir: + print(get_include_dir()) if args.tensor_includes: print_tensor_include_flags() if args.tensor_include_dir: diff --git a/dpnp/tests/test_cli_options.py b/dpnp/tests/test_cli_options.py index 0caca95f397..1d353e9fddf 100644 --- a/dpnp/tests/test_cli_options.py +++ b/dpnp/tests/test_cli_options.py @@ -2,6 +2,24 @@ import sys +def test_includes(): + res = subprocess.run( + [sys.executable, "-m", "dpnp", "--includes"], + capture_output=True, + ) + assert res.returncode == 0 + assert res.stdout + flags = res.stdout.decode("utf-8") + res = subprocess.run( + [sys.executable, "-m", "dpnp", "--include-dir"], + capture_output=True, + ) + assert res.returncode == 0 + assert res.stdout + include_dir = res.stdout.decode("utf-8") + assert flags == "-I " + include_dir + + def test_tensor_includes(): res = subprocess.run( [sys.executable, "-m", "dpnp", "--tensor-includes"], diff --git a/setup.py b/setup.py index 3f544966350..1193b61ac2a 100644 --- a/setup.py +++ b/setup.py @@ -52,6 +52,9 @@ "libdpnp_backend_c.so", "dpnp_backend_c.lib", "dpnp_backend_c.dll", + "tensor/libtensor/include/kernels/*.h*", + "tensor/libtensor/include/kernels/*/*.h*", + "tensor/libtensor/include/utils/*.h*", "tests/*.*", "tests/tensor/*.py", "tests/tensor/*/*.py",