@@ -1002,6 +1002,26 @@ def action_progress(line, sep):
1002
1002
if m .group (1 ) == "Checking out files" :
1003
1003
show_progress ('Checking out' , (float (m .group (3 )) / float (m .group (4 ))) * 100 )
1004
1004
1005
+ _environment_markers = {
1006
+ "platform_system" : platform .system ()
1007
+ }
1008
+
1009
+ _comparators = {
1010
+ "!=" : lambda a , b : a != b ,
1011
+ "==" : lambda a , b : a == b ,
1012
+ }
1013
+
1014
+ def _eval_environment_marker (marker ):
1015
+ m = re .match (r'\s*([^!=]+)\s*([!=]+)\s*([^\s]*)' , marker )
1016
+ if m :
1017
+ try :
1018
+ environment_marker_value = _environment_markers [m .group (1 )]
1019
+ environment_marker_cmp = m .group (3 ).strip ("\" '" )
1020
+ return _comparators [m .group (2 )](environment_marker_value , environment_marker_cmp )
1021
+ except KeyError as e :
1022
+ pass
1023
+
1024
+ raise Exception ("Unsupported environment marker: {}" .format (marker ))
1005
1025
1006
1026
# Repository object
1007
1027
class Repo (object ):
@@ -1652,8 +1672,14 @@ def check_requirements(self, require_install=False):
1652
1672
pkg = re .sub (r'-' , '_' , re .sub (r'^([^<>=@]+).*$' , r'\1' , line ).lower ())
1653
1673
pkg = re .sub (r'^(git|hg|svn|bzr)\+(.*)/([\w.-]+?)(\.(git|hg))?$' , r'\3' , pkg )
1654
1674
pkg = re .sub (r'\[([\w]+)\]' , '' , pkg )
1655
- if not pkg in installed_packages :
1656
- missing .append (pkg )
1675
+ line_parts = line .split (";" )
1676
+
1677
+ for line_part in line_parts [1 :]:
1678
+ if not _eval_environment_marker (line_part ):
1679
+ break
1680
+ else :
1681
+ if not pkg in installed_packages :
1682
+ missing .append (pkg )
1657
1683
1658
1684
if missing and install_requirements and require_install :
1659
1685
try :
0 commit comments