[Distutils] Problem with distribute and converting tests for python3

Gerry Reno greno at verizon.net
Mon Oct 12 20:05:16 CEST 2009

Michael Whapples wrote:
> OK, I didn't realise the .py files are included in a binary 
> distribution, I understood it to be that the .pyc file was enough and 
> so had followed through that the .py file wouldn't be included in a 
> binary distribution like it is typically done in java (java tends not 
> to include the .java source files in a binary .jar file, only the 
> .class files). I did warn you that I may be making some 
> assumptions/hold views due to my java programming. This leads to some 
> more general questions about python and distributing modules (eg. why 
> do we need binary distributions (bdist_egg, bdist, etc) when a source 
> distribution should be fine and do all needed, why does python 
> distribute source and compiled files in a binary distribution (what 
> does the source files add in such a case), etc).
> Anyway back to the actual topic. My main question of the possible 
> solution is, why can't we have a way of specifying extra directories 
> to run 2to3 on? Tests are an example (well at least the way I view 
> tests) of when this could be useful, it may be useful in other cases 
> (not thought of an example).
> Michael Whapples
> On 12/10/09 18:16, Lennart Regebro wrote:
>> 2009/10/12 Michael Whapples<mwhapples at aim.com>:
>>> In that case I would ask them to download the source distribution 
>>> and run
>>> the tests there, they probably will want the source distribution as 
>>> I may
>>> need to ask them to apply a patch and test it out (they have the 
>>> environment
>>> I didn't foresee/have).
>> Well, that's one step extra, but fine.
>>> I question how unit tests in a binary package are like a sort of
>>> documentation as the user will not be able to see the test source 
>>> code as it
>>> will all be in .pyc files.
>> A binary distribution will include the .py files as well. "Binary" is
>> different from "source" in that extensions are already compiled. You
>> don't need to make binary distributions for anything else than
>> Windows, and then only if you have C-extensions. Modules without
>> c-extensions are best distributed as a source distribution.
>>>> The problem is that these files doesn't end up in the binary
>>>> distribution and hence 2to3 can't be run on them.
>>> Bad wording on my part, I said compile when I meant convert, so 
>>> point two
>>> should be "As distribute will include test/test*.py, why can't 
>>> distribute
>>> run 2to3 on these files and so convert my tests and so then be able 
>>> to run
>>> tests from the test command". This probably would need distribute to 
>>> create
>>> a separate directory (eg. test_3k) and then run tests from the new 
>>> location
>>> to achieve this.
>> No, that wasn't bad wording on your part, I understood perfectly, I
>> think. The problem is that these files doesn't end up in the binary
>> distribution and hence 2to3 isn't run on them as the 2to3 conversion
>> is done in build_py.
Binary distribution is a packaging type such as an rpm or a deb file 
usually for a particular distro. Not about whether source or various 
compilation products are or are not included in these binary packages. 
You can write an install that requires no build and and no source and 
just moves precompiled files into position.


More information about the Distutils-SIG mailing list