I've installed my own custom package with -e 'git+https://.....@main#egg=package'. I build my dependencies with pip-tools (pip-compile), and install them with pip-sync.
The package shows as "installed" when I look at the installed packages of the interpreter in Pycharm. But it's contents are not detected, all imports using that package are red, no autocompletion, etc. But, everything works fine, it's only Pycharm, not finding the contents of the installed package, and thus only a "display" or IDE problem. In Pycharm, I can run tests and things, everything works but not the display under "External Libraries", which is important for me, to quickly access this package's content. This worked before, but not anymore, since a few versions... I ignored it a few months, but it's really annoying...so here I am.
The reason why it probably happens: The contents are outside of the site-packages folder - only the .pth files or .dist-somthing files are there, that's why it's recognized as "installed". The package contents are in the src folder of my virtualenv...somehow, Pycharm does not look there (anymore)?
I've updated the installed package to use a pyproject.toml, as I thought this could be the reason, but it was not. I also have latest versions of pip, setuptools and wheel installed.
I could install without -e, but then I would need to pip cache purge before installing an updated version, or I would need to install with a commit hash instead of just main - if possible, I would not go this way.
I could add the path ~/.virtualenv/myenv/src/package-name/ to sources in Pycharm, which is too much manual work...so not this way either if possible.
I tend to open a support case, as it's really an edge case problem.
(yes it is: https://youtrack.jetbrains.com/issue/PY-57566/Support-PEP-660-editable-installs)
It is a bug in Pycharm:
https://youtrack.jetbrains.com/issue/PY-57566/Support-PEP-660-editable-installs
Pycharm cannot (yet) deal with the advanced ways setuptools installs editable packages. Using either one of the following in your to be installed package should help:
use a different build backend in pyproject.toml, for example hatchling.
use compat flag at install time (pip install -e /Users/whoever/dev/my-package --config-settings editable_mode=compat) - this does not work in requirements files, though.
Should solve this problem. DISCLAIMER, I've only tested the hatchling version, works fine for me.
Background/WHY?
In site-packages, the file mypackage-0.6.77.dist-info/direct_url.json contains infos where the editable package can be found. Installed with hatchling, this file just contains a path. With setuptools (both with legacy setup.py or pyproject.toml), it contains a pointer to .pth file, and this is not understood by Pycharm.