Fix test-tagcore-function for new init
[canto-curses.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, Extension
6 import subprocess
7 import glob
8 import os
9
10 string_version = "0.9.3"
11
12 class canto_curses_build_py(build_py):
13     def run(self):
14         os.utime("canto_curses/main.py", None)
15         build_py.run(self)
16
17 class canto_curses_install_data(install_data):
18     def run(self):
19         try:
20             git_hash = subprocess.check_output(["git", "describe"]).decode("UTF-8")[-9:-1]
21         except Exception as e:
22             print(e)
23             git_hash = ""
24
25         install_data.run(self)
26
27         install_cmd = self.get_finalized_command('install')
28         libdir = install_cmd.install_lib
29
30         with open(libdir + '/canto_curses/main.py', 'r+') as f:
31             d = f.read().replace("VERSION", "\"" + string_version + "\"")
32             d = d.replace("GIT_HASH", "\"" + git_hash + "\"")
33             f.truncate(0)
34             f.seek(0)
35             f.write(d)
36
37 setup(name='Canto-curses',
38       version=string_version,
39       description='Next-gen console RSS/Atom reader',
40       author='Jack Miller',
41       author_email='jack@codezen.org',
42       license='GPLv2',
43       download_url='http://codezen.org/static/canto-curses-' + string_version + ".tar.gz",
44       url='http://codezen.org/canto-ng',
45       packages=['canto_curses'],
46       ext_modules=[ Extension('canto_curses.widecurse',\
47               sources = ['canto_curses/widecurse.c'],
48               libraries = ['ncursesw', 'readline'],
49               library_dirs = ["/usr/local/lib", "/opt/local/lib"],
50               include_dirs = ["/usr/local/include", "/opt/local/include"])],
51       scripts=['bin/canto-curses'],
52       data_files = [("share/man/man1/", ["man/canto-curses.1"]),
53                     ("lib/canto/plugins/", glob.glob('plugins/*.py'))],
54       cmdclass = {  'install_data' : canto_curses_install_data,
55                     'build_py' : canto_curses_build_py},
56      )