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

Chris Jerdonek chris.jerdonek at gmail.com
Wed May 16 21:24:29 CEST 2012


On Wed, May 16, 2012 at 11:57 AM, Barry Warsaw <barry at python.org> wrote:
> The question I have is how can we avoid trying to byte compile _compat2x.py
> when the package is installed via Python 3?  I've tried various distutils
> command overrides and hacks (including trying to load a MANIFEST3.in which
> exclusions that file), but haven't hit upon the right magic to make it work in
> all cases.

I also encountered this issue recently.  Can you just avoid importing
anything from your package from within setup.py?  It looks like you're
importing your package mostly just to get the __version__ number in
your package's __init__.py (though I also see you use it in the
cmdclass argument to setup(), which might require a different
work-around).

The consequence for me was that I needed to maintain the version
string for my project in two places: both setup.py and my package's
__init__.py (and I added a unit test to check that they were the
same).  I rationalized this by telling myself that the script
responsible for installing a project shouldn't need to be able to run
the project: it should be independent.

--Chris


More information about the Python-porting mailing list