author | ymh <ymh.work@gmail.com> |
Thu, 02 Aug 2018 16:25:54 +0200 | |
changeset 35 | 5ad3ec36b76b |
parent 33 | 508f0fcf9ac6 |
permissions | -rw-r--r-- |
6 | 1 |
import os |
2 |
from setuptools import setup |
|
3 |
from distutils.command.install_data import install_data |
|
4 |
from distutils.command.install import INSTALL_SCHEMES |
|
5 |
import sys |
|
6 |
||
7 |
||
8 |
class osx_install_data(install_data): |
|
9 |
# On MacOS, the platform-specific lib dir is /System/Library/Framework/Python/.../ |
|
10 |
# which is wrong. Python 2.5 supplied with MacOS 10.5 has an Apple-specific fix |
|
11 |
# for this in distutils.command.install_data#306. It fixes install_lib but not |
|
12 |
# install_data, which is why we roll our own install_data class. |
|
13 |
||
14 |
def finalize_options(self): |
|
15 |
# By the time finalize_options is called, install.install_lib is set to the |
|
16 |
# fixed directory, so we set the installdir to install_lib. The |
|
17 |
# install_data class uses ('install_data', 'install_dir') instead. |
|
18 |
self.set_undefined_options('install', ('install_lib', 'install_dir')) |
|
19 |
install_data.finalize_options(self) |
|
20 |
||
21 |
def fullsplit(path, result=None): |
|
22 |
""" |
|
23 |
Split a pathname into components (the opposite of os.path.join) in a |
|
24 |
platform-neutral way. |
|
25 |
""" |
|
26 |
if result is None: |
|
27 |
result = [] |
|
28 |
head, tail = os.path.split(path) |
|
29 |
if head == '': |
|
30 |
return [tail] + result |
|
31 |
if head == path: |
|
32 |
return result |
|
33 |
return fullsplit(head, [tail] + result) |
|
34 |
||
35 |
||
36 |
def launch_setup(script_name, script_args): |
|
37 |
if sys.platform == "darwin": |
|
38 |
cmdclasses = {'install_data': osx_install_data} |
|
39 |
else: |
|
40 |
cmdclasses = {'install_data': install_data} |
|
41 |
||
42 |
||
43 |
root_dir = os.path.dirname(__file__) |
|
44 |
if root_dir != '': |
|
45 |
os.chdir(root_dir) |
|
46 |
source_dirs = ['iconolab_mcc',] |
|
47 |
||
48 |
version_variables = {} |
|
49 |
try: |
|
50 |
with open(os.path.join(source_dirs[0], "__init__.py")) as f: |
|
51 |
code = compile(f.read(), "__init__.py", 'exec') |
|
52 |
exec(code, version_variables) |
|
53 |
except: |
|
54 |
pass |
|
55 |
||
56 |
version = version_variables['__version__'] |
|
57 |
||
58 |
packages, data_files = [], [] |
|
59 |
||
60 |
for source_dir in source_dirs: |
|
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('.') or dirname.startswith('__pycache__'): 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 README.md\n") |
|
89 |
m.write("include MANIFEST.in\n") |
|
90 |
m.write("include requirements/base.txt\n") |
|
91 |
m.write("include requirements/dev.txt\n") |
|
92 |
m.write("include requirements/prod.txt\n") |
|
93 |
for entry in data_files: |
|
94 |
file_list = entry[1] |
|
95 |
for filename in file_list: |
|
96 |
m.write("include %s\n" % (filename)) |
|
97 |
||
9 | 98 |
return setup( |
6 | 99 |
script_name=script_name, |
100 |
script_args=script_args, |
|
101 |
name='iconolab_mcc', |
|
102 |
version=version, |
|
103 |
author='IRI', |
|
104 |
author_email='contact@iri.centrepompidou.fr', |
|
105 |
packages=packages, |
|
106 |
data_files=data_files, |
|
107 |
cmdclass=cmdclasses, |
|
108 |
scripts=[], |
|
109 |
url='http://www.iri.centrepompidou.fr/dev/hg/iconolab_mcc', |
|
110 |
license='LICENSE', |
|
111 |
description='projet Iconolab', |
|
112 |
long_description="Projet Iconolab", |
|
113 |
classifiers=[ |
|
114 |
'Development Status :: 4 - Beta', |
|
115 |
'Environment :: Web Environment', |
|
116 |
'Framework :: Django', |
|
117 |
'Intended Audience :: Developers', |
|
118 |
'License :: Ceccil-B', |
|
119 |
'Operating System :: OS Independent', |
|
120 |
'Programming Language :: Python', |
|
121 |
'Topic :: Utilities' |
|
122 |
], |
|
123 |
setup_requires=['setuptools_scm'], |
|
124 |
install_requires=[ |
|
125 |
"Django >= 2.0", |
|
35
5ad3ec36b76b
Update iconlab version + increment version
ymh <ymh.work@gmail.com>
parents:
33
diff
changeset
|
126 |
"iconolab == 0.1.10", |
6 | 127 |
"django-appconf", |
128 |
"django-comments-xtd", |
|
129 |
"django-contrib-comments", |
|
130 |
"elasticsearch-dsl >= 6.0, < 7.0", |
|
131 |
"django-elasticsearch-dsl", |
|
132 |
"django-notifications-hq", |
|
133 |
"elasticsearch", |
|
134 |
"jsonfield", |
|
135 |
"Pillow", |
|
136 |
"pytz", |
|
137 |
"requests", |
|
138 |
"six", |
|
139 |
"sorl-thumbnail >= 12.4.1", |
|
140 |
"djangorestframework >= 3.8" |
|
141 |
], |
|
142 |
) |
|
143 |
||
144 |
||
145 |
if __name__ == "__main__": |
|
146 |
||
147 |
script_name = os.path.basename(sys.argv[0]) |
|
148 |
script_args = sys.argv[1:] |
|
149 |
||
150 |
launch_setup(script_name, script_args) |