Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[1.5.x] Fixed #19252 -- Added support for wheel packages.

Backport from master (a5becad).

Signed-off-by: Jannis Leidel <jannis@leidel.info>
  • Loading branch information...
commit 4391718f26466f82f943e37368181d5c0520fa35 1 parent 8b34561
Florian Apolloner authored April 03, 2013 jezdez committed May 01, 2013
2  MANIFEST.in
@@ -10,7 +10,9 @@ recursive-include docs *
10 10
 recursive-include scripts *
11 11
 recursive-include extras *
12 12
 recursive-include tests *
  13
+recursive-include django/conf/app_template *
13 14
 recursive-include django/conf/locale *
  15
+recursive-include django/conf/project_template *
14 16
 recursive-include django/contrib/*/locale *
15 17
 recursive-include django/contrib/admin/templates *
16 18
 recursive-include django/contrib/admin/static *
0  django/bin/__init__.py
No changes.
9  extras/Makefile
... ...
@@ -0,0 +1,9 @@
  1
+all: sdist bdist_wheel
  2
+
  3
+sdist:
  4
+	python setup.py sdist
  5
+
  6
+bdist_wheel:
  7
+	python -c "import setuptools;__file__='setup.py';exec(compile(open(__file__).read().replace('\\r\\n', '\\n'), __file__, 'exec'))" bdist_wheel
  8
+
  9
+.PHONY : sdist bdist_wheel
5  setup.cfg
@@ -2,3 +2,8 @@
2 2
 doc_files = docs extras AUTHORS INSTALL LICENSE README.rst
3 3
 install-script = scripts/rpm-install.sh
4 4
 
  5
+[metadata]
  6
+license-file = LICENSE
  7
+
  8
+[wheel]
  9
+universal = 1 #  use py2.py3 tag for pure-python dist
98  setup.py
... ...
@@ -1,10 +1,9 @@
1  
-from distutils.core import setup
2  
-from distutils.command.install_data import install_data
3  
-from distutils.command.install import INSTALL_SCHEMES
4  
-from distutils.sysconfig import get_python_lib
5 1
 import os
6 2
 import sys
7 3
 
  4
+from distutils.core import setup
  5
+from distutils.sysconfig import get_python_lib
  6
+
8 7
 # Warn if we are installing over top of an existing installation. This can
9 8
 # cause issues where files that were deleted from a more recent Django are
10 9
 # still present in site-packages. See #18115.
@@ -20,28 +19,11 @@
20 19
             overlay_warning = True
21 20
             break
22 21
 
23  
-class osx_install_data(install_data):
24  
-    # On MacOS, the platform-specific lib dir is /System/Library/Framework/Python/.../
25  
-    # which is wrong. Python 2.5 supplied with MacOS 10.5 has an Apple-specific fix
26  
-    # for this in distutils.command.install_data#306. It fixes install_lib but not
27  
-    # install_data, which is why we roll our own install_data class.
28  
-
29  
-    def finalize_options(self):
30  
-        # By the time finalize_options is called, install.install_lib is set to the
31  
-        # fixed directory, so we set the installdir to install_lib. The
32  
-        # install_data class uses ('install_data', 'install_dir') instead.
33  
-        self.set_undefined_options('install', ('install_lib', 'install_dir'))
34  
-        install_data.finalize_options(self)
35  
-
36  
-if sys.platform == "darwin":
37  
-    cmdclasses = {'install_data': osx_install_data}
38  
-else:
39  
-    cmdclasses = {'install_data': install_data}
40 22
 
41 23
 def fullsplit(path, result=None):
42 24
     """
43  
-    Split a pathname into components (the opposite of os.path.join) in a
44  
-    platform-neutral way.
  25
+    Split a pathname into components (the opposite of os.path.join)
  26
+    in a platform-neutral way.
45 27
     """
46 28
     if result is None:
47 29
         result = []
@@ -52,15 +34,23 @@ def fullsplit(path, result=None):
52 34
         return result
53 35
     return fullsplit(head, [tail] + result)
54 36
 
55  
-# Tell distutils not to put the data_files in platform-specific installation
56  
-# locations. See here for an explanation:
57  
-# http://groups.google.com/group/comp.lang.python/browse_thread/thread/35ec7b2fed36eaec/2105ee4d9e8042cb
58  
-for scheme in INSTALL_SCHEMES.values():
59  
-    scheme['data'] = scheme['purelib']
  37
+
  38
+EXCLUDE_FROM_PACKAGES = ['django.conf.project_template',
  39
+                         'django.conf.app_template',
  40
+                         'django.bin']
  41
+
  42
+
  43
+def is_package(package_name):
  44
+    for pkg in EXCLUDE_FROM_PACKAGES:
  45
+        if package_name.startswith(pkg):
  46
+            return False
  47
+    return True
  48
+
60 49
 
61 50
 # Compile the list of packages available, because distutils doesn't have
62 51
 # an easy way to do this.
63  
-packages, data_files = [], []
  52
+packages, package_data = [], {}
  53
+
64 54
 root_dir = os.path.dirname(__file__)
65 55
 if root_dir != '':
66 56
     os.chdir(root_dir)
@@ -69,34 +59,38 @@ def fullsplit(path, result=None):
69 59
 for dirpath, dirnames, filenames in os.walk(django_dir):
70 60
     # Ignore PEP 3147 cache dirs and those whose names start with '.'
71 61
     dirnames[:] = [d for d in dirnames if not d.startswith('.') and d != '__pycache__']
72  
-    if '__init__.py' in filenames:
73  
-        packages.append('.'.join(fullsplit(dirpath)))
  62
+    parts = fullsplit(dirpath)
  63
+    package_name = '.'.join(parts)
  64
+    if '__init__.py' in filenames and is_package(package_name):
  65
+        packages.append(package_name)
74 66
     elif filenames:
75  
-        data_files.append([dirpath, [os.path.join(dirpath, f) for f in filenames]])
  67
+        relative_path = []
  68
+        while '.'.join(parts) not in packages:
  69
+            relative_path.append(parts.pop())
  70
+        relative_path.reverse()
  71
+        path = os.path.join(*relative_path)
  72
+        package_files = package_data.setdefault('.'.join(parts), [])
  73
+        package_files.extend([os.path.join(path, f) for f in filenames])
76 74
 
77  
-# Small hack for working with bdist_wininst.
78  
-# See http://mail.python.org/pipermail/distutils-sig/2004-August/004134.html
79  
-if len(sys.argv) > 1 and sys.argv[1] == 'bdist_wininst':
80  
-    for file_info in data_files:
81  
-        file_info[0] = '\\PURELIB\\%s' % file_info[0]
82 75
 
83 76
 # Dynamically calculate the version based on django.VERSION.
84 77
 version = __import__('django').get_version()
85 78
 
  79
+
86 80
 setup(
87  
-    name = "Django",
88  
-    version = version,
89  
-    url = 'http://www.djangoproject.com/',
90  
-    author = 'Django Software Foundation',
91  
-    author_email = 'foundation@djangoproject.com',
92  
-    description = 'A high-level Python Web framework that encourages rapid development and clean, pragmatic design.',
93  
-    download_url = 'https://www.djangoproject.com/m/releases/1.5/Django-1.5.1.tar.gz',
94  
-    license = "BSD",
95  
-    packages = packages,
96  
-    cmdclass = cmdclasses,
97  
-    data_files = data_files,
98  
-    scripts = ['django/bin/django-admin.py'],
99  
-    classifiers = [
  81
+    name='Django',
  82
+    version=version,
  83
+    url='http://www.djangoproject.com/',
  84
+    author='Django Software Foundation',
  85
+    author_email='foundation@djangoproject.com',
  86
+    description=('A high-level Python Web framework that encourages '
  87
+                 'rapid development and clean, pragmatic design.'),
  88
+    download_url='https://www.djangoproject.com/m/releases/1.5/Django-1.5.1.tar.gz',
  89
+    license='BSD',
  90
+    packages=packages,
  91
+    package_data=package_data,
  92
+    scripts=['django/bin/django-admin.py'],
  93
+    classifiers=[
100 94
         'Development Status :: 5 - Production/Stable',
101 95
         'Environment :: Web Environment',
102 96
         'Framework :: Django',
@@ -113,7 +107,7 @@ def fullsplit(path, result=None):
113 107
         'Topic :: Internet :: WWW/HTTP :: WSGI',
114 108
         'Topic :: Software Development :: Libraries :: Application Frameworks',
115 109
         'Topic :: Software Development :: Libraries :: Python Modules',
116  
-   ],
  110
+    ],
117 111
 )
118 112
 
119 113
 if overlay_warning:
@@ -134,4 +128,4 @@ def fullsplit(path, result=None):
134 128
 
135 129
 directory and re-install Django.
136 130
 
137  
-""" % { "existing_path": existing_path })
  131
+""" % {"existing_path": existing_path})

0 notes on commit 4391718

Please sign in to comment.
Something went wrong with that request. Please try again.