Ticket #21340: 1812.patch

File 1812.patch, 2.1 KB (added by remirampin@…, 11 years ago)
  • setup.py

    From cef5314a61f33dc3a3c74c74f862765e004a9231 Mon Sep 17 00:00:00 2001
    From: Remi Rampin <remirampin@gmail.com>
    Date: Fri, 25 Oct 2013 14:05:02 -0400
    Subject: [PATCH] Use entry_points from setuptools if available
    
    If setuptools is available, use setuptools.setup() instead of
    distutils.core.setup(), and use 'entry_point' instead of 'scripts'.
    
    Keep the exact same behavior if setuptools cannot be imported.
    
    This means that a django-admin.py.exe will be created in the PATH of
    Windows users that have setuptools available, allowing them to run it
    from the command line without having to type in the full name to the
    script (prefixed with the 'python' command) or copy it to their
    project's directory.
    ---
     setup.py | 19 ++++++++++++++++---
     1 file changed, 16 insertions(+), 3 deletions(-)
    
    diff --git a/setup.py b/setup.py
    index 6278afa..96e797f 100644
    a b  
    11import os
    22import sys
    33
    4 from distutils.core import setup
     4try:
     5    from setuptools import setup
     6    using_setuptools = True
     7except ImportError:
     8    from distutils.core import setup
     9    using_setuptools = False
    510from distutils.sysconfig import get_python_lib
    611
    712# Warn if we are installing over top of an existing installation. This can
    def is_package(package_name):  
    8085version = __import__('django').get_version()
    8186
    8287
    83 setup(
     88setup_opts = dict(
    8489    name='Django',
    8590    version=version,
    8691    url='http://www.djangoproject.com/',
    def is_package(package_name):  
    9196    license='BSD',
    9297    packages=packages,
    9398    package_data=package_data,
    94     scripts=['django/bin/django-admin.py'],
    9599    classifiers=[
    96100        'Development Status :: 3 - Alpha',
    97101        'Environment :: Web Environment',
    def is_package(package_name):  
    113117    ],
    114118)
    115119
     120if using_setuptools:
     121    setup_opts['entry_points'] = {'console_scripts': [
     122        'django-admin.py = django.core.management.execute_from_command_line',
     123    ]}
     124else:
     125    setup_opts['scripts'] = ['django/bin/django-admin.py']
     126
     127setup(**setup_opts)
     128
    116129if overlay_warning:
    117130    sys.stderr.write("""
    118131
Back to Top