[Distutils] complicated setup

Ethan Furman ethan at stoneleaf.us
Thu Jun 27 19:31:33 CEST 2013


On 06/27/2013 10:19 AM, Erik Bray wrote:
> On Wed, Jun 26, 2013 at 4:21 PM, Erik Bray <erik.m.bray at gmail.com> wrote:
>> On Sun, Jun 16, 2013 at 3:13 AM, Ethan Furman <ethan at stoneleaf.us> wrote:
>>> Here's my file layout:
>>>
>>> <root> /
>>>         |- setup.py
>>>         |
>>>         |- enum /
>>>                 |- __init__.py
>>>                 |
>>>                 |- py2_enum.py
>>>                 |
>>>                 |- py3_enum.py
>>>                 |
>>>                 |- test /
>>>                         |- test_enum.py
>>>                         |
>>>                         |- py2_test_enum.py
>>>                         |
>>>                         |- py3_test_enum.py
>>>
>>> __init__ and test_enum are both smart enough to pull in the correct code
>>> when imported.  The issue I am having is this:
>>>
>>> --8<--------------------------------------------------------------
>>> ethan at hydra:~$ sudo easy_install enum34
>>> [sudo] password for ethan:
>>> Searching for enum34
>>> Reading http://pypi.python.org/simple/enum34/
>>> Best match: enum34 0.9
>>> Downloading
>>> http://pypi.python.org/packages/source/e/enum34/enum34-0.9.zip#md5=4717b8c328083d816b3b987f24446ad8
>>> Processing enum34-0.9.zip
>>> Writing /tmp/easy_install-sB55B5/enum34-0.9/setup.cfg
>>> Running enum34-0.9/setup.py -q bdist_egg --dist-dir
>>> /tmp/easy_install-sB55B5/enum34-0.9/egg-dist-tmp-qUYAv5
>>> SyntaxError: ('invalid syntax',
>>> ('build/bdist.linux-x86_64/egg/enum/py3_enum.py', 211, 43, '    def
>>> __call__(cls, value, names=None, *, module=None, type=None):\n'))
>>>
>>> SyntaxError: ('invalid syntax',
>>> ('build/bdist.linux-x86_64/egg/enum/test/py3_test_enum.py', 630, 47, '
>>> class AutoNumberedEnum(Enum, metaclass=auto_enum):\n'))
>>>
>>> zip_safe flag not set; analyzing archive contents...
>>> SyntaxError: ('invalid syntax',
>>> ('/usr/local/lib/python2.7/dist-packages/enum34-0.9-py2.7.egg/enum/py3_enum.py',
>>> 211, 43, '    def __call__(cls, value, names=None, *, module=None,
>>> type=None):\n'))
>>>
>>> SyntaxError: ('invalid syntax',
>>> ('/usr/local/lib/python2.7/dist-packages/enum34-0.9-py2.7.egg/enum/test/py3_test_enum.py',
>>> 630, 47, '        class AutoNumberedEnum(Enum, metaclass=auto_enum):\n'))
>>>
>>> Adding enum34 0.9 to easy-install.pth file
>>>
>>> Installed /usr/local/lib/python2.7/dist-packages/enum34-0.9-py2.7.egg
>>> Processing dependencies for enum34
>>> Finished processing dependencies for enum34
>>> --8<--------------------------------------------------------------
>>>
>>> distutils is trying to load the py3 versions, which of course fails on a py2
>>> install.  The package installs successfully anyway, but if I were a user I
>>> would be wondering if the install was trustworthy.
>>>
>>> It seems to me that I need to either have distutils only install the version
>>> appropriate files, or to not try to scan the version inappropriate files,
>>> but at this point I do not know how to do either.
>>>
>>> Any pointers would be greatly appreciated.
>>
>> That's odd.  I work on a package that ships Python 2 and Python 3
>> versions of some modules and I have never seen this problem before.
>> Perhaps you could post your setup.py?
>
> It occur to me now that the reason I don't see this kind of error on
> my project is because in the setup.py I am just excluding the
> version-specific files based on what Python version the user has.
> Perhaps you should do the same--only install the Python 2 tests on
> Python 2 and so on.  Just make sure that the MANIFEST.in is set up to
> include both versions in the source distribution.  As long as you
> don't install the Py2 files in Py3 or vice versa it shoudn't try to
> compile the bytecode for those files.

I would be willing to do that, but I don't know how, and so far my searching hasn't yielded anything useful besides this 
mailing list.

--
~Ethan~


More information about the Distutils-SIG mailing list