setup.py 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. """
  2. Based entirely on Django's own ``setup.py``.
  3. """
  4. import os
  5. import sys
  6. from distutils.command.install_data import install_data
  7. from distutils.command.install import INSTALL_SCHEMES
  8. from distutils.core import setup
  9. class osx_install_data(install_data):
  10. # On MacOS, the platform-specific lib dir is /System/Library/Framework/Python/.../
  11. # which is wrong. Python 2.5 supplied with MacOS 10.5 has an Apple-specific fix
  12. # for this in distutils.command.install_data#306. It fixes install_lib but not
  13. # 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)
  20. if sys.platform == "darwin":
  21. cmdclasses = {'install_data': osx_install_data}
  22. else:
  23. cmdclasses = {'install_data': install_data}
  24. def fullsplit(path, result=None):
  25. """
  26. Split a pathname into components (the opposite of os.path.join) in a
  27. platform-neutral way.
  28. """
  29. if result is None:
  30. result = []
  31. head, tail = os.path.split(path)
  32. if head == '':
  33. return [tail] + result
  34. if head == path:
  35. return result
  36. return fullsplit(head, [tail] + result)
  37. # Tell distutils to put the data_files in platform-specific installation
  38. # locations. See here for an explanation:
  39. # http://groups.google.com/group/comp.lang.python/browse_thread/thread/35ec7b2fed36eaec/2105ee4d9e8042cb
  40. for scheme in INSTALL_SCHEMES.values():
  41. scheme['data'] = scheme['purelib']
  42. # Compile the list of packages available, because distutils doesn't have
  43. # an easy way to do this.
  44. packages, data_files = [], []
  45. root_dir = os.path.dirname(__file__)
  46. if root_dir != '':
  47. os.chdir(root_dir)
  48. extensions_dir = 'django_extensions'
  49. for dirpath, dirnames, filenames in os.walk(extensions_dir):
  50. # Ignore dirnames that start with '.'
  51. for i, dirname in enumerate(dirnames):
  52. if dirname.startswith('.'):
  53. del dirnames[i]
  54. if '__init__.py' in filenames:
  55. packages.append('.'.join(fullsplit(dirpath)))
  56. elif filenames:
  57. data_files.append([dirpath, [os.path.join(dirpath, f) for f in filenames]])
  58. version = __import__('django_extensions').__version__
  59. setup(
  60. name = 'django-extensions',
  61. version = version,
  62. description = "Extensions for Django",
  63. long_description = """django-extensions bundles several useful
  64. additions for Django projects. See the project page for more information:
  65. http://code.google.com/p/django-command-extensions/""",
  66. author = 'Michael Trier',
  67. author_email = 'mtrier@gmail.com',
  68. url = 'http://code.google.com/p/django-command-extensions/',
  69. license = 'New BSD License',
  70. platforms = ['any'],
  71. packages = packages,
  72. cmdclass = cmdclasses,
  73. data_files = data_files,
  74. classifiers = ['Development Status :: 4 - Beta',
  75. 'Environment :: Web Environment',
  76. 'Framework :: Django',
  77. 'Intended Audience :: Developers',
  78. 'License :: OSI Approved :: BSD License',
  79. 'Operating System :: OS Independent',
  80. 'Programming Language :: Python',
  81. 'Topic :: Utilities'],
  82. )