From c55204cc50716c95c088a67c637fb2e0a1abf686 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 19 Jan 2016 18:42:59 +0200 Subject: [PATCH] Use current Python interpreter for the all subprocess `platformio` calls --- platformio/__init__.py | 2 +- platformio/builder/tools/platformio.py | 3 ++- platformio/ide/projectgenerator.py | 16 ++++++++++------ platformio/util.py | 12 +++++++++--- 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/platformio/__init__.py b/platformio/__init__.py index d910aa59..dc5a8938 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (2, 7, "2.dev3") +VERSION = (2, 7, "2.dev4") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index 5b7629c2..b7a9fbf6 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -19,10 +19,11 @@ from glob import glob from os import getenv, listdir, sep, walk from os.path import basename, dirname, isdir, isfile, join, normpath, realpath -from platformio.util import pioversion_to_intstr from SCons.Script import COMMAND_LINE_TARGETS, DefaultEnvironment, SConscript from SCons.Util import case_sensitive_suffixes +from platformio.util import pioversion_to_intstr + SRC_BUILD_EXT = ["c", "cpp", "S", "spp", "SPP", "sx", "s", "asm", "ASM"] SRC_HEADER_EXT = ["h", "hpp"] SRC_DEFAULT_FILTER = " ".join([ diff --git a/platformio/ide/projectgenerator.py b/platformio/ide/projectgenerator.py index f7eac015..2afd9d40 100644 --- a/platformio/ide/projectgenerator.py +++ b/platformio/ide/projectgenerator.py @@ -15,12 +15,14 @@ import json import os import re -from os.path import abspath, basename, expanduser, isdir, join, relpath +import sys +from os.path import (abspath, basename, expanduser, isdir, join, normpath, + relpath) import bottle import click # pylint: disable=wrong-import-order -from platformio import exception, util +from platformio import app, exception, util class ProjectGenerator(object): @@ -64,10 +66,12 @@ class ProjectGenerator(object): envdata = self.get_project_env() if "env_name" not in envdata: return data - result = util.exec_command( - ["platformio", "-f", "run", "-t", "idedata", - "-e", envdata['env_name'], "-d", self.project_dir] - ) + cmd = [normpath(sys.executable), "-m", "platformio", "-f"] + if app.get_session_var("caller_id"): + cmd.extend(["-c", app.get_session_var("caller_id")]) + cmd.extend(["run", "-t", "idedata", "-e", envdata['env_name']]) + cmd.extend(["-d", self.project_dir]) + result = util.exec_command(cmd) if result['returncode'] != 0 or '"includes":' not in result['out']: raise exception.PlatformioException( diff --git a/platformio/util.py b/platformio/util.py index 30ba686b..93289c67 100644 --- a/platformio/util.py +++ b/platformio/util.py @@ -18,9 +18,9 @@ import json import os import re import subprocess +import sys from glob import glob -from os.path import (abspath, basename, dirname, expanduser, isdir, isfile, - join, realpath) +from os.path import abspath, basename, dirname, expanduser, isdir, isfile, join from platform import system, uname from threading import Thread @@ -175,7 +175,13 @@ def get_lib_dir(): def get_source_dir(): - return dirname(realpath(__file__)) + curpath = abspath(__file__) + if not isfile(curpath): + for p in sys.path: + if isfile(join(p, __file__)): + curpath = join(p, __file__) + break + return dirname(curpath) def get_project_dir():