[Python-porting] Python 2/3 compatible distutils installation?

Brett Cannon brett at python.org
Thu May 17 17:14:05 CEST 2012
On Wed, May 16, 2012 at 10:12 PM, Barry Warsaw <barry at python.org> wrote:

> On May 16, 2012, at 06:38 PM, Chris Jerdonek wrote:
>
> >Have you thought about storing the two files with an extension other
> >than .py?  You could argue that from Python 3's perspective, for
> >example, the compat2 file isn't really a Python file.  You could write
> >your setup script so that it copies the correct file into place at
> >compat.py before calling setup(), and then cleans up afterwards.  This
> >way, the distutils code could proceed normally.  Also, you wouldn't
> >need special version-checking code in the actual package because then
> >both versions would be importing compat when installed.
>
> It's an interesting idea, thanks.  I'll point upstream at this thread and
> see
> if they want to explore it more or if they want to go in the direction of
> using six (which would eliminate the need to use the _compatX.py files in
> this
> particular case).


Your other option is to keep the code in string literals and then do the
proper compile/exec step just like import does. Basically do you want the
hack in distutils or the modules themselves.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-porting/attachments/20120517/2f7f8439/attachment.html>


More information about the Python-porting mailing list