@@ -1002,6 +1002,26 @@ def action_progress(line, sep):
10021002 if m .group (1 ) == "Checking out files" :
10031003 show_progress ('Checking out' , (float (m .group (3 )) / float (m .group (4 ))) * 100 )
10041004
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 ))
10051025
10061026# Repository object
10071027class Repo (object ):
@@ -1652,8 +1672,14 @@ def check_requirements(self, require_install=False):
16521672 pkg = re .sub (r'-' , '_' , re .sub (r'^([^<>=@]+).*$' , r'\1' , line ).lower ())
16531673 pkg = re .sub (r'^(git|hg|svn|bzr)\+(.*)/([\w.-]+?)(\.(git|hg))?$' , r'\3' , pkg )
16541674 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 )
16571683
16581684 if missing and install_requirements and require_install :
16591685 try :
0 commit comments