setup.py 3.9 KB

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