File: setup.py

package info (click to toggle)
wammu 0.17-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,620 kB
  • ctags: 499
  • sloc: python: 6,674; makefile: 46
file content (259 lines) | stat: -rwxr-xr-x 10,507 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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
'''
Wammu - Phone manager
Setup script for installation using distutils
'''
__author__ = 'Michal Čihař'
__email__ = 'michal@cihar.com'
__license__ = '''
Copyright (c) 2003 - 2006 Michal Čihař

This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License version 2 as published by
the Free Software Foundation.

This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.

You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
'''

from distutils.core import setup
from distutils.command.build_scripts import build_scripts
from distutils.util import convert_path
from distutils.dep_util import newer
from distutils import log
from distutils import sysconfig
from stat import ST_MODE
import sys
import glob
import Wammu
import os.path
import os
import re
# Optional support for py2exe
try:
    import py2exe
except:
    pass

# detect whether we should check for dependencies
skip_deps = 'clean' in sys.argv or '--help' in sys.argv or '--help-commands' in sys.argv or 'sdist' in sys.argv

# somw defines
PYTHONGAMMU_REQUIRED = (0,10)

if not skip_deps:
    if os.getenv('SKIPGAMMUCHECK') == 'yes':
        print 'Skipping Gammu check, expecting you know what you are doing!'
    else:
        try:
            import gammu
        except ImportError:
            print 'You need python-gammu!'
            print 'You can get it from <http://cihar.com/gammu/python/>'
            sys.exit(1)
        pygver = tuple(map(int, gammu.Version()[1].split('.')))
        if  pygver < PYTHONGAMMU_REQUIRED:
            print 'You need python-gammu at least %s!' % '.'.join(map(str, PYTHONGAMMU_REQUIRED))
            print 'You can get it from <http://cihar.com/gammu/python/>'
            sys.exit(1)

    if os.getenv('SKIPWXCHECK') == 'yes':
        print 'Skipping wx check, expecting you know what you are doing!'
    else:
        try:
            import wx
        except ImportError:
            print 'You need wxPython!'
            print 'You can get it from <http://www.wxpython.org>'
            sys.exit(1)
        if wx.VERSION < (2,6,0,0):
            print 'You need at least wxPython 2.6.0.0!'
            print 'You can get it from <http://www.wxpython.org>'
            sys.exit(1)

    try:
        import gnomebt.controller
    except ImportError:
        try:
            import bluetooth
        except ImportError:
            print 'WARNING: neither GNOME Bluetooth nor PyBluez found, without those you can not search for bluetooth devices'
            print 'GNOME Bluetooth can be downloaded from <http://usefulinc.com/software/gnome-bluetooth>'
            print 'PyBluez can be downloaded from <http://org.csail.mit.edu/pybluez/>'

# check if Python is called on the first line with this expression
first_line_re = re.compile('^#!.*python[0-9.]*([ \t].*)?$')

class build_scripts_wammu(build_scripts):
    '''
    This is mostly distutils copy, it just renames script according
    to platform (.pyw for Windows, without extension for others)
    '''
    def copy_scripts (self):
        """Copy each script listed in 'self.scripts'; if it's marked as a
        Python script in the Unix way (first line matches 'first_line_re',
        ie. starts with "\#!" and contains "python"), then adjust the first
        line to refer to the current Python interpreter as we copy.
        """
        self.mkpath(self.build_dir)
        outfiles = []
        for script in self.scripts:
            adjust = 0
            script = convert_path(script)
            outfile = os.path.join(self.build_dir, os.path.splitext(os.path.basename(script))[0])
            if sys.platform == 'win32':
                outfile += os.extsep + 'pyw'
            outfiles.append(outfile)

            if not self.force and not newer(script, outfile):
                log.debug("not copying %s (up-to-date)", script)
                continue

            # Always open the file, but ignore failures in dry-run mode --
            # that way, we'll get accurate feedback if we can read the
            # script.
            try:
                f = open(script, "r")
            except IOError:
                if not self.dry_run:
                    raise
                f = None
            else:
                first_line = f.readline()
                if not first_line:
                    self.warn("%s is an empty file (skipping)" % script)
                    continue

                match = first_line_re.match(first_line)
                if match:
                    adjust = 1
                    post_interp = match.group(1) or ''

            if adjust:
                log.info("copying and adjusting %s -> %s", script,
                         self.build_dir)
                if not self.dry_run:
                    outf = open(outfile, "w")
                    if not sysconfig.python_build:
                        outf.write("#!%s%s\n" %
                                   (os.path.normpath(sys.executable),
                                    post_interp))
                    else:
                        outf.write("#!%s%s\n" %
                                   (os.path.join(
                            sysconfig.get_config_var("BINDIR"),
                            "python" + sysconfig.get_config_var("EXE")),
                                    post_interp))
                    outf.writelines(f.readlines())
                    outf.close()
                if f:
                    f.close()
            else:
                f.close()
                self.copy_file(script, outfile)

        if os.name == 'posix':
            for file in outfiles:
                if self.dry_run:
                    log.info("changing mode of %s", file)
                else:
                    oldmode = os.stat(file)[ST_MODE] & 07777
                    newmode = (oldmode | 0555) & 07777
                    if newmode != oldmode:
                        log.info("changing mode of %s from %o to %o",
                                 file, oldmode, newmode)
                        os.chmod(file, newmode)

    # copy_scripts ()



setup(name="wammu",
    version = Wammu.__version__,
    description = "Wammu",
    long_description = "Phone manager built on top of python-gammu. Supports many phones.",
    author = "Michal Čihař",
    author_email = "michal@cihar.com",
    maintainer = "Michal Čihař",
    maintainer_email = "michal@cihar.com",
    url = "http://cihar.com/gammu/wammu",
    license = "GPL",
    classifiers = [
        'Development Status :: 5 - Production/Stable',
        'Environment :: Win32 (MS Windows)',
        'Environment :: X11 Applications :: GTK',
        'Intended Audience :: End Users/Desktop',
        'License :: OSI Approved :: GNU General Public License (GPL)',
        'Operating System :: Microsoft :: Windows :: Windows 95/98/ME',
        'Operating System :: Microsoft :: Windows :: Windows NT/2000/XP',
        'Operating System :: POSIX',
        'Operating System :: Unix',
        'Programming Language :: Python',
        'Topic :: Communications :: Telephony',
        'Topic :: Office/Business :: Scheduling',
        'Topic :: Utilities',
        'Translations :: English',
        'Translations :: Catalan',
        'Translations :: Czech',
        'Translations :: Dutch',
        'Translations :: Estonian',
        'Translations :: Finnish',
        'Translations :: French',
        'Translations :: German',
        'Translations :: Hungarian',
        'Translations :: Italian',
        'Translations :: Korean',
        'Translations :: Polish',
        'Translations :: Portuguese (Brazil)',
        'Translations :: Slovak',
        'Translations :: Spanish',
        'Translations :: Swedish',
    ],
    packages = ['Wammu', 'Wammu.wxcomp'],
    scripts = ['wammu.py'],
    data_files = [
        (os.path.join('share','Wammu','images','icons'), glob.glob('images/icons/*.png')),
        (os.path.join('share','Wammu','images','misc'), glob.glob('images/misc/*.png')),
        (os.path.join('share','locale','ca','LC_MESSAGES'), ['locale/ca/LC_MESSAGES/wammu.mo']),
        (os.path.join('share','locale','cs','LC_MESSAGES'), ['locale/cs/LC_MESSAGES/wammu.mo']),
        (os.path.join('share','locale','de','LC_MESSAGES'), ['locale/de/LC_MESSAGES/wammu.mo']),
        (os.path.join('share','locale','es','LC_MESSAGES'), ['locale/es/LC_MESSAGES/wammu.mo']),
        (os.path.join('share','locale','et','LC_MESSAGES'), ['locale/et/LC_MESSAGES/wammu.mo']),
        (os.path.join('share','locale','fi','LC_MESSAGES'), ['locale/fi/LC_MESSAGES/wammu.mo']),
        (os.path.join('share','locale','fr','LC_MESSAGES'), ['locale/fr/LC_MESSAGES/wammu.mo']),
        (os.path.join('share','locale','hu','LC_MESSAGES'), ['locale/hu/LC_MESSAGES/wammu.mo']),
        (os.path.join('share','locale','ko','LC_MESSAGES'), ['locale/ko/LC_MESSAGES/wammu.mo']),
        (os.path.join('share','locale','nl','LC_MESSAGES'), ['locale/nl/LC_MESSAGES/wammu.mo']),
        (os.path.join('share','locale','it','LC_MESSAGES'), ['locale/it/LC_MESSAGES/wammu.mo']),
        (os.path.join('share','locale','pl','LC_MESSAGES'), ['locale/pl/LC_MESSAGES/wammu.mo']),
        (os.path.join('share','locale','pt_BR','LC_MESSAGES'), ['locale/pt_BR/LC_MESSAGES/wammu.mo']),
        (os.path.join('share','locale','sk','LC_MESSAGES'), ['locale/sk/LC_MESSAGES/wammu.mo']),
        (os.path.join('share','locale','sv','LC_MESSAGES'), ['locale/sv/LC_MESSAGES/wammu.mo']),
        (os.path.join('share','applications'), ['wammu.desktop']),
        (os.path.join('share','pixmaps'), ['icon/wammu.png', 'icon/wammu.xpm', 'icon/wammu.ico']),
        (os.path.join('share','man','man1'), ['wammu.1'])
        ],
    # Override certain command classes with our own ones
    cmdclass = {
        'build_scripts': build_scripts_wammu,
        },
    # py2exe options
    options = {'py2exe': {
            'optimize': 2,
            'packages': 'Wammu',
        }},
    windows = [
        {
            'script': 'wammu.py',
            'icon_resources': [(1, 'icon/wammu.ico')],
        },
        ],
    zipfile = "shared.lib"
    )