File tree 1 file changed +18
-6
lines changed
1 file changed +18
-6
lines changed Original file line number Diff line number Diff line change 4
4
import inspect
5
5
import platform
6
6
from collections .abc import Callable
7
- from typing import Any , ClassVar , cast
7
+ from typing import TYPE_CHECKING , Any , ClassVar , cast
8
8
9
9
import setuptools
10
10
15
15
import distutils .command .install as orig
16
16
from distutils .errors import DistutilsArgError
17
17
18
+ if TYPE_CHECKING :
19
+ # This is only used for a type-cast, don't import at runtime or it'll cause deprecation warnings
20
+ from .easy_install import easy_install as easy_install_cls
21
+ else :
22
+ easy_install_cls = None
23
+
18
24
# Prior to numpy 1.9, NumPy relies on the '_install' name, so provide it for
19
25
# now. See https://github.com/pypa/setuptools/issues/199/
20
26
_install = orig .install
@@ -133,11 +139,17 @@ def _called_from_setup(run_frame):
133
139
def do_egg_install (self ) -> None :
134
140
easy_install = self .distribution .get_command_class ('easy_install' )
135
141
136
- cmd = easy_install (
137
- self .distribution ,
138
- args = "x" ,
139
- root = self .root ,
140
- record = self .record ,
142
+ cmd = cast (
143
+ # We'd want to cast easy_install as type[easy_install_cls] but a bug in
144
+ # mypy makes it think easy_install() returns a Command on Python 3.12+
145
+ # https://github.com/python/mypy/issues/18088
146
+ easy_install_cls ,
147
+ easy_install ( # type: ignore[call-arg]
148
+ self .distribution ,
149
+ args = "x" ,
150
+ root = self .root ,
151
+ record = self .record ,
152
+ ),
141
153
)
142
154
cmd .ensure_finalized () # finalize before bdist_egg munges install cmd
143
155
cmd .always_copy_from = '.' # make sure local-dir eggs get installed
You can’t perform that action at this time.
0 commit comments