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
51import os
62import sys
73
4+ from distutils .core import setup
5+ from distutils .sysconfig import get_python_lib
6+
87# Warn if we are installing over top of an existing installation. This can
98# cause issues where files that were deleted from a more recent Django are
109# still present in site-packages. See #18115.
2322 overlay_warning = True
2423 break
2524
26- class osx_install_data (install_data ):
27- # On MacOS, the platform-specific lib dir is /System/Library/Framework/Python/.../
28- # which is wrong. Python 2.5 supplied with MacOS 10.5 has an Apple-specific fix
29- # for this in distutils.command.install_data#306. It fixes install_lib but not
30- # install_data, which is why we roll our own install_data class.
31-
32- def finalize_options (self ):
33- # By the time finalize_options is called, install.install_lib is set to the
34- # fixed directory, so we set the installdir to install_lib. The
35- # install_data class uses ('install_data', 'install_dir') instead.
36- self .set_undefined_options ('install' , ('install_lib' , 'install_dir' ))
37- install_data .finalize_options (self )
38-
39- if sys .platform == "darwin" :
40- cmdclasses = {'install_data' : osx_install_data }
41- else :
42- cmdclasses = {'install_data' : install_data }
4325
4426def fullsplit (path , result = None ):
4527 """
46- Split a pathname into components (the opposite of os.path.join) in a
47- platform-neutral way.
28+ Split a pathname into components (the opposite of os.path.join)
29+ in a platform-neutral way.
4830 """
4931 if result is None :
5032 result = []
@@ -55,15 +37,23 @@ def fullsplit(path, result=None):
5537 return result
5638 return fullsplit (head , [tail ] + result )
5739
58- # Tell distutils not to put the data_files in platform-specific installation
59- # locations. See here for an explanation:
60- # http://groups.google.com/group/comp.lang.python/browse_thread/thread/35ec7b2fed36eaec/2105ee4d9e8042cb
61- for scheme in INSTALL_SCHEMES .values ():
62- scheme ['data' ] = scheme ['purelib' ]
40+
41+ EXCLUDE_FROM_PACKAGES = ['django.conf.project_template' ,
42+ 'django.conf.app_template' ,
43+ 'django.bin' ]
44+
45+
46+ def is_package (package_name ):
47+ for pkg in EXCLUDE_FROM_PACKAGES :
48+ if package_name .startswith (pkg ):
49+ return False
50+ return True
51+
6352
6453# Compile the list of packages available, because distutils doesn't have
6554# an easy way to do this.
66- packages , data_files = [], []
55+ packages , package_data = [], {}
56+
6757root_dir = os .path .dirname (__file__ )
6858if root_dir != '' :
6959 os .chdir (root_dir )
@@ -72,33 +62,37 @@ def fullsplit(path, result=None):
7262for dirpath , dirnames , filenames in os .walk (django_dir ):
7363 # Ignore PEP 3147 cache dirs and those whose names start with '.'
7464 dirnames [:] = [d for d in dirnames if not d .startswith ('.' ) and d != '__pycache__' ]
75- if '__init__.py' in filenames :
76- packages .append ('.' .join (fullsplit (dirpath )))
65+ parts = fullsplit (dirpath )
66+ package_name = '.' .join (parts )
67+ if '__init__.py' in filenames and is_package (package_name ):
68+ packages .append (package_name )
7769 elif filenames :
78- data_files .append ([dirpath , [os .path .join (dirpath , f ) for f in filenames ]])
70+ relative_path = []
71+ while '.' .join (parts ) not in packages :
72+ relative_path .append (parts .pop ())
73+ relative_path .reverse ()
74+ path = os .path .join (* relative_path )
75+ package_files = package_data .setdefault ('.' .join (parts ), [])
76+ package_files .extend ([os .path .join (path , f ) for f in filenames ])
7977
80- # Small hack for working with bdist_wininst.
81- # See http://mail.python.org/pipermail/distutils-sig/2004-August/004134.html
82- if len (sys .argv ) > 1 and sys .argv [1 ] == 'bdist_wininst' :
83- for file_info in data_files :
84- file_info [0 ] = '\\ PURELIB\\ %s' % file_info [0 ]
8578
8679# Dynamically calculate the version based on django.VERSION.
8780version = __import__ ('django' ).get_version ()
8881
82+
8983setup (
90- name = " Django" ,
91- version = version ,
92- url = 'http://www.djangoproject.com/' ,
93- author = 'Django Software Foundation' ,
94- author_email = '[email protected] ' ,
95- description = 'A high-level Python Web framework that encourages rapid development and clean, pragmatic design.' ,
96- license = "BSD" ,
97- packages = packages ,
98- cmdclass = cmdclasses ,
99- data_files = data_files ,
100- scripts = ['django/bin/django-admin.py' ],
101- classifiers = [
84+ name = ' Django' ,
85+ version = version ,
86+ url = 'http://www.djangoproject.com/' ,
87+ author = 'Django Software Foundation' ,
88+ 89+ description = ( 'A high-level Python Web framework that encourages '
90+ 'rapid development and clean, pragmatic design.' ) ,
91+ license = 'BSD' ,
92+ packages = packages ,
93+ package_data = package_data ,
94+ scripts = ['django/bin/django-admin.py' ],
95+ classifiers = [
10296 'Development Status :: 5 - Production/Stable' ,
10397 'Environment :: Web Environment' ,
10498 'Framework :: Django' ,
@@ -115,7 +109,7 @@ def fullsplit(path, result=None):
115109 'Topic :: Internet :: WWW/HTTP :: WSGI' ,
116110 'Topic :: Software Development :: Libraries :: Application Frameworks' ,
117111 'Topic :: Software Development :: Libraries :: Python Modules' ,
118- ],
112+ ],
119113)
120114
121115if overlay_warning :
@@ -136,4 +130,4 @@ def fullsplit(path, result=None):
136130
137131directory and re-install Django.
138132
139- """ % { "existing_path" : existing_path })
133+ """ % {"existing_path" : existing_path })
0 commit comments