##// END OF EJS Templates
BUG: `isfile` is not a method on Path objects...
farisachugthai -
Show More
@@ -13,7 +13,6 b' import shlex'
13 import sys
13 import sys
14 from pathlib import Path
14 from pathlib import Path
15
15
16 from pathlib import Path
17 from IPython.core.magic import Magics, magics_class, line_magic
16 from IPython.core.magic import Magics, magics_class, line_magic
18
17
19
18
@@ -28,7 +27,7 b' def _get_conda_executable():'
28 # 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.
29 # This is the case within conda's root environment.
28 # This is the case within conda's root environment.
30 conda = Path(sys.executable).parent / "conda"
29 conda = Path(sys.executable).parent / "conda"
31 if conda.isfile():
30 if conda.is_file():
32 return str(conda)
31 return str(conda)
33
32
34 # Otherwise, attempt to extract the executable from conda history.
33 # Otherwise, attempt to extract the executable from conda history.
@@ -41,7 +40,7 b' def _get_conda_executable():'
41 )
40 )
42 if match:
41 if match:
43 return match.groupdict()["command"]
42 return match.groupdict()["command"]
44
43
45 # Fallback: assume conda is available on the system path.
44 # Fallback: assume conda is available on the system path.
46 return "conda"
45 return "conda"
47
46
@@ -73,14 +72,14 b' class PackagingMagics(Magics):'
73 @line_magic
72 @line_magic
74 def conda(self, line):
73 def conda(self, line):
75 """Run the conda package manager within the current kernel.
74 """Run the conda package manager within the current kernel.
76
75
77 Usage:
76 Usage:
78 %conda install [pkgs]
77 %conda install [pkgs]
79 """
78 """
80 if not _is_conda_environment():
79 if not _is_conda_environment():
81 raise ValueError("The python kernel does not appear to be a conda environment. "
80 raise ValueError("The python kernel does not appear to be a conda environment. "
82 "Please use ``%pip install`` instead.")
81 "Please use ``%pip install`` instead.")
83
82
84 conda = _get_conda_executable()
83 conda = _get_conda_executable()
85 args = shlex.split(line)
84 args = shlex.split(line)
86 command = args[0]
85 command = args[0]
General Comments 0
You need to be logged in to leave comments. Login now