Fix SConsNotInstalled error for Linux Debian-based distributives

This commit is contained in:
Ivan Kravets
2015-09-09 00:45:51 +03:00
parent b15408e693
commit 82a8bd01fc
5 changed files with 34 additions and 9 deletions

View File

@ -4,6 +4,11 @@ Release History
PlatformIO 2.0
--------------
2.3.2 (2015-09-??)
~~~~~~~~~~~~~~~~~~
* Fixed `SConsNotInstalled` error for Linux Debian-based distributives
2.3.1 (2015-09-06)
~~~~~~~~~~~~~~~~~~

View File

@ -47,7 +47,7 @@ The latest stable version of PlatformIO may be done via
.. code-block:: bash
# update dependent packages to the latest versions
pip install -U pip setuptools
pip install -U pip setuptools virtualenv
# install the latest version of PlatformIO
pip install -U platformio

View File

@ -1,7 +1,7 @@
# Copyright (C) Ivan Kravets <me@ikravets.com>
# See LICENSE for details.
VERSION = (2, 3, "2.dev0")
VERSION = (2, 3, "2.dev1")
__version__ = ".".join([str(s) for s in VERSION])
__title__ = "platformio"

View File

@ -6,13 +6,16 @@ try:
except ImportError:
import sys
for p in sys.path:
_new_path = None
if not p.endswith("site-packages") and "site-packages" in p:
_new_path = p[:p.rfind("site-packages") + 13]
elif "platformio" in p:
_new_path = p[:p.rfind("platformio") - 1]
if _new_path and _new_path not in sys.path:
sys.path.insert(0, _new_path)
_new_paths = []
for item in ("dist-packages", "site-packages"):
if not p.endswith(item) and item in p:
_new_paths.append(p[:p.rfind(item) + len(item)])
if "platformio" in p:
_new_paths.append(p[:p.rfind("platformio") - 1])
for _p in _new_paths:
if _p not in sys.path:
sys.path.insert(0, _p)
try:
from platformio import util
break

View File

@ -4,6 +4,7 @@
import os
import re
import sys
from glob import glob
from imp import load_source
from os.path import isdir, isfile, join
@ -400,6 +401,22 @@ class BasePlatform(object):
def test_scons():
try:
r = util.exec_command(["scons", "--version"])
if "ImportError: No module named SCons.Script" in r['err']:
_PYTHONPATH = []
for p in sys.path:
if not p.endswith("-packages"):
continue
for item in glob(join(p, "scons*")):
if isdir(join(item, "SCons")) and item not in sys.path:
_PYTHONPATH.append(item)
sys.path.insert(0, item)
if _PYTHONPATH:
_PYTHONPATH = str(os.pathsep).join(_PYTHONPATH)
if os.getenv("PYTHONPATH"):
os.environ['PYTHONPATH'] += os.pathsep + _PYTHONPATH
else:
os.environ['PYTHONPATH'] = _PYTHONPATH
r = util.exec_command(["scons", "--version"])
assert r['returncode'] == 0
return True
except (OSError, AssertionError):