File: setup.py

package info (click to toggle)
diacanvas2 0.13.0-4
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 4,360 kB
  • ctags: 2,897
  • sloc: ansic: 20,741; xml: 8,608; sh: 7,458; python: 669; makefile: 536
file content (168 lines) | stat: -rw-r--r-- 6,228 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
"""Python Bindings for DiaCanvas2.

This file provides an alternative way for building the Python bindings of
DiaCanvas2. 
TODO: Write a good long description"""

MAJOR_VERSION = 0
MINOR_VERSION = 13
MICRO_VERSION = 0

from distutils.command.build import build
from distutils.core import setup
import os
import sys

try:
    import pygtk
    pygtk.require('2.0')
except (ImportError, AssertionError):
    raise SystemExit, 'ERROR: Could not find a recent version of pygtk.'

import gnome.canvas

try:
    import gnome.canvas
except (ImportError, AssertionError):
    raise SystemExit, 'ERROR: Could not find a GnomeCanvas Python binding'

from dsextras import list_files, have_pkgconfig, GLOBAL_INC, GLOBAL_MACROS
from dsextras import InstallLib, BuildExt, PkgConfigExtension
from dsextras import Template, TemplateExtension, pkgc_version_check
from dsextras import getoutput

GLOBAL_MACROS += [('DIACANVAS_MAJOR_VERSION', MAJOR_VERSION)]
GLOBAL_MACROS += [('DIACANVAS_MINOR_VERSION', MINOR_VERSION)]
GLOBAL_MACROS += [('DIACANVAS_MICRO_VERSION', MICRO_VERSION)]

VERSION = "%d.%d.%d" % (MAJOR_VERSION,
                        MINOR_VERSION,
                        MICRO_VERSION)

PYGTK_REQUIRED_VERSION              = '2.0.0'
LIBGNOMECANVAS_REQUIRED_VERSION     = '2.0.0'
LIBDIACANVAS2_REQUIRED_VERSION      = '0.9.2'

PYGTK_SUFFIX = '2.0'
PYGTK_SUFFIX_LONG = 'gtk-' + PYGTK_SUFFIX

GLOBAL_INC.append('..')

DEFS_DIR    = os.path.join('share', 'pygtk', PYGTK_SUFFIX, 'defs')
CODEGEN_DIR = os.path.join('share', 'pygtk', PYGTK_SUFFIX, 'codegen')
INCLUDE_DIR = os.path.join('include', 'pygtk-%s' % PYGTK_SUFFIX)

str_version = sys.version[:3]
version = map(int, str_version.split('.'))
if version < [2, 2]:
    raise SystemExit, \
          "Python 2.2 or higher is required, %s found" % str_version

if not pkgc_version_check('pygtk-2.0', 'PyGTK', PYGTK_REQUIRED_VERSION):
    raise SystemExit, "Aborting"
pygtkincludedir = getoutput('pkg-config --variable pygtkincludedir pygtk-2.0')
codegendir = getoutput('pkg-config --variable codegendir pygtk-2.0')
defsdir = getoutput('pkg-config --variable defsdir pygtk-2.0')

GLOBAL_INC.append(pygtkincludedir)
GTKDEFS = [os.path.join(defsdir, 'pango-types.defs'),
           os.path.join(defsdir, 'gdk-types.defs'),
           os.path.join(defsdir, 'gtk-types.defs')]
CANVASDEFS = [os.path.join(defsdir, 'canvas.defs')]

sys.path.append(codegendir)
try:
    from override import Overrides
except ImportError:
    raise SystemExit, \
'Could not find code generator in %s, do you have installed pygtk correctly?'

canvas = TemplateExtension(name = 'diacanvas',
                           pkc_name='diacanvas2',
                           pkc_version=LIBDIACANVAS2_REQUIRED_VERSION,
                           output='diacanvas._canvas',
                           defs='diacanvas.defs',
                           sources=['diacanvas.c',
                                    'pydiacanvasitem.c',
                                    'diacanvasmodule.c'],
                           register=GTKDEFS + CANVASDEFS + \
                           ['../diacanvas/dia-boxed.defs', 'diashape.defs'],
                           override='diacanvas.override',
                           )
                               
view = TemplateExtension(name = 'diaview',
                         pkc_name='diacanvas2',
                         pkc_version=LIBDIACANVAS2_REQUIRED_VERSION,
                         output='diacanvas.view',
                         defs='diaview.defs',
                         sources=['diaview.c',
                                  'diaviewmodule.c'],
                         register=GTKDEFS + ['diacanvas.defs'],
                         override='diaview.override',
                         )
                               
geometry = TemplateExtension(name = 'diageometry',
                             pkc_name='diacanvas2',
                             pkc_version=LIBDIACANVAS2_REQUIRED_VERSION,
                             output='diacanvas.geometry',
                             defs='diageometry.defs',
                             sources=['diageometry.c',
                                      'diageometrymodule.c'],
                             register=['diacanvas.defs'],
                             override='diageometry.override',
                             )

shape = TemplateExtension(name = 'diashape',
                          pkc_name='diacanvas2',
                          pkc_version=LIBDIACANVAS2_REQUIRED_VERSION,
                          output='diacanvas.shape',
                          defs='diashape.defs',
                          sources=['diashape.c',
                                   'diashapemodule.c'],
                          register=GTKDEFS + ['diacanvas.defs'],
                          override='diashape.override',
                          )

data_files = []
ext_modules = []
py_modules = []

if canvas.can_build():
    ext_modules.append(canvas)
    data_files.append((DEFS_DIR, ('diacanvas.defs',
                                  '../diacanvas/dia-boxed.defs')))

if view.can_build():
    ext_modules.append(view)
    data_files.append((DEFS_DIR, ('diaview.defs',)))
    
if geometry.can_build():
    ext_modules.append(geometry)
    data_files.append((DEFS_DIR, ('diageometry.defs',)))
    
if shape.can_build():
    ext_modules.append(shape)
    data_files.append((DEFS_DIR, ('diashape.defs',)))

if canvas.can_build() and view.can_build() and geometry.can_build() and shape.can_build():
    py_modules.append('diacanvas.__init__')
    py_modules.append('diacanvas.placementtool')
    
doclines = __doc__.split("\n")

setup(name="pydiacanvas2",
      url='http://diacanvas.sourceforge.net',
      version=VERSION,
      license='LGPL',
      platforms=['yes'],
      maintainer="Arjan Molenaar",
      maintainer_email="arjanmol@users.sourceforge.net",
      description = doclines[0],
      long_description = '\n'.join(doclines[2:]),
      package_dir={ 'diacanvas': '.',
                    'diacanvas.__init__': '.',
                    'diacanvas.placementtool': '.' },
      py_modules=py_modules,
      ext_modules=ext_modules,
      data_files=data_files,
      cmdclass={'build_ext': BuildExt})