Skip to content

Commit

Permalink
fix: don't do package_path search, use sys.path always
Browse files Browse the repository at this point in the history
  • Loading branch information
charles-cooper committed Feb 16, 2024
1 parent 7e2681f commit 9055344
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions boa/interpret.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,20 @@ class BoaImporter(importlib.abc.MetaPathFinder):
def __init__(self):
self._path_lookup = {}

# TODO: replace this with more modern `find_spec()`
def find_module(self, fullname, package_path, target=None):
# note: maybe instead of looping, append path to package_path
path = Path(fullname.replace(".", "/")).with_suffix(".vy")

for prefix in package_path:
# for fullname == "x.y.z"
# prefix looks something like "<...>/site-packages/x"
to_try = Path(prefix).parent / path
for prefix in sys.path:
to_try = Path(prefix) / path

if to_try.exists():
self._path_lookup[fullname] = to_try
return self

return None

# TODO: replace with more modern `exec_module()` and `create_module()`
def load_module(self, fullname):
if fullname in sys.modules:
return sys.modules[fullname]
Expand Down

0 comments on commit 9055344

Please sign in to comment.