forked from platformio/platformio-core
Resolved an issue with "pio pkg exec" command on WIndows while executing Python scripts from a package
This commit is contained in:
1 parent
68e62c7137
commit
be4d016f61
3 files changed
+15
-10
No files matched your search
+8
-8
@@ -185,10 +185,17 @@ def copy_pythonpath_to_osenv():
|
||||
|
||||
|
||||
def where_is_program(program, envpath=None):
|
||||
env = os.environ
|
||||
env = os.environ.copy()
|
||||
if envpath:
|
||||
env["PATH"] = envpath
|
||||
|
||||
# look up in $PATH
|
||||
for bin_dir in env.get("PATH", "").split(os.pathsep):
|
||||
if os.path.isfile(os.path.join(bin_dir, program)):
|
||||
return os.path.join(bin_dir, program)
|
||||
if IS_WINDOWS and os.path.isfile(os.path.join(bin_dir, "%s.exe" % program)):
|
||||
return os.path.join(bin_dir, "%s.exe" % program)
|
||||
|
||||
# try OS's built-in commands
|
||||
try:
|
||||
result = exec_command(["where" if IS_WINDOWS else "which", program], env=env)
|
||||
@@ -197,13 +204,6 @@ def where_is_program(program, envpath=None):
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
# look up in $PATH
|
||||
for bin_dir in env.get("PATH", "").split(os.pathsep):
|
||||
if os.path.isfile(os.path.join(bin_dir, program)):
|
||||
return os.path.join(bin_dir, program)
|
||||
if os.path.isfile(os.path.join(bin_dir, "%s.exe" % program)):
|
||||
return os.path.join(bin_dir, "%s.exe" % program)
|
||||
|
||||
return program
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user