Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug[next]: Use same python in CMake as used for execution #1567

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
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: 1 addition & 1 deletion src/gt4py/_core/definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
BOOL_TYPES: Final[Tuple[type, ...]] = cast(Tuple[type, ...], BoolScalar.__args__) # type: ignore[attr-defined]


IntScalar: TypeAlias = Union[int8, int16, int32, int64, int]
Copy link
Contributor

Choose a reason for hiding this comment

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

is this intentional in this PR? If yes, that's not the right solution.

IntScalar: TypeAlias = Union[int8, int16, int32, int64, np.longlong, int]
IntT = TypeVar("IntT", bound=IntScalar)
INT_TYPES: Final[Tuple[type, ...]] = cast(Tuple[type, ...], IntScalar.__args__) # type: ignore[attr-defined]

Expand Down
2 changes: 1 addition & 1 deletion src/gt4py/next/iterator/embedded.py
Original file line number Diff line number Diff line change
Expand Up @@ -1027,7 +1027,7 @@ def _maker(a) -> common.Field:
ranges = []
for d, s in zip(axes, a.shape):
offset = origin.get(d, 0)
ranges.append(common.UnitRange(-offset, s - offset))
ranges.append(common.UnitRange(offset, s + offset))

res = common.field(a, domain=common.Domain(dims=tuple(axes), ranges=tuple(ranges)))
return res
Expand Down
20 changes: 19 additions & 1 deletion src/gt4py/next/otf/compilation/build_systems/cmake_lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,25 @@ def visit_FindDependency(self, dep: FindDependency):
case "nanobind":
import nanobind

py = "find_package(Python COMPONENTS Interpreter Development REQUIRED)"
import sys
import sysconfig

# Get Python executable path
python_executable = sys.executable

# Get Python library path
python_library = sysconfig.get_config_var('LIBDIR') + '/' + sysconfig.get_config_var('LDLIBRARY')
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a suggestion:

Suggested change
python_library = sysconfig.get_config_var('LIBDIR') + '/' + sysconfig.get_config_var('LDLIBRARY')
python_library = f"{sysconfig.get_config_var('LIBDIR')}/{sysconfig.get_config_var('LDLIBRARY')}"


# Get Python include directory path
python_include_dir = sysconfig.get_path('include')

py = f"""
set(Python_EXECUTABLE {python_executable})
#set(Python_LIBRARY {python_library})
#set(Python_INCLUDE_DIR {python_include_dir})

find_package(Python COMPONENTS Interpreter Development REQUIRED)
"""
nb = f"find_package(nanobind CONFIG REQUIRED PATHS {nanobind.cmake_dir()} NO_DEFAULT_PATHS)"
return py + "\n" + nb
case "gridtools_cpu" | "gridtools_gpu":
Expand Down