-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoscompat.py
35 lines (27 loc) · 884 Bytes
/
oscompat.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import os
import sys
WIN = sys.platform == 'win32' or os.name == 'nt'
if not WIN:
def get_binpath(prefix):
return os.path.join(prefix, 'bin')
def get_exec_path(binpath, execbin):
return os.path.join(binpath, execbin)
def exec_bin(execbin, argv, env):
os.execve(execbin, argv, env)
else: # pragma: nocover
import subprocess
def get_binpath(prefix):
return os.path.join(prefix, 'Scripts')
def get_exec_path(binpath, execbin):
if '.exe' not in execbin:
return os.path.join(binpath, '{}.exe'.format(execbin))
else:
return os.path.join(binpath, execbin)
def exec_bin(execbin, argv, env):
exe = subprocess.Popen(
[execbin] + argv[1:],
env=env,
universal_newlines=True
)
exe.communicate()
sys.exit(exe.returncode)