Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Use entry_points from setuptools if available #1812

Closed
wants to merge 1 commit into from

2 participants

@remram44

This fixes not being able to run django-admin.py on Windows in most cases.

I know you removed the dependency on setuptools a while ago. This doesn't bring it back, it will only be used if available.

@remram44 remram44 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.
cef5314
@timgraham
Owner

Not sure if this will be accepted or not, but it needs a Trac ticket in order to move it forward (non-trivial patches without Trac tickets are ignored).

@remram44

I added 21340, with links to all the previous discussions I could find. Thanks!

I can see why they'd be reluctant to accept this simple change, but it's a pretty annoying issue on Windows.

@timgraham
Owner

It seemed to me like the consensus on the mailing list is that this isn't the best approach to solve this... should we close this PR for now?

@remram44

It seemed to me like the consensus on the mailing list is that this isn't the best approach to solve this...

Is it? :(

Email thread is here.

@timgraham
Owner

It looks like we may just switch to setuptools, see #2116

@timgraham timgraham closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 25, 2013
  1. @remram44

    Use entry_points from setuptools if available

    remram44 authored
    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.
This page is out of date. Refresh to see the latest.
Showing with 16 additions and 3 deletions.
  1. +16 −3 setup.py
View
19 setup.py
@@ -1,7 +1,12 @@
import os
import sys
-from distutils.core import setup
+try:
+ from setuptools import setup
+ using_setuptools = True
+except ImportError:
+ from distutils.core import setup
+ using_setuptools = False
from distutils.sysconfig import get_python_lib
# Warn if we are installing over top of an existing installation. This can
@@ -80,7 +85,7 @@ def is_package(package_name):
version = __import__('django').get_version()
-setup(
+setup_opts = dict(
name='Django',
version=version,
url='http://www.djangoproject.com/',
@@ -91,7 +96,6 @@ def is_package(package_name):
license='BSD',
packages=packages,
package_data=package_data,
- scripts=['django/bin/django-admin.py'],
classifiers=[
'Development Status :: 3 - Alpha',
'Environment :: Web Environment',
@@ -113,6 +117,15 @@ def is_package(package_name):
],
)
+if using_setuptools:
+ setup_opts['entry_points'] = {'console_scripts': [
+ 'django-admin.py = django.core.management.execute_from_command_line',
+ ]}
+else:
+ setup_opts['scripts'] = ['django/bin/django-admin.py']
+
+setup(**setup_opts)
+
if overlay_warning:
sys.stderr.write("""
Something went wrong with that request. Please try again.