PageRenderTime 82ms CodeModel.GetById 40ms app.highlight 8ms RepoModel.GetById 32ms app.codeStats 0ms

/setup.py

https://code.google.com/p/mango-py/
Python | 101 lines | 85 code | 4 blank | 12 comment | 5 complexity | a03afe1004b15c2a818eb88c387dd9c1 MD5 | raw file
  1from distutils.core import setup
  2from distutils.command.install_data import install_data
  3from distutils.command.install import INSTALL_SCHEMES
  4import os
  5import sys
  6
  7class osx_install_data(install_data):
  8    # On MacOS, the platform-specific lib dir is /System/Library/Framework/Python/.../
  9    # which is wrong. Python 2.5 supplied with MacOS 10.5 has an Apple-specific fix
 10    # for this in distutils.command.install_data#306. It fixes install_lib but not
 11    # install_data, which is why we roll our own install_data class.
 12
 13    def finalize_options(self):
 14        # By the time finalize_options is called, install.install_lib is set to the
 15        # fixed directory, so we set the installdir to install_lib. The
 16        # install_data class uses ('install_data', 'install_dir') instead.
 17        self.set_undefined_options('install', ('install_lib', 'install_dir'))
 18        install_data.finalize_options(self)
 19
 20if sys.platform == "darwin": 
 21    cmdclasses = {'install_data': osx_install_data} 
 22else: 
 23    cmdclasses = {'install_data': install_data} 
 24
 25def fullsplit(path, result=None):
 26    """
 27    Split a pathname into components (the opposite of os.path.join) in a
 28    platform-neutral way.
 29    """
 30    if result is None:
 31        result = []
 32    head, tail = os.path.split(path)
 33    if head == '':
 34        return [tail] + result
 35    if head == path:
 36        return result
 37    return fullsplit(head, [tail] + result)
 38
 39# Tell distutils to put the data_files in platform-specific installation
 40# locations. See here for an explanation:
 41# http://groups.google.com/group/comp.lang.python/browse_thread/thread/35ec7b2fed36eaec/2105ee4d9e8042cb
 42for scheme in INSTALL_SCHEMES.values():
 43    scheme['data'] = scheme['purelib']
 44
 45# Compile the list of packages available, because distutils doesn't have
 46# an easy way to do this.
 47packages, data_files = [], []
 48root_dir = os.path.dirname(__file__)
 49if root_dir != '':
 50    os.chdir(root_dir)
 51django_dir = 'django'
 52
 53for dirpath, dirnames, filenames in os.walk(django_dir):
 54    # Ignore dirnames that start with '.'
 55    for i, dirname in enumerate(dirnames):
 56        if dirname.startswith('.'): del dirnames[i]
 57    if '__init__.py' in filenames:
 58        packages.append('.'.join(fullsplit(dirpath)))
 59        if True in [F.endswith(".wsgi") for F in filenames]:
 60            data_files.append([dirpath, [os.path.join(dirpath, f) for f in filenames if f.endswith(".wsgi")]])
 61    elif filenames:
 62        data_files.append([dirpath, [os.path.join(dirpath, f) for f in filenames]])
 63
 64# Small hack for working with bdist_wininst.
 65# See http://mail.python.org/pipermail/distutils-sig/2004-August/004134.html
 66if len(sys.argv) > 1 and sys.argv[1] == 'bdist_wininst':
 67    for file_info in data_files:
 68        file_info[0] = '\\PURELIB\\%s' % file_info[0]
 69
 70# Dynamically calculate the version based on django.VERSION.
 71# see django/__init__.py
 72version = __import__('django').get_version()
 73#if u'SVN' in version:
 74#    version = ' '.join(version.split(' ')[:-1])
 75
 76setup(
 77    name = "Mango-py",
 78    version = version.replace(' ', '-'),
 79    url = 'http://code.google.com/p/mango-py/',
 80    download_url = 'http://code.google.com/p/mango-py/downloads/list',
 81    author = 'Django Software Foundation',
 82    author_email = 'foundation@djangoproject.com',
 83    description = 'A high-level Python Web framework that encourages rapid development and clean, pragmatic design.',
 84    packages = packages,
 85    cmdclass = cmdclasses,
 86    data_files = data_files,
 87    scripts = ['django/bin/django-admin.py'],
 88    classifiers = ['Development Status :: 5 - Production/Stable',
 89                   'Environment :: Web Environment',
 90                   'Framework :: Django',
 91                   'Intended Audience :: Developers',
 92                   'License :: OSI Approved :: BSD License',
 93                   'Operating System :: OS Independent',
 94                   'Programming Language :: Python',
 95                   'Topic :: Internet :: WWW/HTTP',
 96                   'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
 97                   'Topic :: Internet :: WWW/HTTP :: WSGI',
 98                   'Topic :: Software Development :: Libraries :: Application Frameworks',
 99                   'Topic :: Software Development :: Libraries :: Python Modules',
100                   ],
101)