File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change 99import os
1010import socket
1111import subprocess
12- import sys
1312import time
1413import warnings
1514import traceback
1615from threading import Thread , Lock
1716from abc import ABC
17+ from ctypes import *
1818
1919import psutil
2020
@@ -928,10 +928,17 @@ def __init__(
928928 self .set_as_global (as_global = as_global )
929929 # Update the python os.environment
930930 if not os .name == "posix" :
931- new_path = subprocess .check_output (
932- [sys .executable , "-c" , r'import os; print(os.environ["PATH"])' ], text = True
933- ) # pragma: no cover
934- os .environ ["PATH" ] = new_path
931+ # Forced to use ctypes to get the updated PATH due to sys.exec not the Python
932+ # interpreter when running Python plugin test VS project
933+ # The better solution would be to not need to update the path
934+ windll .kernel32 .GetEnvironmentVariableA .argtypes = (c_char_p , c_char_p , c_int )
935+ windll .kernel32 .GetEnvironmentVariableA .restype = c_int
936+ name = "PATH"
937+ b_name = name .encode ("utf-8" )
938+ size = 32767
939+ buffer = create_string_buffer (b"" , size )
940+ _ = windll .kernel32 .GetEnvironmentVariableA (b_name , buffer , size )
941+ os .environ ["PATH" ] = buffer .value .decode ("utf-8" )
935942
936943 @property
937944 def version (self ):
You can’t perform that action at this time.
0 commit comments