|
9 | 9 | import os |
10 | 10 | import socket |
11 | 11 | import subprocess |
| 12 | +import sys |
12 | 13 | import time |
13 | 14 | import warnings |
14 | 15 | import traceback |
@@ -927,14 +928,7 @@ def __init__( |
927 | 928 | # Forced to use ctypes to get the updated PATH due to sys.exec not the Python |
928 | 929 | # interpreter when running Python plugin test VS project |
929 | 930 | # The better solution would be to not need to update the path |
930 | | - windll.kernel32.GetEnvironmentVariableA.argtypes = (c_char_p, c_char_p, c_int) |
931 | | - windll.kernel32.GetEnvironmentVariableA.restype = c_int |
932 | | - name = "PATH" |
933 | | - b_name = name.encode("utf-8") |
934 | | - size = 32767 |
935 | | - buffer = create_string_buffer(b"", size) |
936 | | - _ = windll.kernel32.GetEnvironmentVariableA(b_name, buffer, size) |
937 | | - os.environ["PATH"] = buffer.value.decode("utf-8") |
| 931 | + os.environ["PATH"] = get_system_path() |
938 | 932 |
|
939 | 933 | @property |
940 | 934 | def version(self): |
@@ -977,6 +971,22 @@ def config(self): |
977 | 971 | return server_factory.AvailableServerConfigs.InProcessServer |
978 | 972 |
|
979 | 973 |
|
| 974 | +def get_system_path() -> str: |
| 975 | + """Return the current PATH environment variable value of the system.""" |
| 976 | + if not os.name == "posix": |
| 977 | + windll.kernel32.GetEnvironmentVariableA.argtypes = (c_char_p, c_char_p, c_int) |
| 978 | + windll.kernel32.GetEnvironmentVariableA.restype = c_int |
| 979 | + name = "PATH" |
| 980 | + b_name = name.encode("utf-8") |
| 981 | + size = 32767 |
| 982 | + buffer = create_string_buffer(b"", size) |
| 983 | + _ = windll.kernel32.GetEnvironmentVariableA(b_name, buffer, size) |
| 984 | + return buffer.value.decode("utf-8") |
| 985 | + else: |
| 986 | + return sys.path |
| 987 | + |
| 988 | + |
| 989 | + |
980 | 990 | class LegacyGrpcServer(BaseServer): |
981 | 991 | """Provides an instance of the DPF server using InProcess gRPC. |
982 | 992 | Kept for backward-compatibility with dpf servers <0.5.0. |
|
0 commit comments