Skip to content

Commit b8924fd

Browse files
committed
Introduce config flag 'no_requirements', which disables the built in check for installed python modules. Additionally Mbed CLI will only report but not attempt to install missing python modules during mbed compile, mbed test, mbed export, mbed detect
1 parent 1370900 commit b8924fd

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

mbed/mbed.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353

5454

5555
# Application version
56-
ver = '1.8.3'
56+
ver = '1.8.4'
5757

5858
# Default paths to Mercurial and Git
5959
hg_cmd = 'hg'
@@ -1618,7 +1618,12 @@ def requirements_contains(self, library_name):
16181618
with open(os.path.join(req_path, req_file), 'r') as f:
16191619
return library_name in f.read()
16201620

1621-
def check_requirements(self, show_warning=False):
1621+
def check_requirements(self, show_warning_only=False):
1622+
skip_requirements = self.get_cfg("NO_REQUIREMENTS", False)
1623+
if skip_requirements:
1624+
action("Skipping installed requirements check due to configuration flag.")
1625+
return True
1626+
16221627
req_path = self.get_requirements() or self.path
16231628
if not req_path:
16241629
return False
@@ -1636,7 +1641,7 @@ def check_requirements(self, show_warning=False):
16361641
if not pkg in installed_packages:
16371642
missing.append(pkg)
16381643

1639-
if missing and install_requirements:
1644+
if missing and install_requirements and not show_warning_only:
16401645
try:
16411646
action("Auto-installing missing Python modules (%s)..." % ', '.join(missing))
16421647
pquery([python_cmd, '-m', 'pip', 'install', '-q', '-r', os.path.join(req_path, req_file)])
@@ -1648,15 +1653,15 @@ def check_requirements(self, show_warning=False):
16481653

16491654
if missing:
16501655
msg = (
1651-
"Unable to auto-install required Python modules.\n"
1652-
"The mbed OS tools in this program require the following Python modules: %s\n"
1656+
"Missing Python modules were not auto-installed.\n"
1657+
"The Mbed OS tools in this program require the following Python modules: %s\n"
16531658
"You can install all missing modules by running \"pip install -r %s\" in \"%s\"" % (', '.join(missing), req_file, req_path))
16541659
if os.name == 'posix' and platform.system() == 'Darwin':
16551660
msg += "\nOn Mac you might have to install packages as your user by adding the \"--user\" flag"
16561661
elif os.name == 'posix':
16571662
msg += "\nOn Posix systems (Linux, etc) you might have to switch to superuser account or use \"sudo\""
16581663

1659-
if show_warning:
1664+
if show_warning_only:
16601665
warning(msg)
16611666
else:
16621667
error(msg, 1)
@@ -1681,7 +1686,7 @@ def post_action(self, check_reqs=True):
16811686
shutil.copy(os.path.join(mbed_tools_path, 'default_settings.py'), os.path.join(self.path, 'mbed_settings.py'))
16821687

16831688
if check_reqs:
1684-
self.check_requirements(True)
1689+
self.check_requirements()
16851690

16861691
def add_tools(self, path):
16871692
if not os.path.exists(path):
@@ -2977,7 +2982,7 @@ def test_(toolchain=None, target=None, compile_list=False, run_list=False,
29772982
def dev_mgmt(toolchain=None, target=None, source=False, profile=False, build=False):
29782983
orig_path = getcwd()
29792984
program = Program(getcwd(), True)
2980-
program.check_requirements(True)
2985+
program.check_requirements()
29812986
with cd(program.path):
29822987
tools_dir = program.get_tools()
29832988

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
setup(
2020
name="mbed-cli",
21-
version="1.8.3",
21+
version="1.8.4",
2222
description="Arm Mbed command line tool for repositories version control, publishing and updating code from remotely hosted repositories (GitHub, GitLab and mbed.com), and invoking Mbed OS own build system and export functions, among other operations",
2323
long_description=long_description,
2424
long_description_content_type="text/markdown",

0 commit comments

Comments
 (0)