mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-30 01:57:13 +02:00
Fix "get-platformio.py" script which hangs on Windows 10 // Resolve #1118
This commit is contained in:
@ -32,6 +32,8 @@ PlatformIO 3.0
|
|||||||
(`issue #1061 <https://github.com/platformio/platformio-core/issues/1061>`_)
|
(`issue #1061 <https://github.com/platformio/platformio-core/issues/1061>`_)
|
||||||
* Fixed missing toolchain include paths for project generator
|
* Fixed missing toolchain include paths for project generator
|
||||||
(`issue #1154 <https://github.com/platformio/platformio-core/issues/1154>`_)
|
(`issue #1154 <https://github.com/platformio/platformio-core/issues/1154>`_)
|
||||||
|
* Fixed "get-platformio.py" script which hangs on Windows 10
|
||||||
|
(`issue #1118 <https://github.com/platformio/platformio-core/issues/1118>`_)
|
||||||
|
|
||||||
3.4.1 (2017-08-02)
|
3.4.1 (2017-08-02)
|
||||||
~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import site
|
||||||
import sys
|
import sys
|
||||||
from platform import system
|
from platform import system
|
||||||
from tempfile import NamedTemporaryFile
|
from tempfile import NamedTemporaryFile
|
||||||
@ -26,39 +27,34 @@ def fix_winpython_pathenv():
|
|||||||
"""
|
"""
|
||||||
Add Python & Python Scripts to the search path on Windows
|
Add Python & Python Scripts to the search path on Windows
|
||||||
"""
|
"""
|
||||||
import ctypes
|
|
||||||
from ctypes.wintypes import HWND, UINT, WPARAM, LPARAM, LPVOID
|
|
||||||
try:
|
try:
|
||||||
import _winreg as winreg
|
import _winreg as winreg
|
||||||
except ImportError:
|
except ImportError:
|
||||||
import winreg
|
import winreg
|
||||||
|
|
||||||
# took these lines from the native "win_add2path.py"
|
# took these lines from the native "win_add2path.py"
|
||||||
pythonpath = os.path.dirname(CURINTERPRETER_PATH)
|
pythonpath = os.path.dirname(os.path.normpath(sys.executable))
|
||||||
scripts = os.path.join(pythonpath, "Scripts")
|
scripts = os.path.join(pythonpath, "Scripts")
|
||||||
if not os.path.isdir(scripts):
|
appdata = os.environ["APPDATA"]
|
||||||
os.makedirs(scripts)
|
if hasattr(site, "USER_SITE"):
|
||||||
|
userpath = site.USER_SITE.replace(appdata, "%APPDATA%")
|
||||||
|
userscripts = os.path.join(userpath, "Scripts")
|
||||||
|
else:
|
||||||
|
userscripts = None
|
||||||
|
|
||||||
with winreg.CreateKey(winreg.HKEY_CURRENT_USER, u"Environment") as key:
|
with winreg.CreateKey(winreg.HKEY_CURRENT_USER, "Environment") as key:
|
||||||
try:
|
try:
|
||||||
envpath = winreg.QueryValueEx(key, u"PATH")[0]
|
envpath = winreg.QueryValueEx(key, "PATH")[0]
|
||||||
except WindowsError:
|
except WindowsError:
|
||||||
envpath = u"%PATH%"
|
envpath = u"%PATH%"
|
||||||
|
|
||||||
paths = [envpath]
|
paths = [envpath]
|
||||||
for path in (pythonpath, scripts):
|
for path in (pythonpath, scripts, userscripts):
|
||||||
if path and path not in envpath and os.path.isdir(path):
|
if path and path not in envpath and os.path.isdir(path):
|
||||||
paths.append(path)
|
paths.append(path)
|
||||||
|
|
||||||
envpath = os.pathsep.join(paths)
|
envpath = os.pathsep.join(paths)
|
||||||
winreg.SetValueEx(key, u"PATH", 0, winreg.REG_EXPAND_SZ, envpath)
|
winreg.SetValueEx(key, "PATH", 0, winreg.REG_EXPAND_SZ, envpath)
|
||||||
winreg.ExpandEnvironmentStrings(envpath)
|
|
||||||
|
|
||||||
# notify the system about the changes
|
|
||||||
SendMessage = ctypes.windll.user32.SendMessageW
|
|
||||||
SendMessage.argtypes = HWND, UINT, WPARAM, LPVOID
|
|
||||||
SendMessage.restype = LPARAM
|
|
||||||
SendMessage(0xFFFF, 0x1A, 0, u"Environment")
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user