@@ -120,7 +120,9 @@ def run(self):
120120 _write_configure_props ()
121121
122122 for lib in dotnet_modules :
123- output = lib .args .pop ("output" )
123+ output = os .path .join (self .build_lib , lib .args .pop ("output" ))
124+ rename = lib .args .pop ("rename" , {})
125+
124126 opts = sum (
125127 [
126128 ["--" + name .replace ("_" , "-" ), value ]
@@ -130,15 +132,30 @@ def run(self):
130132 )
131133
132134 opts .extend (["--configuration" , self .dotnet_config ])
133- opts .extend (["--output" , os . path . join ( self . build_lib , output ) ])
135+ opts .extend (["--output" , output ])
134136
137+ self .announce ("Running dotnet build..." , level = distutils .log .INFO )
135138 self .spawn (["dotnet" , "build" , lib .path ] + opts )
136139
137- self .distribution .ext_modules = other_modules
140+ for k , v in rename .items ():
141+ source = os .path .join (output , k )
142+ dest = os .path .join (output , v )
143+
144+ if os .path .isfile (source ):
145+ try :
146+ os .remove (dest )
147+ except OSError :
148+ pass
138149
139- super ().run ()
150+ self .move_file (src = source , dst = dest , level = distutils .log .INFO )
151+ else :
152+ self .warn ("Can't find file to rename: %s" % source )
140153
141- self .distribution .ext_modules = orig_modules
154+ if other_modules :
155+ self .distribution .ext_modules = other_modules
156+ super ().run ()
157+ self .distribution .ext_modules = orig_modules
158+ # If no modules need to be compiled, skip
142159
143160
144161class bdist_wheel_patched (bdist_wheel ):
@@ -159,12 +176,14 @@ def finalize_options(self):
159176 "src/clrmodule/" ,
160177 runtime = "win-x64" ,
161178 output = "pythonnet/dlls/amd64" ,
179+ rename = {"clr.dll" : "clr.pyd" },
162180 ),
163181 DotnetLib (
164182 "clrmodule-x86" ,
165183 "src/clrmodule/" ,
166184 runtime = "win-x86" ,
167185 output = "pythonnet/dlls/x86" ,
186+ rename = {"clr.dll" : "clr.pyd" },
168187 ),
169188]
170189
@@ -186,9 +205,6 @@ def finalize_options(self):
186205 )
187206 ext_modules .append (clr_ext )
188207except Exception :
189- import traceback
190-
191- traceback .print_exc ()
192208 print ("Failed to find mono libraries via pkg-config, skipping the Mono CLR loader" )
193209
194210
@@ -208,6 +224,7 @@ def finalize_options(self):
208224 "bdist_wheel" : bdist_wheel_patched ,
209225 "configure" : Configure ,
210226 },
227+ py_modules = ["clr" ],
211228 ext_modules = ext_modules ,
212229 classifiers = [
213230 "Development Status :: 5 - Production/Stable" ,
0 commit comments