Skip to content

Commit a573a72

Browse files
committed
Simplify editable install detection to PEP 610 only
Remove Methods 2 and 3 for detecting editable installs, keeping only PEP 610 (direct_url.json) which is the standard for Python 3.10+ and pip 20.1+. Changes: - Remove Method 2: import cuda.bindings to check repo location (problematic during build requirement phase) - Remove Method 3: .egg-link file detection (obsolete for Python 3.10+) - Keep only PEP 610 method (direct_url.json) which is reliable and doesn't require importing modules during build This fixes build errors caused by importing cuda.bindings during the build requirement phase, which interfered with Cython compilation.
1 parent 6ea0dec commit a573a72

1 file changed

Lines changed: 2 additions & 29 deletions

File tree

cuda_core/build_hooks.py

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,9 @@ def _check_cuda_bindings_installed():
209209
bindings_version = bindings_dist.version
210210
bindings_major_version = bindings_version.split(".")[0]
211211

212-
# Check if it's an editable install
212+
# Check if it's an editable install using PEP 610 (direct_url.json)
213+
# This is the standard method for Python 3.10+ and pip 20.1+
213214
is_editable = False
214-
215-
# Method 1: Check direct_url.json (PEP 610 - modern editable installs)
216215
try:
217216
dist_location = Path(bindings_dist.locate_file(""))
218217
# dist-info or egg-info directory
@@ -226,32 +225,6 @@ def _check_cuda_bindings_installed():
226225
except Exception: # noqa: S110
227226
pass
228227

229-
# Method 2: Check if package is in current repository (another way to detect editable)
230-
if not is_editable:
231-
try:
232-
import cuda.bindings
233-
234-
bindings_path = Path(cuda.bindings.__file__).resolve()
235-
repo_root = Path(__file__).resolve().parent.parent.parent
236-
if repo_root in bindings_path.parents:
237-
is_editable = True
238-
except Exception: # noqa: S110
239-
pass
240-
241-
# Method 3: Check for .egg-link file (old editable install method)
242-
if not is_editable:
243-
try:
244-
# Look for .egg-link files in site-packages
245-
import site
246-
247-
for site_dir in site.getsitepackages():
248-
egg_link_path = Path(site_dir) / "cuda-bindings.egg-link"
249-
if egg_link_path.exists():
250-
is_editable = True
251-
break
252-
except Exception: # noqa: S110
253-
pass
254-
255228
return (True, is_editable, bindings_major_version)
256229

257230

0 commit comments

Comments
 (0)