Permalink
Browse files

[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...
apollo13 authored and jezdez committed Apr 3, 2013
1 parent 8b34561 commit 4391718f26466f82f943e37368181d5c0520fa35
Showing with 62 additions and 52 deletions.
  1. +2 −0 MANIFEST.in
  2. 0 django/bin/__init__.py
  3. +9 −0 extras/Makefile
  4. +5 −0 setup.cfg
  5. +46 −52 setup.py
View
@@ -10,7 +10,9 @@ recursive-include docs *
recursive-include scripts *
recursive-include extras *
recursive-include tests *
recursive-include django/conf/app_template *
recursive-include django/conf/locale *
recursive-include django/conf/project_template *
recursive-include django/contrib/*/locale *
recursive-include django/contrib/admin/templates *
recursive-include django/contrib/admin/static *
View
No changes.
View
@@ -0,0 +1,9 @@
all: sdist bdist_wheel
sdist:
python setup.py sdist
bdist_wheel:
python -c "import setuptools;__file__='setup.py';exec(compile(open(__file__).read().replace('\\r\\n', '\\n'), __file__, 'exec'))" bdist_wheel
.PHONY : sdist bdist_wheel
View
@@ -2,3 +2,8 @@
doc_files = docs extras AUTHORS INSTALL LICENSE README.rst
install-script = scripts/rpm-install.sh
[metadata]
license-file = LICENSE
[wheel]
universal = 1 # use py2.py3 tag for pure-python dist
View
@@ -1,10 +1,9 @@
from distutils.core import setup
from distutils.command.install_data import install_data
from distutils.command.install import INSTALL_SCHEMES
from distutils.sysconfig import get_python_lib
import os
import sys
from distutils.core import setup
from distutils.sysconfig import get_python_lib
# 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.
@@ -20,28 +19,11 @@
overlay_warning = True
break
class osx_install_data(install_data):
# On MacOS, the platform-specific lib dir is /System/Library/Framework/Python/.../
# which is wrong. Python 2.5 supplied with MacOS 10.5 has an Apple-specific fix
# for this in distutils.command.install_data#306. It fixes install_lib but not
# install_data, which is why we roll our own install_data class.
def finalize_options(self):
# By the time finalize_options is called, install.install_lib is set to the
# fixed directory, so we set the installdir to install_lib. The
# install_data class uses ('install_data', 'install_dir') instead.
self.set_undefined_options('install', ('install_lib', 'install_dir'))
install_data.finalize_options(self)
if sys.platform == "darwin":
cmdclasses = {'install_data': osx_install_data}
else:
cmdclasses = {'install_data': install_data}
def fullsplit(path, result=None):
"""
Split a pathname into components (the opposite of os.path.join) in a
platform-neutral way.
Split a pathname into components (the opposite of os.path.join)
in a platform-neutral way.
"""
if result is None:
result = []
@@ -52,15 +34,23 @@ def fullsplit(path, result=None):
return result
return fullsplit(head, [tail] + result)
# Tell distutils not to put the data_files in platform-specific installation
# locations. See here for an explanation:
# http://groups.google.com/group/comp.lang.python/browse_thread/thread/35ec7b2fed36eaec/2105ee4d9e8042cb
for scheme in INSTALL_SCHEMES.values():
scheme['data'] = scheme['purelib']
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
# Compile the list of packages available, because distutils doesn't have
# an easy way to do this.
packages, data_files = [], []
packages, package_data = [], {}
root_dir = os.path.dirname(__file__)
if root_dir != '':
os.chdir(root_dir)
@@ -69,34 +59,38 @@ def fullsplit(path, result=None):
for dirpath, dirnames, filenames in os.walk(django_dir):
# Ignore PEP 3147 cache dirs and those whose names start with '.'
dirnames[:] = [d for d in dirnames if not d.startswith('.') and d != '__pycache__']
if '__init__.py' in filenames:
packages.append('.'.join(fullsplit(dirpath)))
parts = fullsplit(dirpath)
package_name = '.'.join(parts)
if '__init__.py' in filenames and is_package(package_name):
packages.append(package_name)
elif filenames:
data_files.append([dirpath, [os.path.join(dirpath, f) for f in filenames]])
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])
# Small hack for working with bdist_wininst.
# See http://mail.python.org/pipermail/distutils-sig/2004-August/004134.html
if len(sys.argv) > 1 and sys.argv[1] == 'bdist_wininst':
for file_info in data_files:
file_info[0] = '\\PURELIB\\%s' % file_info[0]
# Dynamically calculate the version based on django.VERSION.
version = __import__('django').get_version()
setup(
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.',
download_url = 'https://www.djangoproject.com/m/releases/1.5/Django-1.5.1.tar.gz',
license = "BSD",
packages = packages,
cmdclass = cmdclasses,
data_files = data_files,
scripts = ['django/bin/django-admin.py'],
classifiers = [
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.'),
download_url='https://www.djangoproject.com/m/releases/1.5/Django-1.5.1.tar.gz',
license='BSD',
packages=packages,
package_data=package_data,
scripts=['django/bin/django-admin.py'],
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Web Environment',
'Framework :: Django',
@@ -113,7 +107,7 @@ def fullsplit(path, result=None):
'Topic :: Internet :: WWW/HTTP :: WSGI',
'Topic :: Software Development :: Libraries :: Application Frameworks',
'Topic :: Software Development :: Libraries :: Python Modules',
],
],
)
if overlay_warning:
@@ -134,4 +128,4 @@ def fullsplit(path, result=None):
directory and re-install Django.
""" % { "existing_path": existing_path })
""" % {"existing_path": existing_path})

0 comments on commit 4391718

Please sign in to comment.