[Distutils] a package with is a module
p.f.moore at gmail.com
Mon Oct 27 16:26:20 CET 2014
On 27 October 2014 15:07, Ethan Furman <ethan at stoneleaf.us> wrote:
>> 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?
I don't know to be honest. It's not guaranteed to be run from a
particular location (you can do python /whatever/setup.py if you want)
but most setup.py scripts probably assume you're in the same directory
as setup.py, so it's probably always going to be there for any
I'd do something like (untested!)
here = os.path.dirname(os.path.abspath(__file__))
if sys.version_info == 3:
src = 'dbf_3.py'
elif sys.version_info[:2] == (2, 7):
src = 'dbf_27.py'
src = 'dbf_26.py'
shutil.copyfile(os.path.join(here, src), os.path.join(here, 'dbf.py'))
> And I wouldn't mind making separate wheels, if I ever get that far.
OK, although you'd need to be careful to get the tags right.
>> Alternatively, you could distribute all 3 files, as
> 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.
Yeah, it's harmless but ugly. I've seen that issue myself.
More information about the Distutils-SIG