Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/setup.py
blob: a4ca4bdb5e9c95751a65a181d06036f48d5876f6 (plain)
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from distutils.core import setup
import sys
import os

import hatta

################### Common settings ######################

config = dict(
    name='Hatta',
    version=hatta.__version__,
    url='http://hatta.sheep.art.pl/',
    download_url='http://sheep.art.pl/misc/hatta-%s/Hatta-%s.zip' % (
        hatta.__version__, hatta.__version__),
    license='GNU General Public License (GPL)',
    author='Radomir Dopieralski',
    author_email='hatta@sheep.art.pl',
    description='Wiki engine that lives in Mercurial repository.',
    long_description=hatta.__doc__,
    keywords='wiki wsgi web mercurial repository',
    py_modules=['hatta'],
    data_files=[
        ('share/locale/ar/LC_MESSAGES', ['locale/ar/LC_MESSAGES/hatta.mo']),
        ('share/locale/da/LC_MESSAGES', ['locale/da/LC_MESSAGES/hatta.mo']),
        ('share/locale/de/LC_MESSAGES', ['locale/de/LC_MESSAGES/hatta.mo']),
        ('share/locale/es/LC_MESSAGES', ['locale/es/LC_MESSAGES/hatta.mo']),
        ('share/locale/fr/LC_MESSAGES', ['locale/fr/LC_MESSAGES/hatta.mo']),
        ('share/locale/ja/LC_MESSAGES', ['locale/ja/LC_MESSAGES/hatta.mo']),
        ('share/locale/pl/LC_MESSAGES', ['locale/pl/LC_MESSAGES/hatta.mo']),
        ('share/locale/sv/LC_MESSAGES', ['locale/sv/LC_MESSAGES/hatta.mo']),
        ('share/icons/hicolor/scalable', ['resources/hatta.svg']),
        ('share/icons/hicolor/32x32', ['resources/hatta.png']),
        ('share/applications', ['resources/hatta.desktop']),
        ('share/doc/hatta/examples', [
            'examples/hatta.fcg',
            'examples/hatta.wsgi',
            'examples/extend_parser.py'
        ]),
    ],
    platforms='any',
    requires=['werkzeug (>=0.3)', 'mercurial (>=1.0)'],
    classifiers=[
        'License :: OSI Approved :: GNU General Public License (GPL)',
        'Intended Audience :: Developers',
        'Intended Audience :: End Users/Desktop',
        'Intended Audience :: System Administrators',
        'Topic :: Communications',
        'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
        'Topic :: Internet :: WWW/HTTP :: WSGI :: Application',
        'Programming Language :: Python',
        'Operating System :: OS Independent',
        'Environment :: Web Environment',
    ],
    options = {
        'py2exe': {
            'packages': ['werkzeug', 'dbhash', 'encodings'],
            'excludes': ['_ssl', 'tcl', 'tkinter'],
            'dll_excludes': ['tcl84.dll', 'tk84.dll'],
            "compressed": 1,
            "optimize": 2,
        },
        'py2app': {
            'argv_emulation': True,
            'includes': ['werkzeug.routing', 'PyQt4.QtGui',
                'PyQt4.QtCore', 'PyQt4._qt', 'sip'],
            'iconfile': 'resources/hatta.icns',
            'resources': ['hatta.py'],
        },
    },
# for Mac
    app=['hatta_qticon.py'],
)

if sys.platform == 'darwin':
    from setuptools import setup
    config['setup_requires'] = ['py2app']
elif sys.platform == 'win32':
    ### Windows installer ###
    import py2exe
    class InnoScript(object):
        def __init__(self, name, lib_dir, dist_dir, windows_exe_files = [],
                     lib_files = [], version = "1.0"):
            self.lib_dir = lib_dir
            self.dist_dir = dist_dir
            if not self.dist_dir[-1] in "\\/":
                self.dist_dir += "\\"
            self.name = name
            self.version = version
            self.windows_exe_files = [self.chop(p) for p in windows_exe_files]
            self.lib_files = [self.chop(p) for p in lib_files]

        def chop(self, pathname):
            assert pathname.startswith(self.dist_dir)
            return pathname[len(self.dist_dir):]
        
        def create(self, pathname="dist\\hatta.iss"):
            self.pathname = pathname
            ofi = self.file = open(pathname, "w")
            print >> ofi, "; WARNING: This script has been created by py2exe. Changes to this script"
            print >> ofi, "; will be overwritten the next time py2exe is run!"
            print >> ofi, r"[Setup]"
            print >> ofi, r"AppName=%s" % self.name
            print >> ofi, r"AppVerName=%s %s" % (self.name, self.version)
            print >> ofi, r"DefaultDirName={pf}\%s" % self.name
            print >> ofi, r"DefaultGroupName=%s" % self.name
            print >> ofi

            print >> ofi, r"[Files]"
            for path in self.windows_exe_files + self.lib_files:
                print >> ofi, r'Source: "%s"; DestDir: "{app}\%s"; Flags: ignoreversion' % (path, os.path.dirname(path))
            print >> ofi

            print >> ofi, r"[Icons]"
            for path in self.windows_exe_files:
                print >> ofi, r'Name: "{group}\%s"; Filename: "{app}\%s"' % \
                      (self.name, path)
            print >> ofi, 'Name: "{group}\Uninstall %s"; Filename: "{uninstallexe}"' % self.name

        def compile(self):
            try:
                import ctypes
            except ImportError:
                try:
                    import win32api
                except ImportError:
                    import os
                    os.startfile(self.pathname)
                else:
                    print "Ok, using win32api."
                    win32api.ShellExecute(0, "compile", self.pathname, None, None, 0)
            else:
                print "Cool, you have ctypes installed."
                res = ctypes.windll.shell32.ShellExecuteA(0, "compile", self.pathname, None, None, 0)
                if res < 32:
                    raise RuntimeError, "ShellExecute failed, error %d" % res

    class BuildInstaller(py2exe.build_exe.py2exe):
        """
           This class first builds the exe file(s),
           then creates a Windows installer.
           You need InnoSetup for it.
        """
        def run(self):
            # First, let py2exe do it's work.
            py2exe.build_exe.py2exe.run(self)
            lib_dir = self.lib_dir
            dist_dir = self.dist_dir
            # create the Installer, using the files py2exe has created.
            script = InnoScript("hatta", lib_dir, dist_dir,
                                self.console_exe_files+self.windows_exe_files,
                                self.lib_files)
            print "*** creating the inno setup script***"
            script.create()
            print "*** compiling the inno setup script***"
            script.compile()
            # Note: By default the final setup.exe will be in an
            # Output subdirectory.
    config['cmdclass'] = {"py2exe": BuildInstaller}
    config['console'] = {
        'script': 'hatta.py',
        'icon_resources': [(1, "resources/hatta.ico")],
    },
else: # Other UNIX-like
    config['scripts'] = ['hatta_qticon.py', 'hatta_gtkicon.py']

if __name__=='__main__':
    setup(**config)