Skip to content

Commit

Permalink
make_devtools: fix truncation of PATH variable (setx truncates string…
Browse files Browse the repository at this point in the history
…s larger than 1024 characters, so use powershell script instead)
  • Loading branch information
NicSavichev committed Nov 2, 2023
1 parent ad82b62 commit 1310ed1
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions make_devtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,8 +482,11 @@ def install_3ds_Max_SDK(ver, url):

if nomalized_dest not in os.environ.get('PATH', '').split(os.pathsep):
if ask(f"'{nomalized_dest}' is not found in 'PATH' variable. Do you want to add it?"):
subprocess.run(["setx", "PATH", f"{nomalized_dest};{os.environ.get('PATH', '')}"], shell=True, text=True)
os.environ["PATH"] = os.environ.get('PATH', '') + ";" + nomalized_dest
print(f"adding {nomalized_dest} to 'PATH', it may take a while...")
add_path_command = (f'[System.Environment]::SetEnvironmentVariable("PATH", ' +
f'"{nomalized_dest};" + [System.Environment]::GetEnvironmentVariable("PATH", [System.EnvironmentVariableTarget]::User), ' +
f'[System.EnvironmentVariableTarget]::User)')
subprocess.run(["powershell", "-Command", add_path_command], shell=True, text=True)
env_updated = True

try:
Expand All @@ -495,6 +498,6 @@ def install_3ds_Max_SDK(ver, url):
zip_file.extractall(dest_dir)

if env_updated:
print("\nDone. Please restart your comandline environment to apply the environment variables.")
print("\nDone. Please restart your command-line environment to apply the environment variables.")
else:
print("\nDone.")

0 comments on commit 1310ed1

Please sign in to comment.