setup.py 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. try:
  9. from setuptools import setup
  10. except ImportError:
  11. from distutils.core import setup # NOQA
  12. class osx_install_data(install_data):
  13. # On MacOS, the platform-specific lib dir is at:
  14. # /System/Library/Framework/Python/.../
  15. # which is wrong. Python 2.5 supplied with MacOS 10.5 has an Apple-specific
  16. # fix for this in distutils.command.install_data#306. It fixes install_lib
  17. # but not install_data, which is why we roll our own install_data class.
  18. def finalize_options(self):
  19. # By the time finalize_options is called, install.install_lib is set to
  20. # the fixed directory, so we set the installdir to install_lib. The
  21. # install_data class uses ('install_data', 'install_dir') instead.
  22. self.set_undefined_options('install', ('install_lib', 'install_dir'))
  23. install_data.finalize_options(self)
  24. if sys.platform == "darwin":
  25. cmdclasses = {'install_data': osx_install_data}
  26. else:
  27. cmdclasses = {'install_data': install_data}
  28. def fullsplit(path, result=None):
  29. """
  30. Split a pathname into components (the opposite of os.path.join) in a
  31. platform-neutral way.
  32. """
  33. if result is None:
  34. result = []
  35. head, tail = os.path.split(path)
  36. if head == '':
  37. return [tail] + result
  38. if head == path:
  39. return result
  40. return fullsplit(head, [tail] + result)
  41. # Tell distutils to put the data_files in platform-specific installation
  42. # locations. See here for an explanation:
  43. # http://groups.google.com/group/comp.lang.python/browse_thread/thread/35ec7b2fed36eaec/2105ee4d9e8042cb
  44. for scheme in INSTALL_SCHEMES.values():
  45. 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, package_data = [], {}
  49. root_dir = os.path.dirname(__file__)
  50. if root_dir != '':
  51. os.chdir(root_dir)
  52. extensions_dir = 'django_extensions'
  53. for dirpath, dirnames, filenames in os.walk(extensions_dir):
  54. # Ignore PEP 3147 cache dirs and those whose names start with '.'
  55. dirnames[:] = [d for d in dirnames if not d.startswith('.') and d != '__pycache__']
  56. parts = fullsplit(dirpath)
  57. package_name = '.'.join(parts)
  58. if '__init__.py' in filenames:
  59. packages.append(package_name)
  60. elif filenames:
  61. relative_path = []
  62. while '.'.join(parts) not in packages:
  63. relative_path.append(parts.pop())
  64. relative_path.reverse()
  65. path = os.path.join(*relative_path)
  66. package_files = package_data.setdefault('.'.join(parts), [])
  67. package_files.extend([os.path.join(path, f) for f in filenames])
  68. version = __import__('django_extensions').__version__
  69. setup(
  70. name='django-extensions',
  71. version=version,
  72. description="Extensions for Django",
  73. long_description="""django-extensions bundles several useful
  74. additions for Django projects. See the project page for more information:
  75. http://github.com/django-extensions/django-extensions""",
  76. author='Michael Trier',
  77. author_email='mtrier@gmail.com',
  78. maintainer='Bas van Oostveen',
  79. maintainer_email='v.oostveen@gmail.com',
  80. url='http://github.com/django-extensions/django-extensions',
  81. license='MIT License',
  82. platforms=['any'],
  83. packages=packages,
  84. cmdclass=cmdclasses,
  85. package_data=package_data,
  86. install_requires=['six>=1.2'],
  87. tests_require=['Django', 'shortuuid', 'python-dateutil'],
  88. test_suite='run_tests.main',
  89. classifiers=[
  90. 'Development Status :: 4 - Beta',
  91. 'Development Status :: 5 - Production/Stable',
  92. 'Environment :: Web Environment',
  93. 'Framework :: Django',
  94. 'Intended Audience :: Developers',
  95. 'License :: OSI Approved :: MIT License',
  96. 'Operating System :: OS Independent',
  97. 'Programming Language :: Python',
  98. 'Programming Language :: Python :: 3',
  99. 'Programming Language :: Python :: Implementation :: PyPy',
  100. 'Topic :: Utilities',
  101. ],
  102. )