2 from distutils.core import setup
3 from distutils.command.install_data import install_data
4 from distutils.command.install import INSTALL_SCHEMES
8 class osx_install_data(install_data):
9 # On MacOS, the platform-specific lib dir is /System/Library/Framework/Python/.../
10 # which is wrong. Python 2.5 supplied with MacOS 10.5 has an Apple-specific fix
11 # for this in distutils.command.install_data#306. It fixes install_lib but not
12 # install_data, which is why we roll our own install_data class.
14 def finalize_options(self):
15 # By the time finalize_options is called, install.install_lib is set to the
16 # fixed directory, so we set the installdir to install_lib. The
17 # install_data class uses ('install_data', 'install_dir') instead.
18 self.set_undefined_options('install', ('install_lib', 'install_dir'))
19 install_data.finalize_options(self)
21 if sys.platform == "darwin":
22 cmdclasses = {'install_data': osx_install_data}
24 cmdclasses = {'install_data': install_data}
26 def fullsplit(path, result=None):
28 Split a pathname into components (the opposite of os.path.join) in a
33 head, tail = os.path.split(path)
35 return [tail] + result
38 return fullsplit(head, [tail] + result)
40 # Tell distutils to put the data_files in platform-specific installation
41 # locations. See here for an explanation:
42 # http://groups.google.com/group/comp.lang.python/browse_thread/thread/35ec7b2fed36eaec/2105ee4d9e8042cb
43 for scheme in INSTALL_SCHEMES.values():
44 scheme['data'] = scheme['purelib']
46 # Compile the list of packages available, because distutils doesn't have
47 # an easy way to do this.
48 packages, data_files = [], []
49 root_dir = os.path.dirname(__file__)
52 package_dir = 'django_tables'
54 for dirpath, dirnames, filenames in os.walk(package_dir):
55 # Ignore dirnames that start with '.'
56 for i, dirname in enumerate(dirnames):
57 if dirname.startswith('.'): del dirnames[i]
58 if '__init__.py' in filenames:
59 packages.append('.'.join(fullsplit(dirpath)))
61 data_files.append([dirpath, [os.path.join(dirpath, f) for f in filenames]])
63 # Small hack for working with bdist_wininst.
64 # See http://mail.python.org/pipermail/distutils-sig/2004-August/004134.html
65 if len(sys.argv) > 1 and sys.argv[1] == 'bdist_wininst':
66 for file_info in data_files:
67 file_info[0] = '\\PURELIB\\%s' % file_info[0]
70 name = 'django-tables',
71 version = __import__(package_dir).get_version().replace(' ', '-'),
72 description = 'Table framework for Django',
73 author = 'Bradley Ayers',
74 author_email = 'bradley.ayers@gmail.com',
77 'Environment :: Web Environment',
78 'Framework :: Django',
79 'Intended Audience :: Developers',
80 'License :: OSI Approved :: BSD License',
81 'Operating System :: OS Independent',
82 'Programming Language :: Python',
83 'Topic :: Internet :: WWW/HTTP',
84 'Topic :: Software Development :: Libraries',
87 data_files = data_files,
88 cmdclass = cmdclasses,
89 requires = ['django(>=1.1)'],
90 install_requires = ['django>=1.1']