2
0

setup.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import os
  2. import site
  3. import sys
  4. from distutils.sysconfig import get_python_lib
  5. from setuptools import setup
  6. # Allow editable install into user site directory.
  7. # See https://github.com/pypa/pip/issues/7953.
  8. site.ENABLE_USER_SITE = "--user" in sys.argv[1:]
  9. # Warn if we are installing over top of an existing installation. This can
  10. # cause issues where files that were deleted from a more recent Django are
  11. # still present in site-packages. See #18115.
  12. overlay_warning = False
  13. if "install" in sys.argv:
  14. lib_paths = [get_python_lib()]
  15. if lib_paths[0].startswith("/usr/lib/"):
  16. # We have to try also with an explicit prefix of /usr/local in order to
  17. # catch Debian's custom user site-packages directory.
  18. lib_paths.append(get_python_lib(prefix="/usr/local"))
  19. for lib_path in lib_paths:
  20. existing_path = os.path.abspath(os.path.join(lib_path, "django"))
  21. if os.path.exists(existing_path):
  22. # We note the need for the warning here, but present it after the
  23. # command is run, so it's more likely to be seen.
  24. overlay_warning = True
  25. break
  26. setup()
  27. if overlay_warning:
  28. sys.stderr.write(
  29. """
  30. ========
  31. WARNING!
  32. ========
  33. You have just installed Django over top of an existing
  34. installation, without removing it first. Because of this,
  35. your install may now include extraneous files from a
  36. previous version that have since been removed from
  37. Django. This is known to cause a variety of problems. You
  38. should manually remove the
  39. %(existing_path)s
  40. directory and re-install Django.
  41. """
  42. % {"existing_path": existing_path}
  43. )