Show More
@@ -19,21 +19,21 b' from IPython.core.magic import Magics, magics_class, line_magic' | |||||
19 | def _is_conda_environment(): |
|
19 | def _is_conda_environment(): | |
20 | """Return True if the current Python executable is in a conda env""" |
|
20 | """Return True if the current Python executable is in a conda env""" | |
21 | # TODO: does this need to change on windows? |
|
21 | # TODO: does this need to change on windows? | |
22 |
return Path(sys.prefix, |
|
22 | return Path(sys.prefix, "conda-meta", "history").exists() | |
23 |
|
23 | |||
24 |
|
24 | |||
25 | def _get_conda_executable(): |
|
25 | def _get_conda_executable(): | |
26 | """Find the path to the conda executable""" |
|
26 | """Find the path to the conda executable""" | |
27 | # Check if there is a conda executable in the same directory as the Python executable. |
|
27 | # Check if there is a conda executable in the same directory as the Python executable. | |
28 | # This is the case within conda's root environment. |
|
28 | # This is the case within conda's root environment. | |
29 |
conda = Path(sys.executable).parent / |
|
29 | conda = Path(sys.executable).parent / "conda" | |
30 | if conda.isfile(): |
|
30 | if conda.isfile(): | |
31 | return str(conda) |
|
31 | return str(conda) | |
32 |
|
32 | |||
33 | # Otherwise, attempt to extract the executable from conda history. |
|
33 | # Otherwise, attempt to extract the executable from conda history. | |
34 | # This applies in any conda environment. |
|
34 | # This applies in any conda environment. | |
35 | R = re.compile(r"^#\s*cmd:\s*(?P<command>.*conda)\s[create|install]") |
|
35 | R = re.compile(r"^#\s*cmd:\s*(?P<command>.*conda)\s[create|install]") | |
36 |
with open(Path(sys.prefix, |
|
36 | with open(Path(sys.prefix, "conda-meta", "history")) as f: | |
37 | for line in f: |
|
37 | for line in f: | |
38 | match = R.match(line) |
|
38 | match = R.match(line) | |
39 | if match: |
|
39 | if match: |
General Comments 0
You need to be logged in to leave comments.
Login now