mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-30 10:07:14 +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
|
||||
except ImportError:
|
||||
import sys
|
||||
for _path in sys.path:
|
||||
if "platformio" in _path:
|
||||
sys.path.insert(0, _path[:_path.rfind("platformio") - 1])
|
||||
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)
|
||||
try:
|
||||
from platformio import util
|
||||
break
|
||||
from platformio import util
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
import json
|
||||
from os import environ
|
||||
|
@ -1,9 +1,10 @@
|
||||
# Copyright (C) Ivan Kravets <me@ikravets.com>
|
||||
# See LICENSE for details.
|
||||
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
from imp import load_source
|
||||
from os import listdir
|
||||
from os.path import isdir, isfile, join
|
||||
|
||||
import click
|
||||
@ -152,7 +153,7 @@ class PlatformFactory(object):
|
||||
pdir = join(d, "platforms")
|
||||
if not isdir(pdir):
|
||||
continue
|
||||
for p in sorted(listdir(pdir)):
|
||||
for p in sorted(os.listdir(pdir)):
|
||||
if (p in ("__init__.py", "base.py") or not
|
||||
p.endswith(".py")):
|
||||
continue
|
||||
@ -371,6 +372,20 @@ class BasePlatform(object):
|
||||
|
||||
self._found_error = False
|
||||
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(
|
||||
[
|
||||
"scons",
|
||||
|
Reference in New Issue
Block a user