parts/tagging/.svn/text-base/setup.py.svn-base
changeset 69 c6bca38c1cbf
equal deleted inserted replaced
68:5ff1fc726848 69:c6bca38c1cbf
       
     1 """
       
     2 Based entirely on Django's own ``setup.py``.
       
     3 """
       
     4 import os
       
     5 from distutils.command.install import INSTALL_SCHEMES
       
     6 from distutils.core import setup
       
     7 
       
     8 import tagging
       
     9 
       
    10 
       
    11 
       
    12 def fullsplit(path, result=None):
       
    13     """
       
    14     Split a pathname into components (the opposite of os.path.join) in a
       
    15     platform-neutral way.
       
    16     """
       
    17     if result is None:
       
    18         result = []
       
    19     head, tail = os.path.split(path)
       
    20     if head == '':
       
    21         return [tail] + result
       
    22     if head == path:
       
    23         return result
       
    24     return fullsplit(head, [tail] + result)
       
    25 
       
    26 # Tell distutils to put the data_files in platform-specific installation
       
    27 # locations. See here for an explanation:
       
    28 # http://groups.google.com/group/comp.lang.python/browse_thread/thread/35ec7b2fed36eaec/2105ee4d9e8042cb
       
    29 for scheme in INSTALL_SCHEMES.values():
       
    30     scheme['data'] = scheme['purelib']
       
    31 
       
    32 # Compile the list of packages available, because distutils doesn't have
       
    33 # an easy way to do this.
       
    34 packages, data_files = [], []
       
    35 root_dir = os.path.dirname(__file__)
       
    36 tagging_dir = os.path.join(root_dir, 'tagging')
       
    37 pieces = fullsplit(root_dir)
       
    38 if pieces[-1] == '':
       
    39     len_root_dir = len(pieces) - 1
       
    40 else:
       
    41     len_root_dir = len(pieces)
       
    42 
       
    43 for dirpath, dirnames, filenames in os.walk(tagging_dir):
       
    44     # Ignore dirnames that start with '.'
       
    45     for i, dirname in enumerate(dirnames):
       
    46         if dirname.startswith('.'): del dirnames[i]
       
    47     if '__init__.py' in filenames:
       
    48         packages.append('.'.join(fullsplit(dirpath)[len_root_dir:]))
       
    49     elif filenames:
       
    50         data_files.append([dirpath, [os.path.join(dirpath, f) for f in filenames]])
       
    51 
       
    52 
       
    53 setup(
       
    54     name = 'django-tagging',
       
    55     version = tagging.get_version(),
       
    56     description = 'Generic tagging application for Django',
       
    57     author = 'Jonathan Buchanan',
       
    58     author_email = 'jonathan.buchanan@gmail.com',
       
    59     url = 'http://code.google.com/p/django-tagging/',
       
    60     packages = packages,
       
    61     data_files = data_files,
       
    62     classifiers = ['Development Status :: 4 - Beta',
       
    63                    'Environment :: Web Environment',
       
    64                    'Framework :: Django',
       
    65                    'Intended Audience :: Developers',
       
    66                    'License :: OSI Approved :: BSD License',
       
    67                    'Operating System :: OS Independent',
       
    68                    'Programming Language :: Python',
       
    69                    'Topic :: Utilities'],
       
    70 )