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

Fix converting of editable package #288

Merged
merged 16 commits into from
Aug 2, 2023
4 changes: 4 additions & 0 deletions src/npe2/__main__.py
Copy link
Collaborator Author

@Czaki Czaki May 24, 2023

Choose a reason for hiding this comment

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

I have added this file to simplify debugging my allow run by python -m npe2

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from npe2.cli import main

if __name__ == "__main__":
main()
8 changes: 7 additions & 1 deletion src/npe2/_inspection/_from_npe1.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,13 @@ def get_top_module_path(package_name, top_module: Optional[str] = None) -> Path:
top_module = top_mods[0]

path = Path(dist.locate_file(top_module))
assert path.is_dir()
if not path.is_dir():
for f_path in dist.files:
if "__editable__" in f_path.name:
path = Path(f_path.read_text().strip()) / top_module
break
Copy link
Member

Choose a reason for hiding this comment

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

@Czaki I have zero context here so take my review with a grain of salt, but if there are no tests here, could you at least add comments about why these lines are needed? eg "if the given npe1 plugin is installed in editable mode, then X doesn't work so we must do Y"


assert path.is_dir(), f"Could not find top level module {top_module} using {path}"
return path


Expand Down