File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed
tests/third_party/cupy/testing Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change 11import contextlib
2+ import importlib .metadata
23import inspect
34import unittest
45import warnings
6+ from importlib .metadata import PackageNotFoundError
57from typing import Callable
68from unittest import mock
79
@@ -52,14 +54,18 @@ def installed(*specifiers):
5254 Args:
5355 specifiers: Version specifiers (e.g., `numpy>=1.20.0`).
5456 """
55- # Delay import of pkg_resources because it is excruciatingly slow.
56- # See https://github.com/pypa/setuptools/issues/510
57- import pkg_resources
57+ # Make `packaging` a soft requirement
58+ from packaging .requirements import Requirement
5859
5960 for spec in specifiers :
61+ req = Requirement (spec )
6062 try :
61- pkg_resources .require (spec )
62- except pkg_resources .ResolutionError :
63+ found = importlib .metadata .version (req .name )
64+ except PackageNotFoundError :
65+ return False
66+ expected = req .specifier
67+ # If no constraint is given, skip
68+ if expected and (not expected .contains (found , prereleases = True )):
6369 return False
6470 return True
6571
You can’t perform that action at this time.
0 commit comments