mirror of
https://github.com/platformio/platformio-core.git
synced 2025-10-02 00:20:56 +02:00
Allow to run platformio
directly from the bin folder
This commit is contained in:
@@ -5,11 +5,19 @@ try:
|
|||||||
from platformio import util
|
from platformio import util
|
||||||
except ImportError:
|
except ImportError:
|
||||||
import sys
|
import sys
|
||||||
for _path in sys.path:
|
for p in sys.path:
|
||||||
if "platformio" in _path:
|
_new_path = None
|
||||||
sys.path.insert(0, _path[:_path.rfind("platformio") - 1])
|
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)
|
||||||
|
try:
|
||||||
|
from platformio import util
|
||||||
break
|
break
|
||||||
from platformio import util
|
except ImportError:
|
||||||
|
pass
|
||||||
|
|
||||||
import json
|
import json
|
||||||
from os import environ
|
from os import environ
|
||||||
|
@@ -1,9 +1,10 @@
|
|||||||
# Copyright (C) Ivan Kravets <me@ikravets.com>
|
# Copyright (C) Ivan Kravets <me@ikravets.com>
|
||||||
# See LICENSE for details.
|
# See LICENSE for details.
|
||||||
|
|
||||||
|
import os
|
||||||
import re
|
import re
|
||||||
|
import sys
|
||||||
from imp import load_source
|
from imp import load_source
|
||||||
from os import listdir
|
|
||||||
from os.path import isdir, isfile, join
|
from os.path import isdir, isfile, join
|
||||||
|
|
||||||
import click
|
import click
|
||||||
@@ -152,7 +153,7 @@ class PlatformFactory(object):
|
|||||||
pdir = join(d, "platforms")
|
pdir = join(d, "platforms")
|
||||||
if not isdir(pdir):
|
if not isdir(pdir):
|
||||||
continue
|
continue
|
||||||
for p in sorted(listdir(pdir)):
|
for p in sorted(os.listdir(pdir)):
|
||||||
if (p in ("__init__.py", "base.py") or not
|
if (p in ("__init__.py", "base.py") or not
|
||||||
p.endswith(".py")):
|
p.endswith(".py")):
|
||||||
continue
|
continue
|
||||||
@@ -371,6 +372,20 @@ class BasePlatform(object):
|
|||||||
|
|
||||||
self._found_error = False
|
self._found_error = False
|
||||||
try:
|
try:
|
||||||
|
# test that SCons is installed correctly
|
||||||
|
try:
|
||||||
|
r = util.exec_command(["scons", "--version"])
|
||||||
|
assert r['returncode'] == 0
|
||||||
|
except (OSError, AssertionError):
|
||||||
|
for p in sys.path:
|
||||||
|
try:
|
||||||
|
r = util.exec_command([join(p, "scons"), "--version"])
|
||||||
|
assert r['returncode'] == 0
|
||||||
|
os.environ['PATH'] += os.pathsep + p
|
||||||
|
break
|
||||||
|
except (OSError, AssertionError):
|
||||||
|
pass
|
||||||
|
|
||||||
result = util.exec_command(
|
result = util.exec_command(
|
||||||
[
|
[
|
||||||
"scons",
|
"scons",
|
||||||
|
Reference in New Issue
Block a user