comparison setup.py @ 147:33c7ce833d3f

install: setup.py fix + moved "default" dir in a "sat_templates" dir: the merge request at https://bugs.goffi.org/mr/view/3 was a good basis, but not fully working ("default" dir was removed), this patch fixes it, and do some improvments: - moved "default" in "sat_templates" dir, which correspond to the python module, so it can be found easily from python - added VERSION, and mercurial hash detection, in the same way as for Cagou and backend - slight modification of classifiers - replaces tabs coming from MR by spaces
author Goffi <goffi@goffi.org>
date Sat, 02 Jun 2018 17:25:43 +0200
parents 7dc00829c32f
children a4b6b8b6fc58
comparison
equal deleted inserted replaced
146:7dc00829c32f 147:33c7ce833d3f
1 #!/usr/bin/env python2 1 #!/usr/bin/env python2
2 # -*- coding: utf-8 -*- 2 # -*- coding: utf-8 -*-
3 3
4 # SàT templates: collection of templates 4 # SàT templates: collection of templates
5 # Copyright (C) 2017 Xavier Maillard (xavier@maillard.im) 5 # Copyright (C) 2017 Xavier Maillard (xavier@maillard.im)
6 6
7 # This program is free software: you can redistribute it and/or modify 7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU Affero General Public License as published by 8 # it under the terms of the GNU Affero General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or 9 # the Free Software Foundation, either version 3 of the License, or
17 # You should have received a copy of the GNU Affero General Public License 17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. 18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 19
20 import os 20 import os
21 import sys 21 import sys
22 from setuptools import setup, find_packages 22 from setuptools import setup
23 23
24 base = None 24 base = None
25 NAME = 'sat_templates' 25 NAME = 'sat_templates'
26 is_wheel = 'bdist_wheel' in sys.argv 26 is_wheel = 'bdist_wheel' in sys.argv
27 27
28 # https://stackoverflow.com/a/36693250 28 # https://stackoverflow.com/a/36693250
29 29
30 def get_data_templates_files(directory): 30 def get_package_data(directory):
31 paths = [] 31 paths = []
32 for (path, directories, filenames) in os.walk(directory): 32 for (path, directories, filenames) in os.walk(directory):
33 for filename in filenames: 33 for filename in filenames:
34 paths.append(os.path.join('..', path, filename)) 34 paths.append(os.path.join('..', path, filename))
35 return paths 35 return paths
36 36
37 data_templates_files = get_data_templates_files('default') 37
38 with open(os.path.join(NAME, 'VERSION')) as f:
39 VERSION = f.read().strip()
40 is_dev_version = VERSION.endswith('D')
41
42
43 def sat_templates_dev_version():
44 """Use mercurial data to compute version"""
45 def version_scheme(version):
46 return VERSION.replace('D', '.dev0')
47
48 def local_scheme(version):
49 return "+{rev}.{distance}".format(
50 rev=version.node[1:],
51 distance=version.distance)
52
53 return {'version_scheme': version_scheme,
54 'local_scheme': local_scheme}
55
38 56
39 setup_info = dict( 57 setup_info = dict(
40 name=NAME, 58 name=NAME,
41 version= '0.7D', 59 version= '0.7D',
42 author='Association « Salut à Toi »', 60 author='Association « Salut à Toi »',
43 author_email='contact@salut-a-toi.org', 61 author_email='contact@salut-a-toi.org',
44 url='https://salut-a-toi.org', 62 url='https://salut-a-toi.org',
45 classifiers=['Development Status :: 3 - Alpha', 63 classifiers=['Development Status :: 3 - Alpha',
64 'Programming Language :: Python :: 2.7',
65 'Programming Language :: Python :: 2 :: Only',
46 'License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)', 66 'License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)',
47 'Operating System :: POSIX :: Linux', 67 ],
48 'Topic :: Communications :: Chat'],
49 install_requires=[], 68 install_requires=[],
69 setup_requires=['setuptools_scm'] if is_dev_version else [],
70 use_scm_version=sat_templates_dev_version if is_dev_version else False,
50 packages=['sat_templates'], 71 packages=['sat_templates'],
51 package_dir={'sat_templates':'default'}, 72 package_data={'sat_templates': get_package_data('sat_templates') },
52 package_data={'': data_templates_files },
53 data_files=[(os.path.join(sys.prefix, 'share/locale/fr/LC_MESSAGES'), ['i18n/fr/LC_MESSAGES/sat.mo']), 73 data_files=[(os.path.join(sys.prefix, 'share/locale/fr/LC_MESSAGES'), ['i18n/fr/LC_MESSAGES/sat.mo']),
54 ('share/doc/%s' % NAME, ['COPYING']), 74 ('share/doc/%s' % NAME, ['COPYING']),
55 ], 75 ],
56 zip_safe=True, 76 zip_safe=True,
57 ) 77 )