Skip to content

Commit c1ce491

Browse files
Include libtensor headers in dpnp package distribution (#2915)
This PR fixes missing libtensor headers in the installed dpnp package #2909 During the migration from `dpctl.tensor` to `dpnp.tensor` libtensor header files were not added to `package_data` so they were not included in the final package. This PR adds the missing libtensor include paths to `setup.py`
1 parent db2ee80 commit c1ce491

4 files changed

Lines changed: 47 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ This release is compatible with NumPy 2.4.5.
2929
* Fixed `conda build` command syntax in GitHub workflows and documentation to use `conda-build` [#2888](https://github.com/IntelPython/dpnp/pull/2888)
3030
* 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)
3131
* 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)
32+
* Fixed missing `libtensor` headers in the installed `dpnp` package [#2915](https://github.com/IntelPython/dpnp/pull/2915)
3233

3334
### Security
3435

dpnp/__main__.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,19 @@ def _dpnp_dir() -> str:
3939
return abs_dpnp_dir
4040

4141

42+
def get_include_dir() -> str:
43+
"""Returns path to dpnp include directory containing dpnp4pybind11.hpp"""
44+
return os.path.join(_dpnp_dir(), "backend", "include")
45+
46+
47+
def print_include_flags() -> None:
48+
"""Prints include flags for dpnp headers"""
49+
print("-I " + get_include_dir())
50+
51+
4252
def get_tensor_include_dir() -> str:
4353
"""Prints path to dpnp libtensor include directory"""
44-
dpnp_dir = _dpnp_dir()
45-
libtensor_dir = os.path.join(dpnp_dir, "tensor", "libtensor", "include")
54+
libtensor_dir = os.path.join(_dpnp_dir(), "tensor", "libtensor", "include")
4655
return libtensor_dir
4756

4857

@@ -55,6 +64,16 @@ def print_tensor_include_flags() -> None:
5564
def main() -> None:
5665
"""Main entry-point."""
5766
parser = argparse.ArgumentParser()
67+
parser.add_argument(
68+
"--includes",
69+
action="store_true",
70+
help="Include flags for dpnp headers.",
71+
)
72+
parser.add_argument(
73+
"--include-dir",
74+
action="store_true",
75+
help="Path to dpnp include directory.",
76+
)
5877
parser.add_argument(
5978
"--tensor-includes",
6079
action="store_true",
@@ -68,6 +87,10 @@ def main() -> None:
6887
args = parser.parse_args()
6988
if not sys.argv[1:]:
7089
parser.print_help()
90+
if args.includes:
91+
print_include_flags()
92+
if args.include_dir:
93+
print(get_include_dir())
7194
if args.tensor_includes:
7295
print_tensor_include_flags()
7396
if args.tensor_include_dir:

dpnp/tests/test_cli_options.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,24 @@
22
import sys
33

44

5+
def test_includes():
6+
res = subprocess.run(
7+
[sys.executable, "-m", "dpnp", "--includes"],
8+
capture_output=True,
9+
)
10+
assert res.returncode == 0
11+
assert res.stdout
12+
flags = res.stdout.decode("utf-8")
13+
res = subprocess.run(
14+
[sys.executable, "-m", "dpnp", "--include-dir"],
15+
capture_output=True,
16+
)
17+
assert res.returncode == 0
18+
assert res.stdout
19+
include_dir = res.stdout.decode("utf-8")
20+
assert flags == "-I " + include_dir
21+
22+
523
def test_tensor_includes():
624
res = subprocess.run(
725
[sys.executable, "-m", "dpnp", "--tensor-includes"],

setup.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@
5252
"libdpnp_backend_c.so",
5353
"dpnp_backend_c.lib",
5454
"dpnp_backend_c.dll",
55+
"tensor/libtensor/include/kernels/*.h*",
56+
"tensor/libtensor/include/kernels/*/*.h*",
57+
"tensor/libtensor/include/utils/*.h*",
5558
"tests/*.*",
5659
"tests/tensor/*.py",
5760
"tests/tensor/*/*.py",

0 commit comments

Comments
 (0)