Changeset 306

Show
Ignore:
Timestamp:
08/13/06 15:57:09 (2 years ago)
Author:
mj
Message:

Fix actual installation of datafiles. Boy, distutils can be painful

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • z3wingdbg/trunk/setup.py

    r305 r306  
    44 
    55from distutils.core import setup 
     6from distutils.command.build_py import build_py 
     7from distutils.command.install_data import install_data 
    68import os 
    79 
     
    911VERSION = file(os.path.join(base, "version.txt")).readline().strip() 
    1012 
     13# Build package and data_files structures 
     14data_globs = ['*.txt', '*.pt', '*.zcml'] 
    1115packages = ['z3wingdbg'] 
     16package_data=dict( 
     17    z3wingdbg=data_globs + ['locales/*.pot', 'locales/*/*/*.po',  
     18                            'locales/*/*/*.mo']) 
    1219for path, dirs, files in os.walk(base): 
    1320    for dir in list(dirs): 
    1421        if os.path.exists(os.path.join(path, dir, '__init__.py')): 
    15             package_path = filter(None, path[len(base):].split(os.path.sep)) 
    16             packages.append('.'.join(['z3wingdbg'] + package_path + [dir])) 
     22            package_base = filter(None, path[len(base):].split(os.path.sep)) 
     23            package = '.'.join(['z3wingdbg'] + package_base + [dir]) 
     24            packages.append(package) 
     25            package_data[package] = data_globs[:] 
    1726        else: 
    1827            dirs.remove(dir) 
     28         
     29# Distutils adjustments (*sigh*) 
     30class fixed_build_py(build_py): 
     31    """Bug-fixed version of get_data_files""" 
     32    def get_data_files (self): 
     33        """Generate list of '(package,src_dir,build_dir,filenames)' tuples""" 
     34        data = [] 
     35        if not self.packages: 
     36            return data 
     37        for package in self.packages: 
     38            # Locate package source directory 
     39            src_dir = self.get_package_dir(package) 
     40 
     41            # Compute package build directory 
     42            build_dir = os.path.join(*([self.build_lib] + package.split('.'))) 
     43 
     44            # Length of path to strip from found files (if src_dir != '') 
     45            plen = len(src_dir) and len(src_dir)+1 
     46 
     47            # Strip directory from globbed filenames 
     48            filenames = [ 
     49                file[plen:] for file in self.find_data_files(package, src_dir) 
     50                ] 
     51            data.append((package, src_dir, build_dir, filenames)) 
     52        return data 
     53     
     54class package_install_data(install_data): 
     55     """Install data into package directories""" 
     56     def finalize_options (self): 
     57         self.set_undefined_options('install', ('install_lib', 'install_dir'), 
     58                                    ('root', 'root'), ('force', 'force')) 
    1959             
    2060setup( 
     
    3676    download_url='http://www.zopatista.com/projects/z3wingdbg/' 
    3777                 'releases/%s/z3wingdbg-%s.tar.gz' % (VERSION, VERSION), 
    38     keywords='debugger,Zope3,Wing IDE', 
     78    keywords='debugger,Zope3,Wing IDE,HTTP', 
    3979    packages=packages, 
     80    package_data=package_data, 
    4081    package_dir=dict(z3wingdbg=''), 
    4182    classifiers=[ 
     
    4990        'Programming Language :: Python', 
    5091        'Topic :: Software Development :: Debuggers', 
    51     ] 
     92    ], 
     93    cmdclass = dict(build_py=fixed_build_py, install_data=package_install_data) 
    5294)