Thread limit fetching
[canto-next.git] / setup.py
1 #!/usr/bin/env python3
2
3 from distutils.command.install_data import install_data
4 from distutils.command.build_py import build_py
5 from distutils.core import setup
6 import subprocess
7 import glob
8 import os
9
10 string_version = "0.9.1"
11
12 changes = ['canto_backend.py','remote.py']
13
14 class canto_next_build_py(build_py):
15     def run(self):
16         for source in changes:
17             os.utime("canto_next/" + source)
18         build_py.run(self)
19
20 class canto_next_install_data(install_data):
21     def run(self):
22         try:
23             git_hash = subprocess.check_output(["git", "describe"]).decode("UTF-8")[-9:-1]
24         except Exception as e:
25             print(e)
26             git_hash = ""
27
28         install_data.run(self)
29
30         install_cmd = self.get_finalized_command('install')
31         libdir = install_cmd.install_lib
32
33         for source in changes:
34             with open(libdir + '/canto_next/' + source, 'r+') as f:
35                 d = f.read().replace("REPLACE_VERSION", "\"" + string_version + "\"")
36                 d = d.replace("GIT_HASH", "\"" + git_hash + "\"")
37                 f.truncate(0)
38                 f.seek(0)
39                 f.write(d)
40
41 setup(name='Canto',
42       version=string_version,
43       description='Next-gen console RSS/Atom reader',
44       author='Jack Miller',
45       author_email='jack@codezen.org',
46       license='GPLv2',
47       url='http://codezen.org/canto-ng',
48       download_url='http://codezen.org/static/canto-daemon-' + string_version + '.tar.gz',
49       packages=['canto_next'],
50       scripts=['bin/canto-daemon','bin/canto-remote'],
51       data_files = [("share/man/man1/", ["man/canto-daemon.1", "man/canto-remote.1"]),
52                     ("lib/systemd/user", ["systemd/user/canto-daemon.service"]),
53                     ("lib/canto/plugins", glob.glob("plugins/*.py"))],
54       cmdclass = {  'install_data' : canto_next_install_data,
55                     'build_py' : canto_next_build_py },
56 )