[Distutils] a package with is a module
ethan at stoneleaf.us
Mon Oct 27 16:07:43 CET 2014
On 10/27/2014 07:04 AM, Paul Moore wrote:
> On 27 October 2014 13:47, Ethan Furman <ethan at stoneleaf.us> wrote:
>> So I have multiple problems:
>> - how do I tell PyPI that this file is for Python2.4 - 2.6, this other
>> file is for 2.7, and this other other file is for 3.3+ ?
>> - if I have to stick it all in one archive, how do I tell setup.py which
>> to install?
>> - is it possible to have all three source files as, say, .txt files, and
>> then have some Python code before the setup() call which renames the correct
>> one to dbf.py? How do I know where the .txt files are at to rename them?
> For a source distribution, you could play clever games in setup.py to
> put the right file in place, with the right name. But that's messy and
> it means that if you distribute wheels (not that there's much point in
> doing so) you need separate wheels for 2.6-, 2.7 and 3.3+.
But how? When setup.py runs, is it guaranteed to do so in a particular location relative to the installable files?
And I wouldn't mind making separate wheels, if I ever get that far.
> Alternatively, you could distribute all 3 files, as
> - __init__.py
> - dbf_26.py
> - dbf_27.py
> - dbf_3.py
> Then in __init__.py do
> if sys.version_info == 3:
> from .dbf_3 import *
> elif sys.version_info[:2] == (2, 7):
> from .dbf_27 import *
> from .dbf_26 import *
The problem I have with this method is that the last time I tried it setup.py attempted to pre-compile all the files,
resulting in syntax errors, which makes for a lousy user experience.
More information about the Distutils-SIG