Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
27 changes: 25 additions & 2 deletions dpnp/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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",
Expand All @@ -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:
Expand Down
18 changes: 18 additions & 0 deletions dpnp/tests/test_cli_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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*",
Comment thread
vlad-perevezentsev marked this conversation as resolved.
"tensor/libtensor/include/utils/*.h*",
"tests/*.*",
"tests/tensor/*.py",
"tests/tensor/*/*.py",
Expand Down
Loading