Skip to content

Commit

Permalink
Merge pull request #64 from sebix/dev-fix-markers
Browse files Browse the repository at this point in the history
Remove hardcoded markers
  • Loading branch information
toabctl committed Oct 10, 2016
2 parents 590a93a + ddebb49 commit 483a2b5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
5 changes: 2 additions & 3 deletions py2pack/requires.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

from __future__ import absolute_import
from __future__ import print_function
import sys

import pkg_resources
from six.moves import filter
Expand All @@ -26,9 +27,7 @@
def _requirement_filter_by_marker(req):
"""check if the requirement is satisfied by the marker"""
if hasattr(req, 'marker') and req.marker:
# TODO (toabctl): currently we hardcode python 2.7 and linux2
# see https://www.python.org/dev/peps/pep-0508/#environment-markers
marker_env = {'python_version': '2.7', 'sys_platform': 'linux'}
marker_env = {'python_version': '.'.join(map(str, sys.version_info[:2])), 'sys_platform': sys.platform}
if not req.marker.evaluate(environment=marker_env):
return False
return True
Expand Down
5 changes: 3 additions & 2 deletions test/test_requires.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import os
import pkg_resources
import shutil
import sys
import tempfile
import unittest
from ddt import ddt, data, unpack
Expand All @@ -43,8 +44,8 @@ def _write_setup_py(self, content):
@data(
("pywin32>=1.0;sys_platform=='win32' # PSF", False),
("foobar", True),
("foobar;python_version=='2.7'", True),
("foobar;python_version=='3.5'", False),
("foobar;python_version=='2.7'", sys.version_info[:2] == (2, 7)),
("foobar;python_version=='3.5'", sys.version_info[:2] == (3, 5)),
)
@unpack
def test__requirement_filter_by_marker(self, req, expected):
Expand Down

0 comments on commit 483a2b5

Please sign in to comment.