[Python-Dev] packaging backport (original) (raw)

Tarek Ziadé ziade.tarek at gmail.com
Tue Jun 21 15:43:09 CEST 2011


On Tue, Jun 21, 2011 at 3:37 PM, Joe Amenta <amentajo at msu.edu> wrote: ...

Yes, 2to3/3to2 does not do anything fancy like that.  The tools are purely concerned with syntax, whereas renaming imports is semantic.  The good news is that this line: import packaging as myPackaging can be replaced by: import distutils2 as myPackaging and code that uses myPackaging will work.  I've attached a fixer that can go into your lib3to2/fixes folder.  You should also edit fiximports.py and add the line: "packaging" : "distutils2", to the MAPPING dictionary near the top, then you can run 3to2 like this: 3to2 -fpackaging -fimports filestofix.py (-w option to write changes to the files modified) Hope this helps,

It does, thanks a lot !

Cheers Tarek

-- Tarek Ziadé | http://ziade.org



More information about the Python-Dev mailing list