Code

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

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

fix for datafiles being installedin the wrong location

Line 
1Index: setup.py
2===================================================================
3--- setup.py    (revision 7737)
4+++ setup.py    (working copy)
5@@ -1,8 +1,22 @@
6 from distutils.core import setup
7+from distutils.command.install_data import install_data
8 from distutils.command.install import INSTALL_SCHEMES
9 import os
10 import sys
11 
12+# On MacOS the plattform specific lib dir is /System/Library/Framework/Python/.../ which is wrong.
13+# Python 2.5 supplied with MacOS 10.5 has an Aplle specific fix for this in distutils.command.install_data#306
14+# It fixes install_lib but not install_data, which is why we roll our own install_data class.
15+
16+class django_install_data( install_data ):
17+#   By the time finalize_options is called install.install_lib is set to the fixed directory.
18+#   so we set the installdir for to install_lib, the install_data class uses ('install_data', 'install_dir') instead.
19+    def finalize_options (self):
20+        self.set_undefined_options('install',
21+                                    ('install_lib', 'install_dir')
22+                                   )
23+        install_data.finalize_options(self)
24+
25 def fullsplit(path, result=None):
26     """
27     Split a pathname into components (the opposite of os.path.join) in a
28@@ -17,6 +31,13 @@
29         return result
30     return fullsplit(head, [tail] + result)
31 
32+# On darwin we nee to use the django specific install_data class so the data_files are installed into the correct location.
33+# On the other platform we use the default class.
34+if sys.platform == "darwin":
35+    cmdclasses = {'install_data': django_install_data }
36+else:
37+    cmdclasses = {'install_data': install_data }
38+
39 # Tell distutils to put the data_files in platform-specific installation
40 # locations. See here for an explanation:
41 # http://groups.google.com/group/comp.lang.python/browse_thread/thread/35ec7b2fed36eaec/2105ee4d9e8042cb
42@@ -55,6 +76,7 @@
43     author_email = 'foundation@djangoproject.com',
44     description = 'A high-level Python Web framework that encourages rapid development and clean, pragmatic design.',
45     packages = packages,
46+    cmdclass = cmdclasses,
47     data_files = data_files,
48     scripts = ['django/bin/django-admin.py'],
49 )