Skip to content

Commit 3cc22ba

Browse files
committed
fix: support editable installs and Ninja in conda Windows builds
Find installed data next to a compiled module, since editable installs keep Python files in the source tree. Clear the VS generator platform and toolset in bld.bat, which Ninja rejects. Assisted-by: ClaudeCode:claude-opus-5-5
1 parent b6b54cf commit 3cc22ba

6 files changed

Lines changed: 18 additions & 4 deletions

File tree

‎conda-recipe-cf/bld.bat‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ set "CC=icx"
2020
set "CXX=icx"
2121

2222
set "CMAKE_GENERATOR=Ninja"
23+
:: Set by the VS activation, but not supported by Ninja
24+
set "CMAKE_GENERATOR_PLATFORM="
25+
set "CMAKE_GENERATOR_TOOLSET="
2326
:: Make CMake verbose
2427
set "VERBOSE=1"
2528

‎conda-recipe/bld.bat‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ set "CC=icx"
1818
set "CXX=icx"
1919

2020
set "CMAKE_GENERATOR=Ninja"
21+
:: Set by the VS activation, but not supported by Ninja
22+
set "CMAKE_GENERATOR_PLATFORM="
23+
set "CMAKE_GENERATOR_TOOLSET="
2124
:: Make CMake verbose
2225
set "VERBOSE=1"
2326

‎dpctl/__init__.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,10 @@ def get_include():
148148
Extension modules that need to be compiled against dpctl should use
149149
this function to locate the appropriate include directory.
150150
"""
151-
return os.path.join(os.path.dirname(__file__), "include")
151+
# Not __file__: editable installs keep Python files in the source tree
152+
from . import _sycl_context
153+
154+
return os.path.join(os.path.dirname(_sycl_context.__file__), "include")
152155

153156

154157
del _init_helper

‎dpctl/__main__.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424

2525

2626
def _dpctl_dir() -> str:
27-
dpctl_dir = importlib.util.find_spec("dpctl").submodule_search_locations[0]
27+
# Compiled modules are next to the installed data, also in editable mode
28+
origin = importlib.util.find_spec("dpctl._sycl_context").origin
29+
dpctl_dir = os.path.dirname(origin)
2830
abs_dpctl_dir = os.path.abspath(dpctl_dir)
2931
return abs_dpctl_dir
3032

‎dpctl/_init_helper.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17+
import importlib.util
1718
import os
1819
import os.path
1920
import sys
@@ -24,7 +25,9 @@
2425

2526
if sys.platform == "win32": # pragma: no cover
2627
# Include folder containing DPCTLSyclInterface.dll to search path
27-
os.add_dll_directory(os.path.dirname(__file__))
28+
# Not __file__: editable installs keep Python files in the source tree
29+
_origin = importlib.util.find_spec("dpctl._sycl_context").origin
30+
os.add_dll_directory(os.path.dirname(_origin))
2831
if is_venv:
2932
# For virtual environments on Windows, add folder
3033
# with DPC++ libraries to the DLL search path gh-1745

‎dpctl/tests/test_service.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def should_skip_syclinterface(request):
156156

157157

158158
def test_syclinterface(should_skip_syclinterface):
159-
install_dir = os.path.dirname(os.path.abspath(dpctl.__file__))
159+
install_dir = os.path.dirname(dpctl.get_include())
160160
paths = glob.glob(os.path.join(install_dir, "*DPCTLSyclInterface*"))
161161
if "linux" in sys.platform:
162162
if should_skip_syclinterface:

0 commit comments

Comments
 (0)