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
|
|
1 | 1 | import os |
2 | 2 | import sys |
3 | 3 | |
4 | | from distutils.core import setup |
| 4 | try: |
| 5 | from setuptools import setup |
| 6 | using_setuptools = True |
| 7 | except ImportError: |
| 8 | from distutils.core import setup |
| 9 | using_setuptools = False |
5 | 10 | from distutils.sysconfig import get_python_lib |
6 | 11 | |
7 | 12 | # Warn if we are installing over top of an existing installation. This can |
… |
… |
def is_package(package_name):
|
80 | 85 | version = __import__('django').get_version() |
81 | 86 | |
82 | 87 | |
83 | | setup( |
| 88 | setup_opts = dict( |
84 | 89 | name='Django', |
85 | 90 | version=version, |
86 | 91 | url='http://www.djangoproject.com/', |
… |
… |
def is_package(package_name):
|
91 | 96 | license='BSD', |
92 | 97 | packages=packages, |
93 | 98 | package_data=package_data, |
94 | | scripts=['django/bin/django-admin.py'], |
95 | 99 | classifiers=[ |
96 | 100 | 'Development Status :: 3 - Alpha', |
97 | 101 | 'Environment :: Web Environment', |
… |
… |
def is_package(package_name):
|
113 | 117 | ], |
114 | 118 | ) |
115 | 119 | |
| 120 | if using_setuptools: |
| 121 | setup_opts['entry_points'] = {'console_scripts': [ |
| 122 | 'django-admin.py = django.core.management.execute_from_command_line', |
| 123 | ]} |
| 124 | else: |
| 125 | setup_opts['scripts'] = ['django/bin/django-admin.py'] |
| 126 | |
| 127 | setup(**setup_opts) |
| 128 | |
116 | 129 | if overlay_warning: |
117 | 130 | sys.stderr.write(""" |
118 | 131 | |