| author | verrierj |
| Wed, 23 Nov 2011 13:55:23 +0100 | |
| changeset 247 | f98f1a6e15f1 |
| parent 189 | 08e6b5dbfc93 |
| child 627 | f5c55582565d |
| permissions | -rw-r--r-- |
| 0 | 1 |
import os |
| 189 | 2 |
from distutils.core import setup |
3 |
from distutils.command.install_data import install_data |
|
4 |
from distutils.command.install import INSTALL_SCHEMES |
|
5 |
import sys |
|
|
48
ef3a8cfef2bc
correct setup.py to integrate templsters
ymh <ymh.work@gmail.com>
parents:
30
diff
changeset
|
6 |
|
| 189 | 7 |
class osx_install_data(install_data): |
8 |
# On MacOS, the platform-specific lib dir is /System/Library/Framework/Python/.../ |
|
9 |
# which is wrong. Python 2.5 supplied with MacOS 10.5 has an Apple-specific fix |
|
10 |
# for this in distutils.command.install_data#306. It fixes install_lib but not |
|
11 |
# install_data, which is why we roll our own install_data class. |
|
12 |
||
13 |
def finalize_options(self): |
|
14 |
# By the time finalize_options is called, install.install_lib is set to the |
|
15 |
# fixed directory, so we set the installdir to install_lib. The |
|
16 |
# install_data class uses ('install_data', 'install_dir') instead. |
|
17 |
self.set_undefined_options('install', ('install_lib', 'install_dir')) |
|
18 |
install_data.finalize_options(self) |
|
| 0 | 19 |
|
| 189 | 20 |
if sys.platform == "darwin": |
21 |
cmdclasses = {'install_data': osx_install_data} |
|
22 |
else: |
|
23 |
cmdclasses = {'install_data': install_data} |
|
24 |
||
25 |
||
26 |
root_dir = os.path.dirname(__file__) |
|
27 |
if root_dir != '': |
|
28 |
os.chdir(root_dir) |
|
29 |
source_dir = 'ldt' |
|
| 0 | 30 |
|
|
84
91a4dafd5904
improve setup and debug lucene calls
ymh <ymh.work@gmail.com>
parents:
63
diff
changeset
|
31 |
version_variables = {} |
|
91a4dafd5904
improve setup and debug lucene calls
ymh <ymh.work@gmail.com>
parents:
63
diff
changeset
|
32 |
try: |
| 189 | 33 |
execfile(os.path.join(source_dir, "__init__.py"), version_variables) |
|
84
91a4dafd5904
improve setup and debug lucene calls
ymh <ymh.work@gmail.com>
parents:
63
diff
changeset
|
34 |
except: |
|
91a4dafd5904
improve setup and debug lucene calls
ymh <ymh.work@gmail.com>
parents:
63
diff
changeset
|
35 |
pass |
|
91a4dafd5904
improve setup and debug lucene calls
ymh <ymh.work@gmail.com>
parents:
63
diff
changeset
|
36 |
|
|
91a4dafd5904
improve setup and debug lucene calls
ymh <ymh.work@gmail.com>
parents:
63
diff
changeset
|
37 |
version = version_variables['__version__'] |
| 0 | 38 |
|
| 189 | 39 |
def fullsplit(path, result=None): |
| 3 | 40 |
""" |
41 |
Split a pathname into components (the opposite of os.path.join) in a |
|
42 |
platform-neutral way. |
|
43 |
""" |
|
44 |
if result is None: |
|
| 30 | 45 |
result = [] |
| 3 | 46 |
head, tail = os.path.split(path) |
47 |
if head == '': |
|
48 |
return [tail] + result |
|
49 |
if head == path: |
|
50 |
return result |
|
| 189 | 51 |
return fullsplit(head, [tail] + result) |
| 3 | 52 |
|
| 189 | 53 |
packages, data_files = [], [] |
| 2 | 54 |
|
| 189 | 55 |
|
56 |
for dirpath, dirnames, filenames in os.walk(source_dir): |
|
| 2 | 57 |
# Ignore dirnames that start with '.' |
58 |
for i, dirname in enumerate(dirnames): |
|
59 |
if dirname.startswith('.'): del dirnames[i] |
|
60 |
if '__init__.py' in filenames: |
|
| 189 | 61 |
packages.append('.'.join(fullsplit(dirpath))) |
62 |
elif filenames: |
|
63 |
data_files.append([dirpath, [os.path.join(dirpath, f) for f in filenames]]) |
|
64 |
||
65 |
||
66 |
# Tell distutils to put the data_files in platform-specific installation |
|
67 |
# locations. See here for an explanation: |
|
68 |
# http://groups.google.com/group/comp.lang.python/browse_thread/thread/35ec7b2fed36eaec/2105ee4d9e8042cb |
|
69 |
for scheme in INSTALL_SCHEMES.values(): |
|
70 |
scheme['data'] = scheme['purelib'] |
|
71 |
||
72 |
# Small hack for working with bdist_wininst. |
|
73 |
# See http://mail.python.org/pipermail/distutils-sig/2004-August/004134.html |
|
74 |
if len(sys.argv) > 1 and sys.argv[1] == 'bdist_wininst': |
|
75 |
for file_info in data_files: |
|
76 |
file_info[0] = '\\PURELIB\\%s' % file_info[0] |
|
| 30 | 77 |
|
|
48
ef3a8cfef2bc
correct setup.py to integrate templsters
ymh <ymh.work@gmail.com>
parents:
30
diff
changeset
|
78 |
#write MANIFEST.in |
|
ef3a8cfef2bc
correct setup.py to integrate templsters
ymh <ymh.work@gmail.com>
parents:
30
diff
changeset
|
79 |
|
| 189 | 80 |
with open("MANIFEST.in", "w") as m: |
81 |
m.write("include CHANGES\n") |
|
82 |
m.write("include LICENSE\n") |
|
83 |
m.write("include README\n") |
|
84 |
m.write("include MANIFEST.in\n") |
|
85 |
for entry in data_files: |
|
86 |
file_list = entry[1] |
|
87 |
for filename in file_list: |
|
88 |
m.write("include %s\n" % (filename)) |
|
|
48
ef3a8cfef2bc
correct setup.py to integrate templsters
ymh <ymh.work@gmail.com>
parents:
30
diff
changeset
|
89 |
|
| 2 | 90 |
|
| 0 | 91 |
setup( |
| 30 | 92 |
name='ldt', |
|
13
97ab7b3191cf
add api to update project, uses psiton
ymh <ymh.work@gmail.com>
parents:
3
diff
changeset
|
93 |
version=version, |
| 189 | 94 |
author='IRI', |
|
13
97ab7b3191cf
add api to update project, uses psiton
ymh <ymh.work@gmail.com>
parents:
3
diff
changeset
|
95 |
author_email='contact@iri.centrepompidou.fr', |
| 63 | 96 |
packages=packages, |
| 189 | 97 |
data_files=data_files, |
98 |
cmdclass = cmdclasses, |
|
|
13
97ab7b3191cf
add api to update project, uses psiton
ymh <ymh.work@gmail.com>
parents:
3
diff
changeset
|
99 |
scripts=[], |
| 189 | 100 |
url='http://www.iri.centrepompidou.fr/dev/hg/platform', |
|
13
97ab7b3191cf
add api to update project, uses psiton
ymh <ymh.work@gmail.com>
parents:
3
diff
changeset
|
101 |
license='LICENSE.txt', |
|
97ab7b3191cf
add api to update project, uses psiton
ymh <ymh.work@gmail.com>
parents:
3
diff
changeset
|
102 |
description='Platform ldt', |
| 189 | 103 |
long_description=open('README').read(), |
|
13
97ab7b3191cf
add api to update project, uses psiton
ymh <ymh.work@gmail.com>
parents:
3
diff
changeset
|
104 |
classifiers=['Development Status :: 5 - Production/Stable', |
| 0 | 105 |
'Environment :: Web Environment', |
106 |
'Framework :: Django', |
|
107 |
'Intended Audience :: Developers', |
|
108 |
'License :: Ceccil-C', |
|
109 |
'Operating System :: OS Independent', |
|
110 |
'Programming Language :: Python', |
|
| 189 | 111 |
'Topic :: Utilities', |
112 |
], |
|
| 0 | 113 |
) |