@@ -1620,7 +1620,12 @@ def requirements_contains(self, library_name):
1620
1620
with open (os .path .join (req_path , req_file ), 'r' ) as f :
1621
1621
return library_name in f .read ()
1622
1622
1623
- def check_requirements (self , show_warning = False ):
1623
+ def check_requirements (self , require_install = False ):
1624
+ skip_requirements = self .get_cfg ("NO_REQUIREMENTS" , False )
1625
+ if skip_requirements :
1626
+ action ("Skipping installed requirements check due to configuration flag." )
1627
+ return True
1628
+
1624
1629
req_path = self .get_requirements () or self .path
1625
1630
if not req_path :
1626
1631
return False
@@ -1638,7 +1643,7 @@ def check_requirements(self, show_warning=False):
1638
1643
if not pkg in installed_packages :
1639
1644
missing .append (pkg )
1640
1645
1641
- if missing and install_requirements :
1646
+ if missing and install_requirements and require_install :
1642
1647
try :
1643
1648
action ("Auto-installing missing Python modules (%s)..." % ', ' .join (missing ))
1644
1649
pquery ([python_cmd , '-m' , 'pip' , 'install' , '-q' , '-r' , os .path .join (req_path , req_file )])
@@ -1650,18 +1655,18 @@ def check_requirements(self, show_warning=False):
1650
1655
1651
1656
if missing :
1652
1657
msg = (
1653
- "Unable to auto-install required Python modules .\n "
1654
- "The mbed OS tools in this program require the following Python modules: %s\n "
1658
+ "Missing Python modules were not auto-installed .\n "
1659
+ "The Mbed OS tools in this program require the following Python modules: %s\n "
1655
1660
"You can install all missing modules by running \" pip install -r %s\" in \" %s\" " % (', ' .join (missing ), req_file , req_path ))
1656
1661
if os .name == 'posix' and platform .system () == 'Darwin' :
1657
1662
msg += "\n On Mac you might have to install packages as your user by adding the \" --user\" flag"
1658
1663
elif os .name == 'posix' :
1659
1664
msg += "\n On Posix systems (Linux, etc) you might have to switch to superuser account or use \" sudo\" "
1660
1665
1661
- if show_warning :
1662
- warning (msg )
1663
- else :
1666
+ if require_install :
1664
1667
error (msg , 1 )
1668
+ else :
1669
+ warning (msg )
1665
1670
1666
1671
return True
1667
1672
@@ -2640,7 +2645,7 @@ def compile_(toolchain=None, target=None, macro=False, profile=False,
2640
2645
args = remainder
2641
2646
# Find the root of the program
2642
2647
program = Program (getcwd (), True )
2643
- program .check_requirements (True )
2648
+ program .check_requirements ()
2644
2649
# Remember the original path. this is needed for compiling only the libraries and tests for the current folder.
2645
2650
orig_path = getcwd ()
2646
2651
orig_target = target
@@ -2800,7 +2805,7 @@ def test_(toolchain=None, target=None, macro=False, compile_list=False, run_list
2800
2805
args = remainder
2801
2806
# Find the root of the program
2802
2807
program = Program (getcwd (), True )
2803
- program .check_requirements (True )
2808
+ program .check_requirements ()
2804
2809
# Check if current Mbed OS support icetea
2805
2810
icetea_supported = program .requirements_contains ('icetea' )
2806
2811
@@ -3039,7 +3044,7 @@ def export(ide=None, target=None, source=False, profile=["debug"], clean=False,
3039
3044
# Find the root of the program
3040
3045
program = Program (getcwd (), True )
3041
3046
if not no_requirements :
3042
- program .check_requirements (True )
3047
+ program .check_requirements ()
3043
3048
# Remember the original path. this is needed for compiling only the libraries and tests for the current folder.
3044
3049
orig_path = getcwd ()
3045
3050
orig_target = target
@@ -3093,7 +3098,7 @@ def detect():
3093
3098
args = remainder
3094
3099
# Find the root of the program
3095
3100
program = Program (getcwd (), False )
3096
- program .check_requirements (True )
3101
+ program .check_requirements ()
3097
3102
# Change directories to the program root to use mbed OS tools
3098
3103
with cd (program .path ):
3099
3104
tools_dir = program .get_tools_dir ()
0 commit comments