Skip to content

Commit 0a2c35c

Browse files
committed
Force installation of dependencies in entry points
1 parent d2dbce0 commit 0a2c35c

File tree

5 files changed

+44
-0
lines changed

5 files changed

+44
-0
lines changed

tools/build.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@
2626
ROOT = abspath(join(dirname(__file__), ".."))
2727
sys.path.insert(0, ROOT)
2828

29+
from tools.utils import install_from_pip
30+
with open(join(ROOT, "requirements.txt")) as reqs:
31+
for req in reqs:
32+
install_from_pip(req)
33+
34+
import site
35+
reload(site)
2936

3037
from tools.toolchains import TOOLCHAINS
3138
from tools.toolchains import mbedToolchain

tools/make.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@
2727
ROOT = abspath(join(dirname(__file__), ".."))
2828
sys.path.insert(0, ROOT)
2929

30+
from tools.utils import install_from_pip
31+
with open(join(ROOT, "requirements.txt")) as reqs:
32+
for req in reqs:
33+
install_from_pip(req)
34+
35+
import site
36+
reload(site)
37+
3038
from tools.utils import args_error
3139
from tools.paths import BUILD_DIR
3240
from tools.paths import RTOS_LIBRARIES
@@ -50,6 +58,7 @@
5058
from tools.toolchains import mbedToolchain
5159
from tools.settings import CLI_COLOR_MAP
5260

61+
5362
if __name__ == '__main__':
5463
# Parse Options
5564
parser = get_default_options_parser()

tools/project.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33
ROOT = abspath(join(dirname(__file__), ".."))
44
sys.path.insert(0, ROOT)
55

6+
from tools.utils import install_from_pip
7+
with open(join(ROOT, "requirements.txt")) as reqs:
8+
for req in reqs:
9+
install_from_pip(req)
10+
11+
import site
12+
reload(site)
13+
614
from shutil import move, rmtree
715
from argparse import ArgumentParser
816
from os import path

tools/test.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@
2626
ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
2727
sys.path.insert(0, ROOT)
2828

29+
from tools.utils import install_from_pip
30+
with open(os.path.join(ROOT, "requirements.txt")) as reqs:
31+
for req in reqs:
32+
install_from_pip(req)
33+
34+
import site
35+
reload(site)
36+
2937
from tools.test_api import test_path_to_name, find_tests, print_tests, build_tests, test_spec_from_test_builds
3038
from tools.options import get_default_options_parser
3139
from tools.build_api import build_project, build_library

tools/utils.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,3 +318,15 @@ def parse_type(not_parent):
318318
else:
319319
return not_parent
320320
return parse_type
321+
322+
def install_from_pip(package):
323+
import pkg_resources
324+
try:
325+
pkg_resources.working_set.require(package)
326+
except (pkg_resources.DistributionNotFound, pkg_resources.VersionConflict):
327+
import pip
328+
try:
329+
pip.main(['install', '--user', '-q', package])
330+
except IOError as exc:
331+
if exc.errno == 13:
332+
print "please retry with sudo"

0 commit comments

Comments
 (0)