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

Chris Jerdonek chris.jerdonek at gmail.com
Thu May 17 03:38:23 CEST 2012


On Wed, May 16, 2012 at 4:34 PM, Barry Warsaw <barry at python.org> wrote:
> On May 16, 2012, at 03:16 PM, Chris Jerdonek wrote:
>
> That's the question. :)  By which I mean, the files get byte compiled on
> installation, and I've tried various things to have it ignore _compat2x.py
> when installing in Python 3, but with no luck.

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.

--Chris


More information about the Python-porting mailing list