Move environment set up to site_scons
This commit is contained in:
parent
b9a582caf4
commit
2f1c86a793
5 changed files with 148 additions and 163 deletions
30
site_scons/paths.py
Normal file
30
site_scons/paths.py
Normal file
|
@ -0,0 +1,30 @@
|
|||
# paths.py
|
||||
# Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
import os
|
||||
import os.path
|
||||
|
||||
|
||||
def is_executable(path):
|
||||
return os.path.exists(path) and os.access(path, os.X_OK)
|
||||
|
||||
|
||||
def which(program):
|
||||
'''
|
||||
Look for `program` in system path and return the full path to that binary if
|
||||
it is found. Otherwise, return `None`.
|
||||
'''
|
||||
path, name = os.path.split(program)
|
||||
if path:
|
||||
if is_executable(program):
|
||||
return program
|
||||
else:
|
||||
pathext = [''] + os.environ.get('PATHEXT', '').split(os.pathsep)
|
||||
for path in os.environ.get('PATH', '').split(os.pathsep):
|
||||
exe = os.path.join(path, program)
|
||||
for ext in pathext:
|
||||
candidate = exe + ext
|
||||
if is_executable(candidate):
|
||||
return candidate
|
||||
return None
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue