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