setup.py 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. # GNU MediaGoblin -- federated, autonomous media hosting
  2. # Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS.
  3. #
  4. # This program is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU Affero General Public License as published by
  6. # the Free Software Foundation, either version 3 of the License, or
  7. # (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU Affero General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU Affero General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. from __future__ import print_function
  17. from setuptools import setup, find_packages
  18. from io import open
  19. import os
  20. import re
  21. import sys
  22. PY2 = sys.version_info[0] == 2 # six is not installed yet
  23. READMEFILE = "README"
  24. VERSIONFILE = os.path.join("mediagoblin", "_version.py")
  25. VSRE = r"^__version__ = ['\"]([^'\"]*)['\"]"
  26. def get_version():
  27. with open(VERSIONFILE, "rt") as fobj:
  28. verstrline = fobj.read()
  29. mo = re.search(VSRE, verstrline, re.M)
  30. if mo:
  31. return mo.group(1)
  32. else:
  33. raise RuntimeError("Unable to find version string in %s." %
  34. VERSIONFILE)
  35. pyversion_install_requires = []
  36. if PY2:
  37. pyversion_install_requires.append('argparse') # only for < 2.7
  38. pyversion_install_requires.append('PasteScript')
  39. # newer sqlalchemy-migrate requires pbr which BREAKS EVERYTHING AND IS
  40. # TERRIBLE AND IS THE END OF ALL THINGS
  41. # I'd love to remove this restriction.
  42. pyversion_install_requires.append('sqlalchemy-migrate<0.8')
  43. # # Annoying. Please remove once we can! We only indirectly
  44. # # use pbr, and currently it breaks things, presumably till
  45. # # their next release.
  46. # pyversion_install_requires.append('pbr==0.5.22')
  47. pyversion_install_requires.append('mock==1.0.1') # mock is in the stdlib for 3.3+
  48. # PyPI version (1.4.2) does not have proper Python 3 support
  49. pyversion_install_requires.append('ExifRead')
  50. pyversion_install_requires.append('PasteScript')
  51. # Paste 2.0 is breaking wsgi, see:
  52. # https://bitbucket.org/ianb/paste/issue/4/wsgi-environ-totally-borked
  53. pyversion_install_requires.append('Paste<=1.9.9')
  54. else:
  55. pyversion_install_requires.append('gunicorn')
  56. install_requires = [
  57. 'alembic==0.6.6',
  58. 'python-dateutil',
  59. 'wtforms',
  60. 'py-bcrypt',
  61. 'pytest>=2.3.1',
  62. 'pytest-xdist',
  63. 'werkzeug>=0.7',
  64. 'celery>=3.0',
  65. 'kombu',
  66. 'jinja2',
  67. 'Babel>=1.3',
  68. 'webtest<2',
  69. 'ConfigObj',
  70. 'Markdown',
  71. 'sqlalchemy<0.9.0, >0.8.0',
  72. 'itsdangerous',
  73. 'pytz',
  74. 'sphinx',
  75. 'six',
  76. 'oauthlib',
  77. 'unidecode',
  78. 'jsonschema',
  79. 'PasteDeploy',
  80. 'requests>=2.6.0',
  81. 'pyld',
  82. # This is optional:
  83. # 'translitcodec',
  84. # For now we're expecting that users will install this from
  85. # their package managers.
  86. # 'lxml',
  87. # 'Pillow',
  88. ] + pyversion_install_requires
  89. dependency_links = []
  90. if not PY2:
  91. # PyPI version (1.4.2) does not have proper Python 3 support
  92. dependency_links.append('https://github.com/ianare/exif-py/zipball/develop#egg=ExifRead-2.0.0')
  93. install_requires.append('ExifRead>=2.0.0')
  94. with open(READMEFILE, encoding="utf-8") as fobj:
  95. long_description = fobj.read()
  96. try:
  97. setup(
  98. name="mediagoblin",
  99. version=get_version(),
  100. packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),
  101. zip_safe=False,
  102. include_package_data = True,
  103. # scripts and dependencies
  104. install_requires=install_requires,
  105. dependency_links=dependency_links,
  106. test_suite='nose.collector',
  107. entry_points="""\
  108. [console_scripts]
  109. gmg = mediagoblin.gmg_commands:main_cli
  110. [paste.app_factory]
  111. app = mediagoblin.app:paste_app_factory
  112. [paste.server_runner]
  113. paste_server_selector = mediagoblin.app:paste_server_selector
  114. [paste.filter_app_factory]
  115. errors = mediagoblin.errormiddleware:mgoblin_error_middleware
  116. [zc.buildout]
  117. make_user_dev_dirs = mediagoblin.buildout_recipes:MakeUserDevDirs
  118. [babel.extractors]
  119. jinja2 = jinja2.ext:babel_extract
  120. """,
  121. license='AGPLv3',
  122. author='Free Software Foundation and contributors',
  123. author_email='cwebber@gnu.org',
  124. url="http://mediagoblin.org/",
  125. long_description=long_description,
  126. description='MediaGoblin is a web application for publishing all kinds of media',
  127. classifiers=[
  128. "Development Status :: 3 - Alpha",
  129. "Environment :: Web Environment",
  130. "License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)",
  131. "Operating System :: OS Independent",
  132. "Programming Language :: Python",
  133. 'Programming Language :: Python :: 2',
  134. 'Programming Language :: Python :: 2.6',
  135. 'Programming Language :: Python :: 2.7',
  136. 'Programming Language :: Python :: 3',
  137. 'Programming Language :: Python :: 3.3',
  138. 'Programming Language :: Python :: 3.4',
  139. "Topic :: Internet :: WWW/HTTP :: Dynamic Content"
  140. ],
  141. )
  142. except TypeError as e:
  143. import sys
  144. # Check if the problem is caused by the sqlalchemy/setuptools conflict
  145. msg_as_str = str(e)
  146. if not (msg_as_str == 'dist must be a Distribution instance'):
  147. raise
  148. # If so, tell the user it is OK to just run the script again.
  149. print("\n\n---------- NOTE ----------", file=sys.stderr)
  150. print("The setup.py command you ran failed.\n", file=sys.stderr)
  151. print("It is a known possible failure. Just run it again. It works the "
  152. "second time.", file=sys.stderr)
  153. sys.exit(1)