setup.py 1.4 KB

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