1
1
import itertools
2
+ import logging
2
3
import os
3
4
import pathlib
4
5
import sys
@@ -90,6 +91,7 @@ def compile_c_extension(
90
91
static library of the common parser sources (this is useful in case you are
91
92
creating multiple extensions).
92
93
"""
94
+ import setuptools .command .build_ext
93
95
import setuptools .logging
94
96
95
97
from setuptools import Extension , Distribution
@@ -98,7 +100,7 @@ def compile_c_extension(
98
100
from setuptools ._distutils .sysconfig import customize_compiler
99
101
100
102
if verbose :
101
- setuptools .logging .set_threshold (setuptools . logging . logging .DEBUG )
103
+ setuptools .logging .set_threshold (logging .DEBUG )
102
104
103
105
source_file_path = pathlib .Path (generated_source_path )
104
106
extension_name = source_file_path .stem
@@ -140,12 +142,14 @@ def compile_c_extension(
140
142
)
141
143
dist = Distribution ({"name" : extension_name , "ext_modules" : [extension ]})
142
144
cmd = dist .get_command_obj ("build_ext" )
145
+ assert isinstance (cmd , setuptools .command .build_ext .build_ext )
143
146
fixup_build_ext (cmd )
144
147
cmd .build_lib = str (source_file_path .parent )
145
148
cmd .include_dirs = include_dirs
146
149
if build_dir :
147
150
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]
149
153
150
154
compiler = new_compiler ()
151
155
customize_compiler (compiler )
@@ -156,7 +160,8 @@ def compile_c_extension(
156
160
library_filename = compiler .library_filename (extension_name , output_dir = library_dir )
157
161
if newer_group (common_sources , library_filename , "newer" ):
158
162
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]
160
165
compile_opts = [f"/Fd{ library_dir } \\ { pdb } " ]
161
166
compile_opts .extend (extra_compile_args )
162
167
else :
0 commit comments