[Distutils] Re: [Twisted-Python] including plugins.tml in a package

Abe Fettig abe at fettig.net
Mon Aug 16 20:00:17 CEST 2004


OK, I've come up with a hack that seems to accomplish putting data files 
in with python files in bdist_wininst.  This is a hack, folks - I'm not 
a distutils expert, and I'm really hoping someone is going to chime in 
with a better way.

Basically, I'm checking to see if the build command is bdist_wininst, 
and if so, prepending /PURELIB/ to the path of data files.  This has the 
effect of putting these files in the installer zip under 
PURELIB/file/name, rather than DATA/file/name.  I can't offer a good 
explanation for why this works, though.

Here's my setup.py file:

from distutils.core import setup
from distutils.command import install
import os, sys

data_files = [['hep', ['hep/plugins.tml']],
               ['hep/web/static', ['hep/web/static/hep.css']],
               ]

# hack to put data files in same basedir as python code
for scheme in install.INSTALL_SCHEMES.values():
     scheme['data'] = scheme['purelib']

# another hack to accomplish the same thing for windows builds
if sys.argv[1] == 'bdist_wininst':
     for fileInfo in data_files:
         fileInfo[0] = '/PURELIB/%s' % fileInfo[0]

setup(name='hep',
       version='0.6.1',
       description='Hep, a multiprotocol message server.',
       author='Abe Fettig',
       author_email='xxx at xxxxx.xxx',
       url='http://www.fettig.net/projects/hep',
       packages=['hep', 'hep.services', 'hep.tests'],
       data_files=data_files,
       )

-- EOF --

I'm cross-posting this to distutils-sig in case someone there has a 
better solution.

Abe

Matt Goodall wrote:

> On Mon, 2004-08-16 at 17:28, Abe Fettig wrote:
> 
>>Matt Goodall wrote:
>>
>>
>>>Nevow tinkers with distutils to install a .css in amongst the Python
>>>modules. Here's the config:
>>
>>[snip]
>>
>>
>>>        for scheme in install.INSTALL_SCHEMES.values():
>>>            scheme['data'] = scheme['purelib']
>>
>>I've tried that approach, but as far as I can see it doesn't work for 
>>bdist_wininst.  I just checked nevow out of cvs, ran "python setup.py 
>>bdist_wininst", and installed the package.  Rather than putting 
>>formless/freeform-default.css in c:\Python23\Lib\site-packages\formless, 
>>it put it in C:\Python23\formless, which I'm pretty sure is wrong.
> 
> 
> Oh ... erm ... damn ;-). Thanks for pointing the error out.
> 
> Cheers, Matt



More information about the Distutils-SIG mailing list