setup.py 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. from distutils.core import setup
  2. from distutils.command.install import INSTALL_SCHEMES
  3. import os
  4. import sys
  5. def fullsplit(path, result=None):
  6. """
  7. Split a pathname into components (the opposite of os.path.join) in a
  8. platform-neutral way.
  9. """
  10. if result is None:
  11. result = []
  12. head, tail = os.path.split(path)
  13. if head == '':
  14. return [tail] + result
  15. if head == path:
  16. return result
  17. return fullsplit(head, [tail] + result)
  18. # Tell distutils to put the data_files in platform-specific installation
  19. # locations. See here for an explanation:
  20. # http://groups.google.com/group/comp.lang.python/browse_thread/thread/35ec7b2fed36eaec/2105ee4d9e8042cb
  21. for scheme in INSTALL_SCHEMES.values():
  22. scheme['data'] = scheme['purelib']
  23. # Compile the list of packages available, because distutils doesn't have
  24. # an easy way to do this.
  25. packages, data_files = [], []
  26. root_dir = os.path.dirname(__file__)
  27. django_dir = os.path.join(root_dir, 'django')
  28. pieces = fullsplit(root_dir)
  29. if pieces[-1] == '':
  30. len_root_dir = len(pieces)- 1
  31. else:
  32. len_root_dir = len(pieces)
  33. for dirpath, dirnames, filenames in os.walk(django_dir):
  34. # Ignore dirnames that start with '.'
  35. for i, dirname in enumerate(dirnames):
  36. if dirname.startswith('.'): del dirnames[i]
  37. if '__init__.py' in filenames:
  38. packages.append('.'.join(fullsplit(dirpath)[len_root_dir:]))
  39. elif filenames:
  40. data_files.append([dirpath, [os.path.join(dirpath, f) for f in filenames]])
  41. # Dynamically calculate the version based on django.VERSION.
  42. version_tuple = __import__('django').VERSION
  43. if version_tuple[2] is not None:
  44. version = "%d.%d_%s" % version_tuple
  45. else:
  46. version = "%d.%d" % version_tuple[:2]
  47. setup(
  48. name = "Django",
  49. version = version,
  50. url = 'http://www.djangoproject.com/',
  51. author = 'Lawrence Journal-World',
  52. author_email = 'holovaty@gmail.com',
  53. description = 'A high-level Python Web framework that encourages rapid development and clean, pragmatic design.',
  54. packages = packages,
  55. data_files = data_files,
  56. scripts = ['django/bin/django-admin.py'],
  57. )