Skip to content
Open
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

* Added C API functions for `dpnp.tensor.usm_ndarray` setters and getters to avoid ABI breakage if `dpnp.tensor.usm_ndarray` is modified [gh-2866](https://github.com/IntelPython/dpnp/pull/2866)
* Added `--includes` and `--include-dir` options to the `dpnp` CLI [#2916](https://github.com/IntelPython/dpnp/pull/2916)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra blank line

Suggested change


### Changed
* Changed `dpnp.meshgrid` and `dpnp.tensor.meshgrid` to return a tuple instead of a list, aligning with NumPy 2.5+ behavior and 2025.12 version of the Python array API standard [#2854](https://github.com/IntelPython/dpnp/pull/2854)
Expand Down
17 changes: 17 additions & 0 deletions doc/quick_start_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,23 @@ devices at the same time:
python scripts/build_locally.py --target-cuda --target-hip=gfx90a


Command-Line Interface
======================

The ``python -m dpnp`` command provides options to query include paths
needed for building C++ extensions against dpnp:
Comment on lines +221 to +222
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The ``python -m dpnp`` command provides options to query include paths
needed for building C++ extensions against dpnp:
The ``python -m dpnp`` command provides options to query the include paths
needed when building C++ extensions with dpnp:


.. code-block:: bash

python -m dpnp --includes # print -I flag for dpnp include directory
python -m dpnp --include-dir # print path to dpnp include directory
python -m dpnp --tensor-includes # print -I flag for libtensor include directory
python -m dpnp --tensor-include-dir # print path to libtensor include directory

These options are useful when building pybind11 extensions that use
``dpnp4pybind11.hpp`` or libtensor kernel headers.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be helpful to add an examples:

For example, to compile a C++ extension using dpnp header using the Intel(R) oneAPI DPC++ compiler:

.. code-block:: bash

    icpx -fsycl myextension.cpp $(python -m dpnp --includes) -o myextension.so

Not sure if that works this way, based on docs/doc_sources/api_reference/dpctl_pybind11.rst from dpctl.


Testing
=======

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"""
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"""Prints path to dpnp libtensor include directory"""
"""Returns 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",
Comment thread
vlad-perevezentsev marked this conversation as resolved.
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
Loading