Show More
@@ -19,21 +19,21 b' from IPython.core.magic import Magics, magics_class, line_magic' | |||
|
19 | 19 | def _is_conda_environment(): |
|
20 | 20 | """Return True if the current Python executable is in a conda env""" |
|
21 | 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 | 25 | def _get_conda_executable(): |
|
26 | 26 | """Find the path to the conda executable""" |
|
27 | 27 | # Check if there is a conda executable in the same directory as the Python executable. |
|
28 | 28 | # This is the case within conda's root environment. |
|
29 |
conda = Path(sys.executable).parent / |
|
|
29 | conda = Path(sys.executable).parent / "conda" | |
|
30 | 30 | if conda.isfile(): |
|
31 | 31 | return str(conda) |
|
32 | 32 | |
|
33 | 33 | # Otherwise, attempt to extract the executable from conda history. |
|
34 | 34 | # This applies in any conda environment. |
|
35 | 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 | 37 | for line in f: |
|
38 | 38 | match = R.match(line) |
|
39 | 39 | if match: |
General Comments 0
You need to be logged in to leave comments.
Login now