Find absolute path to executable cmd in a cross platform manner. This function tries to determine the full path to a command line program using `which` on Unix/Linux/OS X and `win32api` on Windows. Most of the time it will use the version that is first on the users `PATH`. Warning
(cmd)
| 33 | |
| 34 | |
| 35 | def find_cmd(cmd): |
| 36 | """Find absolute path to executable cmd in a cross platform manner. |
| 37 | |
| 38 | This function tries to determine the full path to a command line program |
| 39 | using `which` on Unix/Linux/OS X and `win32api` on Windows. Most of the |
| 40 | time it will use the version that is first on the users `PATH`. |
| 41 | |
| 42 | Warning, don't use this to find IPython command line programs as there |
| 43 | is a risk you will find the wrong one. Instead find those using the |
| 44 | following code and looking for the application itself:: |
| 45 | |
| 46 | import sys |
| 47 | argv = [sys.executable, '-m', 'IPython'] |
| 48 | |
| 49 | Parameters |
| 50 | ---------- |
| 51 | cmd : str |
| 52 | The command line program to look for. |
| 53 | """ |
| 54 | path = shutil.which(cmd) |
| 55 | if path is None: |
| 56 | raise FindCmdError('command could not be found: %s' % cmd) |
| 57 | return path |
| 58 | |
| 59 | |
| 60 | def abbrev_cwd(): |
searching dependent graphs…