| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
""" |
|---|
| 6 |
Gaphor |
|---|
| 7 |
""" |
|---|
| 8 |
|
|---|
| 9 |
MAJOR_VERSION = 0 |
|---|
| 10 |
MINOR_VERSION = 9 |
|---|
| 11 |
MICRO_VERSION = 2 |
|---|
| 12 |
|
|---|
| 13 |
VERSION = '%d.%d.%d' % ( MAJOR_VERSION, MINOR_VERSION, MICRO_VERSION ) |
|---|
| 14 |
|
|---|
| 15 |
LINGUAS = [ 'ca', 'es', 'nl', 'sv' ] |
|---|
| 16 |
|
|---|
| 17 |
TESTS = [ |
|---|
| 18 |
'gaphor.actions.tests.test_itemactions', |
|---|
| 19 |
'gaphor.actions.tests.test_placementactions', |
|---|
| 20 |
'gaphor.adapters.tests.test_connector', |
|---|
| 21 |
'gaphor.adapters.tests.test_editor', |
|---|
| 22 |
'gaphor.diagram.tests.test_diagramitem', |
|---|
| 23 |
'gaphor.diagram.tests.test_class', |
|---|
| 24 |
'gaphor.diagram.tests.test_action', |
|---|
| 25 |
'gaphor.diagram.tests.test_handletool', |
|---|
| 26 |
'gaphor.diagram.tests.test_interfaces', |
|---|
| 27 |
'gaphor.diagram.tests.test_style', |
|---|
| 28 |
'gaphor.ui.tests.test_diagramtab', |
|---|
| 29 |
'gaphor.ui.tests.test_mainwindow', |
|---|
| 30 |
'gaphor.UML.tests.test_elementfactory', |
|---|
| 31 |
] |
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 |
import sys, os |
|---|
| 36 |
from glob import glob |
|---|
| 37 |
from commands import getoutput, getstatus, getstatusoutput |
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
try: |
|---|
| 41 |
import py2app |
|---|
| 42 |
except ImportError: |
|---|
| 43 |
print "No py2app, can't create application bundle" |
|---|
| 44 |
else: |
|---|
| 45 |
from modulegraph.modulegraph import AddPackagePath |
|---|
| 46 |
AddPackagePath('gaphor', 'build/lib/gaphor') |
|---|
| 47 |
AddPackagePath('gaphor.UML', 'build/lib/gaphor/UML') |
|---|
| 48 |
|
|---|
| 49 |
|
|---|
| 50 |
from distutils.core import setup, Command |
|---|
| 51 |
from distutils.command.build import build |
|---|
| 52 |
from distutils.command.install import install |
|---|
| 53 |
from distutils.command.build_py import build_py |
|---|
| 54 |
from distutils.command.install_lib import install_lib |
|---|
| 55 |
from distutils.dep_util import newer |
|---|
| 56 |
from distutils.util import byte_compile |
|---|
| 57 |
from distutils.dir_util import mkpath |
|---|
| 58 |
from utils.command.build_mo import build_mo |
|---|
| 59 |
from utils.command.build_pot import build_pot |
|---|
| 60 |
from utils.command.install_mo import install_mo |
|---|
| 61 |
from utils.command.build_uml import build_uml |
|---|
| 62 |
from utils.command.build_version import build_version |
|---|
| 63 |
from utils.command.install_version import install_version |
|---|
| 64 |
from utils.command.run import run |
|---|
| 65 |
|
|---|
| 66 |
str_version = sys.version[:3] |
|---|
| 67 |
version = map(int, str_version.split('.')) |
|---|
| 68 |
if version < [2, 4]: |
|---|
| 69 |
raise SystemExit, \ |
|---|
| 70 |
"Python 2.4 or higher is required, %s found" % str_version |
|---|
| 71 |
|
|---|
| 72 |
|
|---|
| 73 |
class config(Command): |
|---|
| 74 |
description="Configure Gaphor" |
|---|
| 75 |
|
|---|
| 76 |
user_options = [ |
|---|
| 77 |
|
|---|
| 78 |
] |
|---|
| 79 |
|
|---|
| 80 |
|
|---|
| 81 |
config_failed=[] |
|---|
| 82 |
|
|---|
| 83 |
def initialize_options(self): |
|---|
| 84 |
|
|---|
| 85 |
pass |
|---|
| 86 |
|
|---|
| 87 |
def finalize_options(self): |
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 |
|
|---|
| 91 |
|
|---|
| 92 |
|
|---|
| 93 |
|
|---|
| 94 |
pass |
|---|
| 95 |
|
|---|
| 96 |
def run(self): |
|---|
| 97 |
self.module_check('pygtk') |
|---|
| 98 |
import pygtk |
|---|
| 99 |
pygtk.require('2.0') |
|---|
| 100 |
|
|---|
| 101 |
self.module_check('xml.parsers.expat') |
|---|
| 102 |
self.module_check('gtk', ('gtk_version', (2, 8)), |
|---|
| 103 |
('pygtk_version', (2, 8))) |
|---|
| 104 |
|
|---|
| 105 |
print '' |
|---|
| 106 |
if self.config_failed: |
|---|
| 107 |
print 'Config failed.' |
|---|
| 108 |
print 'The following modules can not be found or are to old:' |
|---|
| 109 |
print ' ', str(self.config_failed)[1:-1] |
|---|
| 110 |
print '' |
|---|
| 111 |
raise SystemExit |
|---|
| 112 |
else: |
|---|
| 113 |
print 'Config succeeded.' |
|---|
| 114 |
|
|---|
| 115 |
def pkg_config_check(self, package, version): |
|---|
| 116 |
"""Check for availability of a package via pkg-config.""" |
|---|
| 117 |
retval = os.system('%s --exists %s' % (self.pkg_config, package)) |
|---|
| 118 |
if retval: |
|---|
| 119 |
print '!!! Required package %s not found.' % package |
|---|
| 120 |
self.config_failed.append(package) |
|---|
| 121 |
return |
|---|
| 122 |
pkg_version_str = getoutput('%s --modversion %s' % (self.pkg_config, package)) |
|---|
| 123 |
pkg_version = map(int, pkg_version_str.split('.')) |
|---|
| 124 |
req_version = map(int, version.split('.')) |
|---|
| 125 |
if pkg_version >= req_version: |
|---|
| 126 |
print "Found '%s', version %s." % (package, pkg_version_str) |
|---|
| 127 |
else: |
|---|
| 128 |
print "!!! Package '%s' has version %s, should have at least version %s." % ( package, pkg_version_str, version ) |
|---|
| 129 |
self.config_failed.append(package) |
|---|
| 130 |
|
|---|
| 131 |
def module_check(self, module, *version_checks): |
|---|
| 132 |
"""Check for the availability of a module. |
|---|
| 133 |
|
|---|
| 134 |
version_checks is a set of ket/version pairs that should be true. |
|---|
| 135 |
""" |
|---|
| 136 |
import string |
|---|
| 137 |
try: |
|---|
| 138 |
mod = __import__(module) |
|---|
| 139 |
except ImportError: |
|---|
| 140 |
print "!!! Required module '%s' not found." % module |
|---|
| 141 |
self.config_failed.append(module) |
|---|
| 142 |
else: |
|---|
| 143 |
print "Module '%s' found." % module |
|---|
| 144 |
for key, ver in version_checks: |
|---|
| 145 |
s_ver = string.join(map(str, ver), '.') |
|---|
| 146 |
print " Checking key '%s.%s' >= %s..." % (module, key, s_ver), |
|---|
| 147 |
try: |
|---|
| 148 |
modver = getattr(mod, key) |
|---|
| 149 |
except: |
|---|
| 150 |
print "Not found." % key |
|---|
| 151 |
self.config_failed.append(module) |
|---|
| 152 |
else: |
|---|
| 153 |
s_modver = string.join(map(str, modver), '.') |
|---|
| 154 |
if modver >= ver: |
|---|
| 155 |
print "Okay (%s)." % s_modver |
|---|
| 156 |
else: |
|---|
| 157 |
print "Failed (%s)" % s_modver |
|---|
| 158 |
self.config_failed.append(module) |
|---|
| 159 |
|
|---|
| 160 |
|
|---|
| 161 |
build.sub_commands.insert(0, ('config', None)) |
|---|
| 162 |
|
|---|
| 163 |
|
|---|
| 164 |
class tests(Command): |
|---|
| 165 |
|
|---|
| 166 |
description = 'Run the Gaphor test suite.' |
|---|
| 167 |
|
|---|
| 168 |
user_options = [ |
|---|
| 169 |
] |
|---|
| 170 |
|
|---|
| 171 |
def initialize_options(self): |
|---|
| 172 |
self.verbosity = 9 |
|---|
| 173 |
|
|---|
| 174 |
def finalize_options(self): |
|---|
| 175 |
pass |
|---|
| 176 |
|
|---|
| 177 |
def run(self): |
|---|
| 178 |
print 'Starting Gaphor test-suite...' |
|---|
| 179 |
|
|---|
| 180 |
self.run_command('build') |
|---|
| 181 |
|
|---|
| 182 |
import unittest |
|---|
| 183 |
|
|---|
| 184 |
test_suite = unittest.defaultTestLoader.loadTestsFromNames(TESTS) |
|---|
| 185 |
|
|---|
| 186 |
test_runner = unittest.TextTestRunner(verbosity=self.verbosity) |
|---|
| 187 |
result = test_runner.run(test_suite) |
|---|
| 188 |
sys.exit(not result.wasSuccessful()) |
|---|
| 189 |
|
|---|
| 190 |
def plugin_data(name): |
|---|
| 191 |
return 'plugins/%s' % name, glob('data/plugins/%s/*.*' % name) |
|---|
| 192 |
|
|---|
| 193 |
|
|---|
| 194 |
setup(name='gaphor', |
|---|
| 195 |
version=VERSION, |
|---|
| 196 |
description="Gaphor is a UML modeling tool", |
|---|
| 197 |
url='http://gaphor.sourceforge.net', |
|---|
| 198 |
author='Arjan J. Molenaar', |
|---|
| 199 |
author_email='arjanmol@users.sourceforge.net', |
|---|
| 200 |
license="GNU General Public License (GPL, see COPYING)", |
|---|
| 201 |
long_description="Gaphor is a UML modeling tool written in Python. " |
|---|
| 202 |
"It uses the GNOME2 environment for user interaction.", |
|---|
| 203 |
platforms=['GNOME2'], |
|---|
| 204 |
packages=['gaphor', |
|---|
| 205 |
'gaphor.UML', |
|---|
| 206 |
'gaphor.UML.tests', |
|---|
| 207 |
'gaphor.diagram', |
|---|
| 208 |
'gaphor.diagram.tests', |
|---|
| 209 |
'gaphor.ui', |
|---|
| 210 |
'gaphor.ui.tests', |
|---|
| 211 |
'gaphor.misc', |
|---|
| 212 |
'gaphor.adapters', |
|---|
| 213 |
'gaphor.adapters.tests', |
|---|
| 214 |
'gaphor.actions', |
|---|
| 215 |
'gaphor.actions.tests', |
|---|
| 216 |
'gaphas', |
|---|
| 217 |
'zope', |
|---|
| 218 |
'zope.interface', |
|---|
| 219 |
'zope.component.bbb', |
|---|
| 220 |
'zope.component.bbb.tests', |
|---|
| 221 |
'zope.interface.common', |
|---|
| 222 |
'zope.component', |
|---|
| 223 |
'zope.exceptions', |
|---|
| 224 |
'zope.deprecation', |
|---|
| 225 |
'zope.testing', |
|---|
| 226 |
|
|---|
| 227 |
], |
|---|
| 228 |
|
|---|
| 229 |
|
|---|
| 230 |
data_files=[('', ['data/icons.xml']), |
|---|
| 231 |
('pixmaps', glob('data/pixmaps/*.png')), |
|---|
| 232 |
plugin_data('plugineditor'), |
|---|
| 233 |
plugin_data('alignment'), |
|---|
| 234 |
plugin_data('checkmetamodel'), |
|---|
| 235 |
plugin_data('diagramlayout'), |
|---|
| 236 |
plugin_data('liveobjectbrowser'), |
|---|
| 237 |
plugin_data('pngexport'), |
|---|
| 238 |
plugin_data('pynsource'), |
|---|
| 239 |
plugin_data('svgexport'), |
|---|
| 240 |
plugin_data('pdfexport'), |
|---|
| 241 |
plugin_data('xmiexport') |
|---|
| 242 |
], |
|---|
| 243 |
scripts=['bin/gaphor', 'bin/gaphorconvert'], |
|---|
| 244 |
|
|---|
| 245 |
cmdclass={'config': config, |
|---|
| 246 |
'build_uml': build_uml, |
|---|
| 247 |
'build_version': build_version, |
|---|
| 248 |
'install_version': install_version, |
|---|
| 249 |
'build_mo': build_mo, |
|---|
| 250 |
'build_pot': build_pot, |
|---|
| 251 |
'install_mo': install_mo, |
|---|
| 252 |
'run': run, |
|---|
| 253 |
'tests': tests |
|---|
| 254 |
}, |
|---|
| 255 |
|
|---|
| 256 |
options = dict( |
|---|
| 257 |
py2app = dict( |
|---|
| 258 |
includes=['atk', 'pango', 'cairo', 'pangocairo'], |
|---|
| 259 |
|
|---|
| 260 |
|
|---|
| 261 |
), |
|---|
| 262 |
build_pot = dict( |
|---|
| 263 |
all_linguas = ','.join(LINGUAS), |
|---|
| 264 |
), |
|---|
| 265 |
build_mo = dict( |
|---|
| 266 |
all_linguas = ','.join(LINGUAS), |
|---|
| 267 |
), |
|---|
| 268 |
install_mo = dict( |
|---|
| 269 |
all_linguas = ','.join(LINGUAS), |
|---|
| 270 |
), |
|---|
| 271 |
) |
|---|
| 272 |
) |
|---|
| 273 |
|
|---|
| 274 |
|
|---|