2006-10-17 05:50:46 +08:00
|
|
|
import os
|
2006-12-30 14:17:21 +08:00
|
|
|
import sys
|
2005-07-16 03:49:10 +08:00
|
|
|
|
2013-04-03 18:42:33 +08:00
|
|
|
from distutils.core import setup
|
|
|
|
from distutils.sysconfig import get_python_lib
|
|
|
|
|
2012-05-22 07:28:58 +08:00
|
|
|
# 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:
|
2013-03-30 03:49:37 +08:00
|
|
|
lib_paths = [get_python_lib()]
|
|
|
|
if lib_paths[0].startswith("/usr/lib/"):
|
|
|
|
# We have to try also with an explicit prefix of /usr/local in order to
|
|
|
|
# catch Debian's custom user site-packages directory.
|
|
|
|
lib_paths.append(get_python_lib(prefix="/usr/local"))
|
|
|
|
for lib_path in lib_paths:
|
2012-05-22 07:28:58 +08:00
|
|
|
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
|
|
|
|
|
2008-07-22 00:30:32 +08:00
|
|
|
|
2007-04-03 20:28:19 +08:00
|
|
|
def fullsplit(path, result=None):
|
|
|
|
"""
|
2013-04-03 18:42:33 +08:00
|
|
|
Split a pathname into components (the opposite of os.path.join)
|
|
|
|
in a platform-neutral way.
|
2007-04-03 20:28:19 +08:00
|
|
|
"""
|
|
|
|
if result is None:
|
|
|
|
result = []
|
|
|
|
head, tail = os.path.split(path)
|
|
|
|
if head == '':
|
|
|
|
return [tail] + result
|
|
|
|
if head == path:
|
|
|
|
return result
|
|
|
|
return fullsplit(head, [tail] + result)
|
|
|
|
|
2013-04-03 18:42:33 +08:00
|
|
|
|
|
|
|
EXCLUDE_FROM_PACKAGES = ['django.conf.project_template',
|
|
|
|
'django.conf.app_template',
|
|
|
|
'django.bin']
|
|
|
|
|
|
|
|
|
|
|
|
def is_package(package_name):
|
|
|
|
for pkg in EXCLUDE_FROM_PACKAGES:
|
|
|
|
if package_name.startswith(pkg):
|
|
|
|
return False
|
|
|
|
return True
|
|
|
|
|
2006-10-17 05:50:46 +08:00
|
|
|
|
|
|
|
# Compile the list of packages available, because distutils doesn't have
|
|
|
|
# an easy way to do this.
|
2013-04-03 18:42:33 +08:00
|
|
|
packages, package_data = [], {}
|
|
|
|
|
2006-11-27 09:12:55 +08:00
|
|
|
root_dir = os.path.dirname(__file__)
|
2008-02-22 04:50:07 +08:00
|
|
|
if root_dir != '':
|
|
|
|
os.chdir(root_dir)
|
|
|
|
django_dir = 'django'
|
2006-11-27 09:12:55 +08:00
|
|
|
|
|
|
|
for dirpath, dirnames, filenames in os.walk(django_dir):
|
2012-10-07 05:40:58 +08:00
|
|
|
# Ignore PEP 3147 cache dirs and those whose names start with '.'
|
2013-02-15 07:29:21 +08:00
|
|
|
dirnames[:] = [d for d in dirnames if not d.startswith('.') and d != '__pycache__']
|
2013-04-03 18:42:33 +08:00
|
|
|
parts = fullsplit(dirpath)
|
|
|
|
package_name = '.'.join(parts)
|
|
|
|
if '__init__.py' in filenames and is_package(package_name):
|
|
|
|
packages.append(package_name)
|
2007-04-03 20:28:19 +08:00
|
|
|
elif filenames:
|
2013-04-03 18:42:33 +08:00
|
|
|
relative_path = []
|
|
|
|
while '.'.join(parts) not in packages:
|
|
|
|
relative_path.append(parts.pop())
|
|
|
|
relative_path.reverse()
|
|
|
|
path = os.path.join(*relative_path)
|
|
|
|
package_files = package_data.setdefault('.'.join(parts), [])
|
|
|
|
package_files.extend([os.path.join(path, f) for f in filenames])
|
2006-12-30 14:17:21 +08:00
|
|
|
|
2008-08-12 10:15:00 +08:00
|
|
|
|
2006-12-13 14:07:15 +08:00
|
|
|
# Dynamically calculate the version based on django.VERSION.
|
2012-01-08 23:05:15 +08:00
|
|
|
version = __import__('django').get_version()
|
2006-12-13 14:07:15 +08:00
|
|
|
|
2013-04-03 18:42:33 +08:00
|
|
|
|
2005-07-16 03:49:10 +08:00
|
|
|
setup(
|
2013-04-03 18:42:33 +08:00
|
|
|
name='Django',
|
|
|
|
version=version,
|
|
|
|
url='http://www.djangoproject.com/',
|
|
|
|
author='Django Software Foundation',
|
|
|
|
author_email='foundation@djangoproject.com',
|
|
|
|
description=('A high-level Python Web framework that encourages '
|
|
|
|
'rapid development and clean, pragmatic design.'),
|
|
|
|
license='BSD',
|
|
|
|
packages=packages,
|
|
|
|
package_data=package_data,
|
|
|
|
scripts=['django/bin/django-admin.py'],
|
|
|
|
classifiers=[
|
2013-06-28 21:15:10 +08:00
|
|
|
'Development Status :: 4 - Beta',
|
2011-03-28 10:14:19 +08:00
|
|
|
'Environment :: Web Environment',
|
|
|
|
'Framework :: Django',
|
|
|
|
'Intended Audience :: Developers',
|
|
|
|
'License :: OSI Approved :: BSD License',
|
|
|
|
'Operating System :: OS Independent',
|
|
|
|
'Programming Language :: Python',
|
2013-06-18 18:15:10 +08:00
|
|
|
'Programming Language :: Python :: 2',
|
2011-03-28 10:14:19 +08:00
|
|
|
'Programming Language :: Python :: 2.6',
|
|
|
|
'Programming Language :: Python :: 2.7',
|
2013-06-18 18:15:10 +08:00
|
|
|
'Programming Language :: Python :: 3',
|
2013-02-27 06:07:56 +08:00
|
|
|
'Programming Language :: Python :: 3.2',
|
|
|
|
'Programming Language :: Python :: 3.3',
|
2011-03-28 10:14:19 +08:00
|
|
|
'Topic :: Internet :: WWW/HTTP',
|
|
|
|
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
|
|
|
|
'Topic :: Internet :: WWW/HTTP :: WSGI',
|
|
|
|
'Topic :: Software Development :: Libraries :: Application Frameworks',
|
|
|
|
'Topic :: Software Development :: Libraries :: Python Modules',
|
2013-04-03 18:42:33 +08:00
|
|
|
],
|
2005-07-16 03:49:10 +08:00
|
|
|
)
|
2012-05-22 07:28:58 +08:00
|
|
|
|
|
|
|
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.
|
|
|
|
|
2013-04-03 18:42:33 +08:00
|
|
|
""" % {"existing_path": existing_path})
|