[Distutils] complicated setup

Oscar Benjamin oscar.j.benjamin at gmail.com
Thu Jun 27 20:55:11 CEST 2013


On 27 June 2013 18:31, Ethan Furman <ethan at stoneleaf.us> wrote:
>>
>> 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.

Do this do what you want:

#setup.py
import sys
from distutils.core import setup

package_data = {'enum': [...]}

if sys.version_info >= (3,0):
    package_data['enum'].append( 'test/py3_test_enum.py')
else:
    package_data['enum'].append( 'test/py2_test_enum.py')

setup(package_data = package_data, ...)


Oscar


More information about the Distutils-SIG mailing list