File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change 16
16
PYTHON_MARKER_REGEX = re .compile (r'python_version\s*('
17
17
r'?P<operator>==|<=|>=|>|<)\s*[\'"]('
18
18
r'?P<python_version>.+?)[\'"]' )
19
- SYSTEM_MARKER_REGEX = re .compile (r'sys_platform\s*==\s*[\'"](. +)[\'"]' )
19
+ SYSTEM_MARKER_REGEX = re .compile (r'sys_platform\s*==\s*[\'"]([\w.-] +)[\'"]' )
20
20
DEPENDENCIES = 'dependencies'
21
21
VERSION = 'version'
22
22
NAME = 'name'
@@ -271,9 +271,10 @@ def matches_environment(requirement):
271
271
sys_platform = sys .platform .lower ()
272
272
markers_text = get_markers_text (requirement )
273
273
if markers_text and 'sys_platform' in markers_text :
274
- match = SYSTEM_MARKER_REGEX .findall (markers_text )
275
- if len (match ) > 0 :
276
- return match [0 ].lower () == sys_platform
274
+ matches = SYSTEM_MARKER_REGEX .findall (markers_text )
275
+ lowercase_matches = [match .lower () for match in matches ]
276
+ if lowercase_matches :
277
+ return sys_platform .lower () in lowercase_matches
277
278
return True
278
279
279
280
Original file line number Diff line number Diff line change @@ -58,6 +58,14 @@ def test_matches_environment(self):
58
58
req .line = "futures==3.2.0; sys_platform == 'linux2'"
59
59
self .assertFalse (matches_environment (req ))
60
60
61
+ mock_sys .platform = "linux"
62
+ req .line = "jinja2==3.1.4 ; sys_platform == 'darwin' or sys_platform == 'linux'"
63
+ self .assertTrue (matches_environment (req ))
64
+
65
+ mock_sys .platform = "darwin"
66
+ req .line = "jinja2==3.1.4 ; sys_platform == 'darwin' or sys_platform == 'linux'"
67
+ self .assertTrue (matches_environment (req ))
68
+
61
69
# BUG: Only == operator is supported in the moment
62
70
# mock_sys.platform = "linux2"
63
71
# req.line = "futures==3.2.0; sys_platform != 'linux2'"
You can’t perform that action at this time.
0 commit comments