Fixed #19252 -- Added support for wheel packages.

Signed-off-by: Jannis Leidel <jannis@leidel.info>
This commit is contained in:
Florian Apolloner 2013-04-03 12:42:33 +02:00 committed by Jannis Leidel
parent ce45240df4
commit a5becad909
6 changed files with 69 additions and 56 deletions

View File

@ -10,7 +10,9 @@ recursive-include docs *
recursive-include scripts * recursive-include scripts *
recursive-include extras * recursive-include extras *
recursive-include tests * recursive-include tests *
recursive-include django/conf/app_template *
recursive-include django/conf/locale * recursive-include django/conf/locale *
recursive-include django/conf/project_template *
recursive-include django/contrib/*/locale * recursive-include django/contrib/*/locale *
recursive-include django/contrib/admin/templates * recursive-include django/contrib/admin/templates *
recursive-include django/contrib/admin/static * recursive-include django/contrib/admin/static *

View File

View File

@ -175,13 +175,13 @@ OK, this is the fun part, where we actually push out a release!
#. Make sure you have an absolutely clean tree by running ``git clean -dfx``. #. Make sure you have an absolutely clean tree by running ``git clean -dfx``.
#. Run ``python setup.py sdist`` to generate the release package. This will #. Run ``make -f extras/Makefile`` to generate the release packages. This will
create the release package in a ``dist/`` directory. create the release packages in a ``dist/`` directory.
#. Generate the hashes of the release package:: #. Generate the hashes of the release packages::
$ md5sum dist/Django-<version>.tar.gz $ md5sum dist/Django-*
$ sha1sum dist/Django-<version>.tar.gz $ sha1sum dist/Django-*
*FIXME: perhaps we should switch to sha256?* *FIXME: perhaps we should switch to sha256?*
@ -221,6 +221,9 @@ Now you're ready to actually put the release out there. To do this:
$ mktmpenv $ mktmpenv
$ pip install https://www.djangoproject.com/m/releases/1.5/Django-1.5.1.tar.gz $ pip install https://www.djangoproject.com/m/releases/1.5/Django-1.5.1.tar.gz
$ deactivate $ deactivate
$ mktmpenv
$ pip install https://www.djangoproject.com/m/releases/1.5/Django-1.5.1-py2.py3-none-any.whl
$ deactivate
This just tests that the tarballs are available (i.e. redirects are up) and This just tests that the tarballs are available (i.e. redirects are up) and
that they install correctly, but it'll catch silly mistakes. that they install correctly, but it'll catch silly mistakes.

9
extras/Makefile Normal file
View File

@ -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 File

@ -2,3 +2,8 @@
doc_files = docs extras AUTHORS INSTALL LICENSE README.rst doc_files = docs extras AUTHORS INSTALL LICENSE README.rst
install-script = scripts/rpm-install.sh install-script = scripts/rpm-install.sh
[metadata]
license-file = LICENSE
[wheel]
universal = 1 # use py2.py3 tag for pure-python dist

View File

@ -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 os
import sys 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 # 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 # cause issues where files that were deleted from a more recent Django are
# still present in site-packages. See #18115. # still present in site-packages. See #18115.
@ -23,28 +22,11 @@ if "install" in sys.argv:
overlay_warning = True overlay_warning = True
break 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): def fullsplit(path, result=None):
""" """
Split a pathname into components (the opposite of os.path.join) in a Split a pathname into components (the opposite of os.path.join)
platform-neutral way. in a platform-neutral way.
""" """
if result is None: if result is None:
result = [] result = []
@ -55,15 +37,23 @@ def fullsplit(path, result=None):
return result return result
return fullsplit(head, [tail] + result) return fullsplit(head, [tail] + result)
# Tell distutils not to put the data_files in platform-specific installation
# locations. See here for an explanation: EXCLUDE_FROM_PACKAGES = ['django.conf.project_template',
# http://groups.google.com/group/comp.lang.python/browse_thread/thread/35ec7b2fed36eaec/2105ee4d9e8042cb 'django.conf.app_template',
for scheme in INSTALL_SCHEMES.values(): 'django.bin']
scheme['data'] = scheme['purelib']
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 # Compile the list of packages available, because distutils doesn't have
# an easy way to do this. # an easy way to do this.
packages, data_files = [], [] packages, package_data = [], {}
root_dir = os.path.dirname(__file__) root_dir = os.path.dirname(__file__)
if root_dir != '': if root_dir != '':
os.chdir(root_dir) os.chdir(root_dir)
@ -72,33 +62,37 @@ django_dir = 'django'
for dirpath, dirnames, filenames in os.walk(django_dir): for dirpath, dirnames, filenames in os.walk(django_dir):
# Ignore PEP 3147 cache dirs and those whose names start with '.' # Ignore PEP 3147 cache dirs and those whose names start with '.'
dirnames[:] = [d for d in dirnames if not d.startswith('.') and d != '__pycache__'] dirnames[:] = [d for d in dirnames if not d.startswith('.') and d != '__pycache__']
if '__init__.py' in filenames: parts = fullsplit(dirpath)
packages.append('.'.join(fullsplit(dirpath))) package_name = '.'.join(parts)
if '__init__.py' in filenames and is_package(package_name):
packages.append(package_name)
elif filenames: 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. # Dynamically calculate the version based on django.VERSION.
version = __import__('django').get_version() version = __import__('django').get_version()
setup( setup(
name = "Django", name='Django',
version = version, version=version,
url = 'http://www.djangoproject.com/', url='http://www.djangoproject.com/',
author = 'Django Software Foundation', author='Django Software Foundation',
author_email = 'foundation@djangoproject.com', author_email='foundation@djangoproject.com',
description = 'A high-level Python Web framework that encourages rapid development and clean, pragmatic design.', description=('A high-level Python Web framework that encourages '
license = "BSD", 'rapid development and clean, pragmatic design.'),
packages = packages, license='BSD',
cmdclass = cmdclasses, packages=packages,
data_files = data_files, package_data=package_data,
scripts = ['django/bin/django-admin.py'], scripts=['django/bin/django-admin.py'],
classifiers = [ classifiers=[
'Development Status :: 5 - Production/Stable', 'Development Status :: 5 - Production/Stable',
'Environment :: Web Environment', 'Environment :: Web Environment',
'Framework :: Django', 'Framework :: Django',
@ -136,4 +130,4 @@ should manually remove the
directory and re-install Django. directory and re-install Django.
""" % { "existing_path": existing_path }) """ % {"existing_path": existing_path})