-
Notifications
You must be signed in to change notification settings - Fork 763
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
uv pip install -e
and its PEP-660-style editable installs break vscode import resolution (and probably static type checkers)
#3898
Comments
To be honest I am bit confused. Pip passess the implementation responsability of editable installs to the backend: https://pip.pypa.io/en/stable/topics/local-project-installs/#editable-installs Doesn't uv does the same? For packages built with setuptools there are a coupe of configuration options used at installation time. That said, I am not sure if the latest version of setuptools works the way that OP proposes here anymore. For reference, when building with hatch works with the default that allows static analysis tools to work by default: Any chance a mantainer could chime in, clarify the state of affairs and say whether this is:
|
I agree this issue is not clear. I'm not the expert on this area, but a
This seems like a problem with
It seems possible that you're getting different versions of setuptools depending on if you're using uv or pip? Having you tried using |
This is a known problem with setuptools: pypa/setuptools#3518, it also affects e.g. mypy: python/mypy#13392. It's unfortunately not something we can do anything about, i recommend using one of the workarounds in the linked issues or switching to a different backend such as hatchling or flit. |
Why not offer a way to do an editable install using the classic static resolution (egg-link) instead of the dynamic one? A while ago I noticed that I never really looked into alternative build backends, but I assume this also means changing all the related configs (setup.cfg etc.) in the project, which is a mess if you have many projects and you either end up with one using something different than all the others, or having to update all of them for consistency... |
The old egg mechanism was never standardized and is basically pip-setuptools special casing; in uv, we support PEP 660, the standard editable installs that work across build backends. Pip has also deprecated its current behavior and will remove it in the 25.0 release (pypa/pip#11457). |
…all (#24029) ## Summary & Motivation After wiping my pyright & base virtual envs, I was unable to get pyright working, hitting [strange errors that dagster imports were not found](https://dagsterlabs.slack.com/archives/C03A0D72A6T/p1724874346772169): ```python /Users/ben/repos/dagster/python_modules/libraries/dagster-shell/dagster_shell/__init__.py: 1:5: Import "dagster._core.libraries" could not be resolved (reportMissingImports) ``` Some Googling turned up that there are [multiple ways to install editable packages](astral-sh/uv#3898) & the default behavior of `uv pip install` is to not install packages in compat mode, which pyright requires. We [explicitly opt in in our pyright venv building code](https://github.com/dagster-io/dagster/blob/master/scripts/run-pyright.py#L304), but I'm wondering if my base editable installs not using compat mode has some bleed-over to my pyright venv (e.g. the editable install is shared)? Either way, making this change, rerunning `make dev_install` and then rerunning `make rebuild_pyright` seemed to fix my issues. ## Changelog [Bug] `NOCHANGELOG`
My context is that I have a main package and some related packages. Everything is installed in editable mode for development.
When using standard
pip
with setuptools installed, this creates an egg-link file inside site-packages which is looked up just fine by type checkers including Pyright (which powers the vscode Python/Pylance extension).However, when using
uv pip install -e
, the package is installed in PEP-660 mode with a__editable__.<pkgname+version>.pth
and__editable___<pkgname+version>_finder.py
, ie using a dynamic import hook.Of course static analyzers generally do not understand those, and don't even try to extract the information from the "dynamic" code even though it would be trivial to do (by simply parsing the
MAPPING
dict from the..._finder.py
).While this is not directly uv's fault, and I generally agree with not outputting legacy stuff, this is causing a problem when IDEs can no longer properly resolve imports. And at least the pyright/pylance developers don't seem to be willing to add any workarounds on their side, so they'd rather wait for the Python ecosystem to agree on something that does not require dynamic import lookups. But that probably needs someone to be willing to write a PEP and get it accepted which all takes some time.
Some related issues/comments:
reportMissingModuleSource
microsoft/pyright#3880 (comment)Import could not be resolved
with[tool.setuptools.package-dir]
microsoft/pylance-release#5894 (comment)Is there any chance
uv
can do something about this, such as providing an option to generate an egg-link instead of a PEP660-style__editable__*.pth
, even though it's slightly more legacy?The text was updated successfully, but these errors were encountered: