Skip to content

Commit

Permalink
Prefer packaging instead of pkg_resources in dist.py for markers
Browse files Browse the repository at this point in the history
  • Loading branch information
abravalheri committed Jan 23, 2023
1 parent f8f56bc commit 6f93ec7
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions setuptools/dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,11 +300,21 @@ def check_extras(dist, attr, value):

def _check_extra(extra, reqs):
name, sep, marker = extra.partition(':')
if marker and pkg_resources.invalid_marker(marker):
raise DistutilsSetupError("Invalid environment marker: " + marker)
try:
_check_marker(marker)
except packaging.markers.InvalidMarker:
msg = f"Invalid environment marker: {marker} ({extra!r})"
raise DistutilsSetupError(msg) from None
list(_reqs.parse(reqs))


def _check_marker(marker):
if not marker:
return
m = packaging.markers.Marker(marker)
m.evaluate()


def assert_bool(dist, attr, value):
"""Verify that value is True, False, 0, or 1"""
if bool(value) != value:
Expand Down

0 comments on commit 6f93ec7

Please sign in to comment.