setup.py 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. import os
  2. import sys
  3. from distutils.sysconfig import get_python_lib
  4. from setuptools import find_packages, setup
  5. CURRENT_PYTHON = sys.version_info[:2]
  6. REQUIRED_PYTHON = (3, 5)
  7. # This check and everything above must remain compatible with Python 2.7.
  8. if CURRENT_PYTHON < REQUIRED_PYTHON:
  9. sys.stderr.write("""
  10. ==========================
  11. Unsupported Python version
  12. ==========================
  13. This version of Django requires Python {}.{}, but you're trying to
  14. install it on Python {}.{}.
  15. This may be because you are using a version of pip that doesn't
  16. understand the python_requires classifier. Make sure you
  17. have pip >= 9.0 and setuptools >= 24.2, then try again:
  18. $ python -m pip install --upgrade pip setuptools
  19. $ python -m pip install django
  20. This will install the latest version of Django which works on your
  21. version of Python. If you can't upgrade your pip (or Python), request
  22. an older version of Django:
  23. $ python -m pip install "django<2"
  24. """.format(*(REQUIRED_PYTHON + CURRENT_PYTHON)))
  25. sys.exit(1)
  26. # Warn if we are installing over top of an existing installation. This can
  27. # cause issues where files that were deleted from a more recent Django are
  28. # still present in site-packages. See #18115.
  29. overlay_warning = False
  30. if "install" in sys.argv:
  31. lib_paths = [get_python_lib()]
  32. if lib_paths[0].startswith("/usr/lib/"):
  33. # We have to try also with an explicit prefix of /usr/local in order to
  34. # catch Debian's custom user site-packages directory.
  35. lib_paths.append(get_python_lib(prefix="/usr/local"))
  36. for lib_path in lib_paths:
  37. existing_path = os.path.abspath(os.path.join(lib_path, "django"))
  38. if os.path.exists(existing_path):
  39. # We note the need for the warning here, but present it after the
  40. # command is run, so it's more likely to be seen.
  41. overlay_warning = True
  42. break
  43. EXCLUDE_FROM_PACKAGES = ['django.conf.project_template',
  44. 'django.conf.app_template',
  45. 'django.bin']
  46. # Dynamically calculate the version based on django.VERSION.
  47. version = __import__('django').get_version()
  48. def read(fname):
  49. with open(os.path.join(os.path.dirname(__file__), fname)) as f:
  50. return f.read()
  51. setup(
  52. name='Django',
  53. version=version,
  54. python_requires='>={}.{}'.format(*REQUIRED_PYTHON),
  55. url='https://www.djangoproject.com/',
  56. author='Django Software Foundation',
  57. author_email='foundation@djangoproject.com',
  58. description=('A high-level Python Web framework that encourages '
  59. 'rapid development and clean, pragmatic design.'),
  60. long_description=read('README.rst'),
  61. license='BSD',
  62. packages=find_packages(exclude=EXCLUDE_FROM_PACKAGES),
  63. include_package_data=True,
  64. scripts=['django/bin/django-admin.py'],
  65. entry_points={'console_scripts': [
  66. 'django-admin = django.core.management:execute_from_command_line',
  67. ]},
  68. install_requires=['pytz'],
  69. extras_require={
  70. "bcrypt": ["bcrypt"],
  71. "argon2": ["argon2-cffi >= 16.1.0"],
  72. },
  73. zip_safe=False,
  74. classifiers=[
  75. 'Development Status :: 2 - Pre-Alpha',
  76. 'Environment :: Web Environment',
  77. 'Framework :: Django',
  78. 'Intended Audience :: Developers',
  79. 'License :: OSI Approved :: BSD License',
  80. 'Operating System :: OS Independent',
  81. 'Programming Language :: Python',
  82. 'Programming Language :: Python :: 3',
  83. 'Programming Language :: Python :: 3.5',
  84. 'Programming Language :: Python :: 3.6',
  85. 'Programming Language :: Python :: 3 :: Only',
  86. 'Topic :: Internet :: WWW/HTTP',
  87. 'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
  88. 'Topic :: Internet :: WWW/HTTP :: WSGI',
  89. 'Topic :: Software Development :: Libraries :: Application Frameworks',
  90. 'Topic :: Software Development :: Libraries :: Python Modules',
  91. ],
  92. )
  93. if overlay_warning:
  94. sys.stderr.write("""
  95. ========
  96. WARNING!
  97. ========
  98. You have just installed Django over top of an existing
  99. installation, without removing it first. Because of this,
  100. your install may now include extraneous files from a
  101. previous version that have since been removed from
  102. Django. This is known to cause a variety of problems. You
  103. should manually remove the
  104. %(existing_path)s
  105. directory and re-install Django.
  106. """ % {"existing_path": existing_path})