Ticket #4244 enhancement closed fixed
Allow running setup.py in Python 3
|Reported by:||loewis||Owned by:||thijs|
|Cc:||spiv, thijs, exarkun||Branch:||
(diff, github, buildbot, log)
|Author:||thijs, loewis||Launchpad Bug:|
Description (last modified by thijs) (diff)
The attached patch changes trunk to support running setup.py in Python 3.1 (tested on r77847). setup.py will not complete, as it will break when trying to compile extensions modules. I'll look into porting the extension modules next, however, that is likely independent from this change.
The changes fall into two parts:
- adjust all code run by setup.py so that it works on both 2.x and 3.x unmodified
- integrate with distribute's use_2to3 flag
The patch is intended for use with distribute in Python 3.x, usage of setuptools should continue to work in 2.x unmodified.
The 3.x changes can be summarized as follows:
- replace file with open (#5785). This will work on all 2.x versions, and 3.x doesn't have the file builtin
- provide an implementation for execfile in 3.x. 2to3 will also fix all execfile usage, however, a few cases of execfile are used during the setup process (#5129)
- parenthetise print and exec
- replace an unlink/EnvironmentError check in dist.py with a os.path.exists check. This, again, should work on all Python versions, whereas the except syntax doesn't work in 3.x.
The use_2to3 changes have two pieces:
- activate use_2to3
- disable a fixer that caused problems. I haven't checked 3.1.1; it may be that the problem only exists in the Python release31-maint branch.