mirror of
https://github.com/django/django.git
synced 2025-10-09 10:10:28 +00:00
Fixed #18115 - added warning about overlaid install.
Setup.py now warns if it detects that Django is being installed over top of a previous installation that was never removed. This should only happen when installing with ``python setup.py install``, as pip automatically uninstalls before installing a new version and easy_install installs as an egg directory. Also generally updated the installation doc.
This commit is contained in:
parent
23b9418458
commit
6ed7d40727
2 changed files with 122 additions and 52 deletions
36
setup.py
36
setup.py
|
@ -1,9 +1,25 @@
|
|||
from distutils.core import setup
|
||||
from distutils.command.install_data import install_data
|
||||
from distutils.command.install import INSTALL_SCHEMES
|
||||
from distutils.sysconfig import get_python_lib
|
||||
import os
|
||||
import sys
|
||||
|
||||
# Warn if we are installing over top of an existing installation. This can
|
||||
# cause issues where files that were deleted from a more recent Django are
|
||||
# still present in site-packages. See #18115.
|
||||
overlay_warning = False
|
||||
if "install" in sys.argv:
|
||||
# We have to try also with an explicit prefix of /usr/local in order to
|
||||
# catch Debian's custom user site-packages directory.
|
||||
for lib_path in get_python_lib(), get_python_lib(prefix="/usr/local"):
|
||||
existing_path = os.path.abspath(os.path.join(lib_path, "django"))
|
||||
if os.path.exists(existing_path):
|
||||
# We note the need for the warning here, but present it after the
|
||||
# command is run, so it's more likely to be seen.
|
||||
overlay_warning = True
|
||||
break
|
||||
|
||||
class osx_install_data(install_data):
|
||||
# On MacOS, the platform-specific lib dir is /System/Library/Framework/Python/.../
|
||||
# which is wrong. Python 2.5 supplied with MacOS 10.5 has an Apple-specific fix
|
||||
|
@ -97,3 +113,23 @@ setup(
|
|||
'Topic :: Software Development :: Libraries :: Python Modules',
|
||||
],
|
||||
)
|
||||
|
||||
if overlay_warning:
|
||||
sys.stderr.write("""
|
||||
|
||||
========
|
||||
WARNING!
|
||||
========
|
||||
|
||||
You have just installed Django over top of an existing
|
||||
installation, without removing it first. Because of this,
|
||||
your install may now include extraneous files from a
|
||||
previous version that have since been removed from
|
||||
Django. This is known to cause a variety of problems. You
|
||||
should manually remove the
|
||||
|
||||
%(existing_path)s
|
||||
|
||||
directory and re-install Django.
|
||||
|
||||
""" % { "existing_path": existing_path })
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue