This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author televi
Recipients dstufft, eric.araujo, televi
Date 2020-03-09.20:01:51
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Run the following command in py36, py37, and py3 for package uvloop

python build_ext --inline bdist_wheel

Expected behavior:

The package is built and bundled as a wheel.

Observed behavior:

The build fails at the bdist_wheel stage with the following error:

error: don't know how to compile C/C++ code on platform 'posix' with '<distutils.unixccompiler.UnixCCompiler object at 0x7f6054587438>' compiler

Additional Notes:

If I split the two commands (build_ext and bdist_wheel) into separate invocations (e.g. python build_ext --inline && python bdist_wheel) then the wheel is successfully built.  It only (and always) fails when build_ext and bdist_wheel are on the same command line.

What "seems" to be happening is that bdist_wheel is somehow inheriting the existing CCompiler object that was used by build_ext and is then passing that back to distutils.compiler.new_compiler().  The new_compiler() function simply checks to see if compiler is None and, if not, uses its value as a key to the compiler_class dict.

The distutils/command/build_ext build_ext object initially sets self.compiler to None so the first invocation of new_compiler() in will work as expected.  In at around line 306 (in master), however, it simply does self.compiler = new_compiler(compiler=self.compiler,...) so any subsequent invocation of run() seems like it will fail and produce the error message I'm seeing.  new_compiler() is the only place I see that error message being emitted.

The package I'm building (uvloop) is being built with Cython but all the object paths I've been able to track come back to  That packages file doesn't seem to do anything weird that I can see (which doesn't mean it isn't doing something weird).  It sets the sdist and build_ext cmdclass entries to their own methods (that don't seem to set compiler - just compiler options) and also registers an extension via ext_modules.  The code is here:

Possible Fix:

Two simple possibilities come to mind.  1) In run, see if self.compiler is not None and alter the call to new_compiler() to use self.compiler.compiler_type.  2) In new_compiler(), check the type of compiler and simply return if its a CCompiler object.
Date User Action Args
2020-03-09 20:01:52televisetrecipients: + televi, eric.araujo, dstufft
2020-03-09 20:01:52televisetmessageid: <>
2020-03-09 20:01:52televilinkissue39917 messages
2020-03-09 20:01:51televicreate