[Distutils] complicated setup

Ethan Furman ethan at stoneleaf.us
Sat Jun 29 02:09:03 CEST 2013


On 06/28/2013 04:45 PM, Ethan Furman wrote:
> On 06/27/2013 11:55 AM, Oscar Benjamin wrote:
>> 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, ...)
>
> Cool!
>
> Is there a way to have files renamed?  Ideally the installed package would just have enum.py, test_enum.py, and not
> py2_enum.py and py2_test_enum.py

Am I making this too complicated?  Can I just do my renaming in the setup.py script before calling the setup function?

--
~Ethan~


More information about the Distutils-SIG mailing list