@@ -1599,13 +1599,19 @@ def _find_file_paths(self, paths, fl):
1599
1599
return None
1600
1600
1601
1601
def requirements_contains (self , library_name ):
1602
- req_path = self .get_requirements () or self .path
1602
+ req_path = self .get_requirements ()
1603
+ if not req_path :
1604
+ return None
1605
+
1603
1606
req_file = 'requirements.txt'
1604
1607
with open (os .path .join (req_path , req_file ), 'r' ) as f :
1605
1608
return library_name in f .read ()
1606
1609
1607
1610
def check_requirements (self , show_warning = False ):
1608
1611
req_path = self .get_requirements () or self .path
1612
+ if not req_path :
1613
+ return False
1614
+
1609
1615
req_file = 'requirements.txt'
1610
1616
missing = []
1611
1617
try :
@@ -1615,17 +1621,17 @@ def check_requirements(self, show_warning=False):
1615
1621
for line in f .read ().splitlines ():
1616
1622
pkg = re .sub (r'-' , '_' , re .sub (r'^([^<>=@]+).*$' , r'\1' , line ).lower ())
1617
1623
pkg = re .sub (r'^(git|hg|svn|bzr)\+(.*)/([\w.-]+?)(\.(git|hg))?$' , r'\3' , pkg )
1624
+ pkg = re .sub (r'\[([\w]+)\]' , '' , pkg )
1618
1625
if not pkg in installed_packages :
1619
1626
missing .append (pkg )
1620
1627
1621
1628
if missing and install_requirements :
1622
1629
try :
1623
- action ("Auto-installing missing Python modules..." )
1630
+ action ("Auto-installing missing Python modules (%s) ..." % ', ' . join ( missing ) )
1624
1631
pquery ([python_cmd , '-m' , 'pip' , 'install' , '-q' , '-r' , os .path .join (req_path , req_file )])
1625
1632
missing = []
1626
1633
except ProcessException :
1627
1634
pass
1628
-
1629
1635
except (IOError , ImportError , OSError ):
1630
1636
pass
1631
1637
@@ -1644,6 +1650,8 @@ def check_requirements(self, show_warning=False):
1644
1650
else :
1645
1651
error (msg , 1 )
1646
1652
1653
+ return True
1654
+
1647
1655
1648
1656
# Routines after cloning mbed-os
1649
1657
def post_action (self , check_reqs = True ):
0 commit comments