11import itertools
2+ import logging
23import os
34import pathlib
45import sys
@@ -90,6 +91,7 @@ def compile_c_extension(
9091 static library of the common parser sources (this is useful in case you are
9192 creating multiple extensions).
9293 """
94+ import setuptools .command .build_ext
9395 import setuptools .logging
9496
9597 from setuptools import Extension , Distribution
@@ -98,7 +100,7 @@ def compile_c_extension(
98100 from setuptools ._distutils .sysconfig import customize_compiler
99101
100102 if verbose :
101- setuptools .logging .set_threshold (setuptools . logging . logging .DEBUG )
103+ setuptools .logging .set_threshold (logging .DEBUG )
102104
103105 source_file_path = pathlib .Path (generated_source_path )
104106 extension_name = source_file_path .stem
@@ -140,12 +142,14 @@ def compile_c_extension(
140142 )
141143 dist = Distribution ({"name" : extension_name , "ext_modules" : [extension ]})
142144 cmd = dist .get_command_obj ("build_ext" )
145+ assert isinstance (cmd , setuptools .command .build_ext .build_ext )
143146 fixup_build_ext (cmd )
144147 cmd .build_lib = str (source_file_path .parent )
145148 cmd .include_dirs = include_dirs
146149 if build_dir :
147150 cmd .build_temp = build_dir
148- cmd .ensure_finalized ()
151+ # A deficiency in typeshed's stubs means we have to type: ignore:
152+ cmd .ensure_finalized () # type: ignore[attr-defined]
149153
150154 compiler = new_compiler ()
151155 customize_compiler (compiler )
@@ -156,7 +160,8 @@ def compile_c_extension(
156160 library_filename = compiler .library_filename (extension_name , output_dir = library_dir )
157161 if newer_group (common_sources , library_filename , "newer" ):
158162 if sys .platform == "win32" :
159- pdb = compiler .static_lib_format % (extension_name , ".pdb" )
163+ # A deficiency in typeshed's stubs means we have to type: ignore:
164+ pdb = compiler .static_lib_format % (extension_name , ".pdb" ) # type: ignore[attr-defined]
160165 compile_opts = [f"/Fd{ library_dir } \\ { pdb } " ]
161166 compile_opts .extend (extra_compile_args )
162167 else :
0 commit comments