distutils bdist_wininst failure on Linux

Steven D'Aprano steve+comp.lang.python at pearwood.info
Thu Feb 23 19:49:11 EST 2012


On 2012年2月24日 00:11:11 +0000, Steven D'Aprano wrote:
> On 2012年2月23日 07:09:35 -0800, jmfauth wrote:
>>> On 23 fév, 15:06, Steven D'Aprano <steve
>> +comp.lang.pyt... at pearwood.info> wrote:
>>> Following instructions here:
>>>>>> http://docs.python.org/py3k/distutils/builtdist.html#creating-
> windows...
>>>>>> I am trying to create a Windows installer for a pure-module
>>> distribution using Python 3.2. I get a "LookupError: unknown encoding:
>>> mbcs"
> [...]
>>> How do I fix this, and is it a bug in distutils?
>>>> Because the 'mbcs' codec is missing in your Linux, :-)
>> Well duh :-)
>> This is a bug in distutils. Prompted by your comment I expanded my
> search terms and found this bug report:
>> http://bugs.python.org/issue10945
>> The problem is that mbcs is not a real codec, it means "whatever codec
> is currently configured in Windows". So it doesn't exist on non-Windows
> platforms. But distutils bdist_wininst is explicitly documented as
> working on non-Windows platforms. Hence, it's a bug.

And I have a work-around that seems to work for me. Put this at the top 
of your setup.py install script:
# Work around mbcs bug in distutils.
# http://bugs.python.org/issue10945
import codecs
try:
 codecs.lookup('mbcs')
except LookupError:
 ascii = codecs.lookup('ascii')
 func = lambda name, enc=ascii: {True: enc}.get(name=='mbcs')
 codecs.register(func)
-- 
Steven


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /