PageRenderTime 65ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 0ms

/setup.py

https://code.google.com/p/mango-py/
Python | 101 lines | 85 code | 4 blank | 12 comment | 6 complexity | a03afe1004b15c2a818eb88c387dd9c1 MD5 | raw file
Possible License(s): BSD-3-Clause
  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. if True in [F.endswith(".wsgi") for F in filenames]:
  53. data_files.append([dirpath, [os.path.join(dirpath, f) for f in filenames if f.endswith(".wsgi")]])
  54. elif filenames:
  55. data_files.append([dirpath, [os.path.join(dirpath, f) for f in filenames]])
  56. # Small hack for working with bdist_wininst.
  57. # See http://mail.python.org/pipermail/distutils-sig/2004-August/004134.html
  58. if len(sys.argv) > 1 and sys.argv[1] == 'bdist_wininst':
  59. for file_info in data_files:
  60. file_info[0] = '\\PURELIB\\%s' % file_info[0]
  61. # Dynamically calculate the version based on django.VERSION.
  62. # see django/__init__.py
  63. version = __import__('django').get_version()
  64. #if u'SVN' in version:
  65. # version = ' '.join(version.split(' ')[:-1])
  66. setup(
  67. name = "Mango-py",
  68. version = version.replace(' ', '-'),
  69. url = 'http://code.google.com/p/mango-py/',
  70. download_url = 'http://code.google.com/p/mango-py/downloads/list',
  71. author = 'Django Software Foundation',
  72. author_email = 'foundation@djangoproject.com',
  73. description = 'A high-level Python Web framework that encourages rapid development and clean, pragmatic design.',
  74. packages = packages,
  75. cmdclass = cmdclasses,
  76. data_files = data_files,
  77. scripts = ['django/bin/django-admin.py'],
  78. classifiers = ['Development Status :: 5 - Production/Stable',
  79. 'Environment :: Web Environment',
  80. 'Framework :: Django',
  81. 'Intended Audience :: Developers',
  82. 'License :: OSI Approved :: BSD License',
  83. 'Operating System :: OS Independent',
  84. 'Programming Language :: Python',
  85. 'Topic :: Internet :: WWW/HTTP',
  86. 'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
  87. 'Topic :: Internet :: WWW/HTTP :: WSGI',
  88. 'Topic :: Software Development :: Libraries :: Application Frameworks',
  89. 'Topic :: Software Development :: Libraries :: Python Modules',
  90. ],
  91. )