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 modules installed by uv aren't found #731

Closed
krmax44 opened this issue Oct 2, 2024 · 6 comments
Closed

Editable modules installed by uv aren't found #731

krmax44 opened this issue Oct 2, 2024 · 6 comments
Labels
awaiting response waiting for more info from the author - will eventually close if they don't respond

Comments

@krmax44
Copy link

krmax44 commented Oct 2, 2024

I'm using uv as my package manager. When I install modules as editable (with -e), the module cannot be resolved by Pyright: Import mymodule could not be resolved. basedpyright(reportMissingImports)

With verbose output enabled, there is one potentially interesting message logged:

Skipping '__editable__.mymodule-1.0.0.finder.__path_hook__' because it is not a valid directory

uv does seem to create a .pth though. In this case, it's located at .venv/lib/python3.12/site-packages/__editable__.mymodule-1.0.0.pth and contains:

import __editable___mymodule_1_0_0_finder; __editable___mymodule_1_0_0_finder.install()

The referenced module contains the MAPPING and NAMESPACES.

When I install the module without -e, the types are found.

@DetachHead DetachHead added the needs investigation awaiting verification by a maintainer that the issue is valid label Oct 2, 2024
@DetachHead
Copy link
Owner

i'm not really familiar with how editable packages work, but i wasn't able to reproduce the issue by running uv pip install -e . on my project

  • what command are you running exactly?
  • what's your pyproject.toml & project structure look like?
  • how are you running basedpyright? CLI (if so, what command?) or language server (if so, which editor?)
  • are you able to check if the issue also occurs in pyright?

thanks

@DetachHead DetachHead added awaiting response waiting for more info from the author - will eventually close if they don't respond and removed needs investigation awaiting verification by a maintainer that the issue is valid labels Oct 3, 2024
@krmax44
Copy link
Author

krmax44 commented Oct 3, 2024

Sorry, should have been more specific here. It's happening when installing another package as editable, like uv pip install -e /my/project/somewhere. I'm using basedpyright in VS Codium with the Pylance language server. I have nothing regarding basedpyright in my pyproject.toml, the only thing configured is type checking set to basic via VS Code.

@DetachHead DetachHead added needs investigation awaiting verification by a maintainer that the issue is valid and removed awaiting response waiting for more info from the author - will eventually close if they don't respond labels Oct 11, 2024
@DetachHead
Copy link
Owner

hmm, i'm still not able to reproduce it. according to the documentation about editable installs, it should work as long as it uses .pth files with file paths in them, which as far as i can tell is what uv already does by default.

after you install the package as editable, can you try restarting the language server and see if the issue persists? (F1 > "Tasks: Run Task" > "basedpyright: Restart Server")

@DetachHead DetachHead added language server awaiting response waiting for more info from the author - will eventually close if they don't respond and removed needs investigation awaiting verification by a maintainer that the issue is valid labels Oct 12, 2024
@DetachHead
Copy link
Owner

oh wait i think i misunderstood how this works.

that config is specified on the build backend, as in the build tool on the package you're installing rather than what you're installing it with. from my understanding uv does not have a build backend yet (astral-sh/uv#3957), so the way to get your package to work with (based)pyright depends on whatever build backend it uses. hope the documentation i linked in the previous comment helps

@DetachHead
Copy link
Owner

closing this as i'm pretty sure my comment above explains the situation. i also clarified the docs in #770.

let us know if you're still having issues and we can re-open this if needed

@DetachHead DetachHead closed this as not planned Won't fix, can't repro, duplicate, stale Oct 18, 2024
@krmax44
Copy link
Author

krmax44 commented Oct 21, 2024

Thanks, that works perfectly. Just to leave the solution right here, one can use either uv pip install -e /path/to/module --config-setting editable_mode=compat or set an option in the pyproject.toml.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting response waiting for more info from the author - will eventually close if they don't respond
Projects
None yet
Development

No branches or pull requests

2 participants