necaris / conda.el

Emacs helper library (and minor mode) to work with conda environments
MIT License
153 stars 49 forks source link

Purpose of `conda--get-path-prefix` #72

Closed arthurcgusmao closed 2 years ago

arthurcgusmao commented 4 years ago

Hi, recently I was digging into the code and found that conda--get-path-prefix seems to perform the exact same thing that

(concat (file-name-as-directory env-dir) conda-env-executables-dir)

would for the same valid env-dir.

Example:

(conda--get-path-prefix "/path/to/anywhere")
;; outputs the same as
(concat (file-name-as-directory "/path/to/anywhere") conda-env-executables-dir)
;; given that "/path/to/anywhere" is a path to a valid directory

Since conda--get-path-prefix already makes use of conda-env-executables-dir to find the proper path to the conda command, it doesn't seem to make sense such a more complicated check performed inside of the function.

Can someone explain this further?

necaris commented 4 years ago

It's mostly true that right now conda--get-path-prefix simply returns the executable directory within the env directory (I seem to recall it does something different on Windows, but I may be misremembering). The intent, however, is to be robust to any changes in how conda handles this; hence the call out to conda ..activate to return the information, if conda should change formats.

If we can be sure that the behavior will be consistent on Windows and other platforms I have no objections to changing how it's used or implemented.

necaris commented 2 years ago

Hopefully closed by #23