davidhalter / jedi

Awesome autocompletion, static analysis and refactoring library for python
http://jedi.readthedocs.io
Other
5.78k stars 508 forks source link

allow users to set cache_directory via env-var #1965

Closed woutervh closed 11 months ago

woutervh commented 12 months ago

jedi is mostly installed in a virtualenv, but uses $XDG's ~/.cache/jedi , which is a good default / fallback.

Many python tools/libs allow the user to set the cache_dir via env-var: BLACK_CACHE_DIR MYPY_CACHE_DIR RUFF_CACHE_DIR ....

please support an env-var JEDI_CACHE_DIR

davidhalter commented 12 months ago

Why?

woutervh commented 12 months ago

because libraries installed in a virtualenv should not write to hardcoded externals dirs like ~/.cache/jedi. XDG-directories are a very good default, but they should still remain default.

and setting XDG_CACHE_HOME to some project-specific dir only creates other issues.

woutervh commented 12 months ago

and because I want to avoid monkeypatching :)

davidhalter commented 12 months ago

But this does not explain when you would use this?

woutervh commented 11 months ago

I never use jedi directly but subdependencies in many of my projects are.

The whole idea of virtualenvs is to provide a certain isolation from the rest of the system and the ability to run many versions in parallel. Writing to $HOME runs counter to that.

woutervh commented 11 months ago

this does not explain when you would use this?

I'm not understanding your question. I never want a virtualenv-installed python library to write to $HOME.

So when would I use this JEDI_CACHE_DIR? In every project that depends on jedi.

davidhalter commented 11 months ago

But how do you set this? Do you really set this variable by hand in every venv?

woutervh commented 11 months ago

I set env-vars in a .env and pip install autoread-dotenv to automatically process the .env.

see https://autoread-dotenv.readthedocs.io/ ( I wrote this package)

examples:

davidhalter commented 11 months ago

Sorry, this feels not important enough for me. I'm closing.