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