Ticket #7414: setup-data-files-macos-r7732.diff

File setup-data-files-macos-r7732.diff, 2.2 KB (added by ajs, 7 years ago)

fix for datafiles being installedin the wrong location

  • setup.py

     
    11from distutils.core import setup
     2from distutils.command.install_data import install_data
    23from distutils.command.install import INSTALL_SCHEMES
    34import os
    45import sys
    56
     7# On MacOS the plattform specific lib dir is /System/Library/Framework/Python/.../ which is wrong.
     8# Python 2.5 supplied with MacOS 10.5 has an Aplle specific fix for this in distutils.command.install_data#306
     9# It fixes install_lib but not install_data, which is why we roll our own install_data class.
     10
     11class django_install_data( install_data ):
     12#   By the time finalize_options is called install.install_lib is set to the fixed directory.
     13#   so we set the installdir for to install_lib, the install_data class uses ('install_data', 'install_dir') instead.
     14    def finalize_options (self):
     15        self.set_undefined_options('install',
     16                                    ('install_lib', 'install_dir')
     17                                   )
     18        install_data.finalize_options(self)
     19
    620def fullsplit(path, result=None):
    721    """
    822    Split a pathname into components (the opposite of os.path.join) in a
     
    1731        return result
    1832    return fullsplit(head, [tail] + result)
    1933
     34# On darwin we nee to use the django specific install_data class so the data_files are installed into the correct location.
     35# On the other platform we use the default class.
     36if sys.platform == "darwin":
     37    cmdclasses = {'install_data': django_install_data }
     38else:
     39    cmdclasses = {'install_data': install_data }
     40
    2041# Tell distutils to put the data_files in platform-specific installation
    2142# locations. See here for an explanation:
    2243# http://groups.google.com/group/comp.lang.python/browse_thread/thread/35ec7b2fed36eaec/2105ee4d9e8042cb
     
    5576    author_email = 'foundation@djangoproject.com',
    5677    description = 'A high-level Python Web framework that encourages rapid development and clean, pragmatic design.',
    5778    packages = packages,
     79    cmdclass = cmdclasses,
    5880    data_files = data_files,
    5981    scripts = ['django/bin/django-admin.py'],
    6082)
Back to Top