File: setup.py

package info (click to toggle)
cyclograph 1.9.1-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, sid
  • size: 1,064 kB
  • sloc: python: 5,695; makefile: 3
file content (153 lines) | stat: -rwxr-xr-x 5,415 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#!/usr/bin/env python3
from distutils.core import setup
from distutils.command.build_py import build_py
from distutils.command.clean import clean
from distutils.cmd import Command
import distutils.log
from cyclograph.version import VERSION
import glob
import os
import subprocess

files = ["openlayers.html",
         "map.html",
         "google.css",
         "draw_on_map.js"]

icons = glob.glob('pixmaps/32x32/*.png') + glob.glob('pixmaps/*svg')

class pyrcc(Command):
    description = "Run pyrcc to generate pyqt resource file"
    user_options = []
    def initialize_options(self):
        pass
    def finalize_options(self):
        pass
    def run(self):
        command = ['/usr/bin/pyrcc5',
                   '-o', 'cyclograph/qt/cyclograph_rc.py',
                   'qt_ui/cyclograph.qrc']
        self.announce("Running: %s" % " ".join(command), level=distutils.log.INFO)
        #We set the seed to 0 as environmental variable to obtain
        #a reproducible build
        subprocess.check_call(command, env={'QT_HASH_SEED':'0'})

class genhtml(Command):
    description = "Generate html user manual from asciidoc file"
    user_options = []
    def initialize_options(self):
        pass
    def finalize_options(self):
        pass
    def run(self):
        command = ['asciidoc', 
                   '-b', 'html5', 
                   '--section-numbers', 
                   '-a', 'footer-style=none', 
                   'doc/manual.txt']
        subprocess.check_call(command)

class pyuic(Command):
    description = "Generate python from designer ui files"
    user_options = []
    def initialize_options(self):
        pass
    def finalize_options(self):
        pass
    def run(self):
        command = ['./build.py']
        #The script is designed to be run from the qt_ui directory
        subprocess.check_call(command, cwd='qt_ui')

class msgfmt(Command):
    description = "Run gettext to generate .mo files"
    user_options = []
    def initialize_options(self):
        pass
    def finalize_options(self):
        pass
    def run(self):
        for lang in ['en', 'it']:
            filename = 'po/%s/LC_MESSAGES/cyclograph' % lang
            fnamein = filename + '.po'
            fnameout = filename + '.mo'
            subprocess.check_call(['msgfmt', fnamein, '-o', fnameout])

class generate_all(Command):
    description = "Run all the file generators"
    user_options = []
    def initialize_options(self):
        pass
    def finalize_options(self):
        pass
    def run(self):
        self.run_command("pyrcc")
        self.run_command("pyuic")
        self.run_command("html")
        self.run_command("msgfmt")

class my_build_py(build_py):
    def run(self):
        nogeneratepath = os.path.join(os.path.dirname(__file__), 'no-generate.stamp')
        if not os.path.exists(nogeneratepath):
            self.run_command('generate')
        build_py.run(self)

class my_clean(clean):
    def run(self):
        files = ['cyclograph/qt/cyclograph_rc.py',
                 'cyclograph/qt/ui_qt.py',
                 'doc/manual.html']
        files += glob.glob('qt_ui/ui_*.py')
        files += ['po/en/LC_MESSAGES/cyclograph.mo',
                  'po/it/LC_MESSAGES/cyclograph.mo']
        for f in files:
            try:
                os.remove(f)
            except OSError as e:
                pass #print(e)
        #run standard clean
        clean.run(self)

setup(name = "cyclograph",
    version = VERSION,
    description = "route altimetry plotting application",
    author = "Federico Brega, Pierluigi Villani",
    author_email = "charon66@users.sourceforge.net",
    url = "http://cyclograph.sourceforge.net",
    license = "GPL v3 or later",
    packages = ['cyclograph',
                'cyclograph.qt',
                'cyclograph.gtk3'],
    cmdclass = {'build_py': my_build_py,
                'clean': my_clean,
                'generate': generate_all,
                'pyrcc': pyrcc,
                'pyuic': pyuic,
                'msgfmt': msgfmt,
                'html': genhtml},
    package_data = {'cyclograph' : files },
    scripts = ["cyclograph/cyclograph"],
    data_files = [('share/icons/hicolor/scalable/apps', ['pixmaps/cyclograph.svg']),
        ('share/icons/hicolor/16x16/apps', ['pixmaps/16x16/cyclograph.png']),
        ('share/icons/hicolor/22x22/apps', ['pixmaps/22x22/cyclograph.png']),
        ('share/icons/hicolor/24x24/apps', ['pixmaps/24x24/cyclograph.png']),
        ('share/icons/hicolor/32x32/apps', ['pixmaps/32x32/cyclograph.png']),
        ('share/icons/hicolor/48x48/apps', ['pixmaps/48x48/cyclograph.png']),
        ('share/icons/hicolor/256x256/apps', ['pixmaps/256x256/cyclograph.png']),
        ('share/cyclograph/icons', icons),
        ('share/locale/en/LC_MESSAGES',
            ['po/en/LC_MESSAGES/cyclograph.mo']),
        ('share/locale/it/LC_MESSAGES',
            ['po/it/LC_MESSAGES/cyclograph.mo']),
        ('share/applications',
            ['cyclograph-qt.desktop',
             'cyclograph-gtk3.desktop']),
        ],
    long_description = \
"""CycloGraph is an application for plotting the elevation profile of routes.
Its main value is in the graphical visualization of the difficulty of a
road, in term of slope, difference in height, etc. Plots like these are
often used in cycling competitions, but are also useful in other sports,
such as hiking or running."""
)