This repository has been archived by the owner on Feb 3, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
59 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import sys | ||
import os | ||
from os.path import exists, join | ||
|
||
def which(binary_name): | ||
for p in os.environ.get('PATH', '').split(os.pathsep): | ||
path = join(p, binary_name) | ||
if exists(path): | ||
return path | ||
|
||
return None | ||
|
||
def get_executable(conf): | ||
name = conf['PYTHON_EXECUTABLE'] | ||
|
||
try: | ||
return conf['PYTHON_EXECUTABLES'][name] | ||
except KeyError: | ||
pass | ||
|
||
if name == 'default': | ||
return sys.executable | ||
elif name == 'python2': | ||
path = which('python2') | ||
if path: | ||
return path | ||
elif name == 'python3': | ||
path = which('python3') | ||
if path: | ||
return path | ||
|
||
return sys.executable |