Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the PATH update on InProcess #1454

Merged
merged 1 commit into from
Mar 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions src/ansys/dpf/core/server_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
import os
import socket
import subprocess
import sys
import time
import warnings
import traceback
from threading import Thread, Lock
from abc import ABC
from ctypes import *

import psutil

Expand Down Expand Up @@ -928,10 +928,17 @@ def __init__(
self.set_as_global(as_global=as_global)
# Update the python os.environment
if not os.name == "posix":
new_path = subprocess.check_output(
[sys.executable, "-c", r'import os; print(os.environ["PATH"])'], text=True
) # pragma: no cover
os.environ["PATH"] = new_path
# Forced to use ctypes to get the updated PATH due to sys.exec not the Python
# interpreter when running Python plugin test VS project
# The better solution would be to not need to update the path
windll.kernel32.GetEnvironmentVariableA.argtypes = (c_char_p, c_char_p, c_int)
windll.kernel32.GetEnvironmentVariableA.restype = c_int
name = "PATH"
b_name = name.encode("utf-8")
size = 32767
buffer = create_string_buffer(b"", size)
_ = windll.kernel32.GetEnvironmentVariableA(b_name, buffer, size)
os.environ["PATH"] = buffer.value.decode("utf-8")

@property
def version(self):
Expand Down
Loading