Editable installs don't expose `__version__`, break pylint
jacobtylerwalls opened this issue · 4 comments
Steps to reproduce
- pip install -e astroid
- pylint --version
Current behavior
Traceback (most recent call last):
File "/Users/jwalls/release/bin/pylint", line 8, in <module>
sys.exit(run_pylint())
^^^^^^^^^^^^
File "/Users/jwalls/pylint/pylint/__init__.py", line 31, in run_pylint
from pylint.lint import Run as PylintRun
File "/Users/jwalls/pylint/pylint/lint/__init__.py", line 20, in <module>
from pylint.lint.caching import load_results, save_results
File "/Users/jwalls/pylint/pylint/lint/caching.py", line 12, in <module>
from pylint.constants import PYLINT_HOME
File "/Users/jwalls/pylint/pylint/constants.py", line 62, in <module>
astroid {astroid.__version__}
Expected behavior
pylint 3.1.0-dev0
astroid 3.0.3
Python 3.11.7 (v3.11.7:fa7a6f2303, Dec 4 2023, 15:22:56) [Clang 13.0.0 (clang-1300.0.29.30)]
Notes
Has prevented me from using pre-commit for a couple years now.
Environment
setuptools==69.0.3
Have you tried this?
pip install -e astroid -C editable_mode=compat
Thanks, that did it!
Do you think we should update the contributor docs or apply a patch like we did for pylint?
Do you think we should update the contributor docs or apply a patch like we did for pylint?
Tbh I haven't looked into how / why the patch works. Using -C editable_mode=compat
was always enough for me, so I didn't question it further.
Workaround was inspired from this comment.
As I understand it, you aren't guaranteed the ability to import things off the module itself (e.g. astroid.version, astroid.exceptions) after a bare import astroid
without it. I think it's worth a patch; we want astroid to be easier to contribute to!