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

Editable installs broken for pth files using ";" instead of newlines #172

Closed
machow opened this issue Jun 26, 2023 · 1 comment
Closed

Comments

@machow
Copy link
Contributor

machow commented Jun 26, 2023

Describe the bug

Currently, griffe uses a regex over pth files that assumes each command is separated by a line break. I'm pretty unfamiliar with pth files, but ran into some issues with editable installs recently, which seem to trace back to pth files using ";" to terminate lines :/.

Here is a pth file I noticed causing issues:

import __editable___quartodoc_0_3_5_dev1_gdba857e_d20230626_finder; __editable___quartodoc_0_3_5_dev1_gdba857e_d20230626_finder.install()

I noticed that...

  • running through griffe.finders._handle_pth_file returned an empty list
  • replacing the ; with a newline caused it to return the two entries pointing to the editable source directory.

I don't know a lot about pth files, but wonder if this is a recent setuptools tweak or something? 😓

@pawamoy
Copy link
Member

pawamoy commented Jun 27, 2023

From the docs at https://docs.python.org/3/library/site.html: "Lines starting with import (followed by space or tab) are executed". Since the docs didn't mention semi-colons, we changed the previous split on ; to a split on \n in this commit: f212dd3. But I guess it's just ambiguous and semi-colons should be supported in executable lines.

So, a fix could be:

for line in path.read_text(encoding="utf8").strip().replace(";", "\n").splitlines(keepends=False):

...hoping that nobody puts ; in the name of directories added to sys.path 🥲

Would you like to submit a PR? This fix plus a test would be perfect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants