Skip to content

Commit

Permalink
Fix issue with Meson + editable mode (at least for Pythran)
Browse files Browse the repository at this point in the history
  • Loading branch information
paugier committed Feb 14, 2024
1 parent c6e17df commit 3765204
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
16 changes: 14 additions & 2 deletions src/transonic/aheadoftime.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import os
import functools
import sys
from importlib import import_module

from transonic.backends import backends, get_backend_name_module
from transonic.config import has_to_replace, backend_default
Expand Down Expand Up @@ -236,9 +237,20 @@ def __init__(
path_mod.parent / f"__{backend.name}__" / (module_short_name + suffix)
)

path_ext = None
# for Meson, we try to import module_backend_name
try:
_module_backend = import_module(module_backend_name)
except ImportError:
path_ext = None
else:
if backend.check_if_compiled(_module_backend):
path_ext = Path(_module_backend.__file__)
if not path_ext.exists():
path_ext = None
else:
path_ext = None

if has_to_compile_at_import() and path_mod.exists():
if has_to_compile_at_import() and path_mod.exists() and path_ext is None:
if mpi.has_to_build(path_backend, path_mod):
if path_backend.exists():
time_backend = mpi.modification_date(path_backend)
Expand Down
7 changes: 6 additions & 1 deletion src/transonic/backends/py.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,12 @@ def compile_extension(
if name_ext_file is None:
name_ext_file = self.name_ext_from_path_backend(path_backend)

copyfile(path_backend, path_backend.with_name(name_ext_file))
if not path_backend.exists():
raise IOError("not path_backend.exists()")

path_ext = path_backend.with_name(name_ext_file)
if path_backend != path_ext:
copyfile(path_backend, path_ext)
compiling = False
process = None
return compiling, process

0 comments on commit 3765204

Please sign in to comment.