Changeset 1139
- Timestamp:
- 02/28/07 05:11:22 (2 years ago)
- Files:
-
- gaphor/trunk/MANIFEST.in (modified) (1 diff)
- gaphor/trunk/esetup.py (modified) (1 diff)
- gaphor/trunk/setup.py (modified) (7 diffs)
- gaphor/trunk/utils/build_mo.py (modified) (3 diffs)
- gaphor/trunk/utils/build_pot.py (modified) (1 diff)
- gaphor/trunk/utils/command (added)
- gaphor/trunk/utils/genUML2.py (modified) (1 diff)
- gaphor/trunk/utils/install_mo.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
gaphor/trunk/MANIFEST.in
r751 r1139 1 1 include COPYING INSTALL NEWS README TODO AUTHORS run-gaphor.sh 2 2 include bin/gaphor 3 recursive-include doc usecases.txt ui-design.txt diagram-in-python.txt4 3 recursive-include gaphor *.py 5 4 include gaphor/UML/uml2.gaphor gaphor/trunk/esetup.py
r1135 r1139 43 43 # 'PyGTK >= 2.8.0', - Exclude, since it will not build anyway 44 44 'gaphas >= 0.1.0', 45 'zope. interface>= 3.3.0', # - won't compile on windows.45 'zope.component >= 3.3.0', # - won't compile on windows. 46 46 ], 47 47 gaphor/trunk/setup.py
r1127 r1139 51 51 from distutils.command.install_lib import install_lib 52 52 from distutils.dep_util import newer 53 from distutils.util import byte_compile 54 from distutils.dir_util import mkpath 53 55 from utils.build_mo import build, build_mo 54 56 from utils.build_pot import build_pot … … 150 152 151 153 152 class build_Gaphor(build): 153 154 def run(self): 155 self.run_command('config') 156 build.run(self) 157 158 159 class version_py: 160 161 def generate_version(self, dir, data_dir): 162 """Create a file gaphor/version.py which contains the current version. 154 build.sub_commands.insert(0, ('config', None)) 155 156 #class build_Gaphor(build): 157 # 158 # def run(self): 159 # self.run_command('config') 160 # build.run(self) 161 # 162 163 def generate_version(dir, data_dir): 164 """ 165 Create a file gaphor/version.py which contains the current version. 166 """ 167 outfile = os.path.join(dir, 'gaphor', 'version.py') 168 print 'generating %s' % outfile, dir, data_dir 169 mkpath(os.path.dirname(outfile)) 170 f = open(outfile, 'w') 171 f.write('"""\nVersion information generated by setup.py. DO NOT EDIT.\n"""\n\n') 172 f.write('VERSION=\'%s\'\n' % VERSION) 173 # expand backspaces 174 f.write('DATA_DIR=\'%s\'\n' % data_dir.replace('\\', '\\\\')) 175 if os.name == 'nt': 176 home = 'USERPROFILE' 177 else: 178 home = 'HOME' 179 f.write('import os\n') 180 f.write('USER_DATA_DIR=os.path.join(os.getenv(\'%s\'), \'.gaphor\')\n' % home) 181 f.write('del os\n') 182 f.close() 183 byte_compile([outfile]) 184 185 186 class build_version(Command): 187 188 user_options = [ 189 ('build-lib=','b', "build directory (where to install from)"), 190 ('force', 'f', "force installation (overwrite existing files)"), 191 ('data-dir', None, "data directory (where images and plugins reside)"), 192 ] 193 boolean_options = [ 'force' ] 194 195 def initialize_options(self): 196 self.build_lib = None 197 self.force = 0 198 self.data_dir = None 199 200 def finalize_options(self): 201 self.set_undefined_options('build', 202 ('build_purelib', 'build_lib'), 203 ('force', 'force')) 204 self.data_dir = os.path.join(os.getcwd(), 'data') 205 206 def run(self): 207 generate_version(self.build_lib, self.data_dir) 208 209 build.sub_commands.insert(0, ('build_version', None)) 210 211 class build_uml(Command): 212 213 description = "Generate gaphor/UML/uml2.py." 214 215 user_options = [ 216 ('build-lib=','b', "build directory (where to install from)"), 217 ('force', 'f', "force installation (overwrite existing files)"), 218 ] 219 220 boolean_options = [ 'force' ] 221 222 def initialize_options(self): 223 self.build_lib = None 224 self.force = 0 225 self.data_dir = None 226 227 def finalize_options(self): 228 self.set_undefined_options('build', 229 ('build_lib', 'build_lib'), 230 ('force', 'force')) 231 232 def run(self): 233 sys.path.insert(0, self.build_lib) 234 self.generate_uml2() 235 236 def generate_uml2(self): 163 237 """ 164 outfile = os.path.join(dir, 'gaphor', 'version.py') 165 print 'generating %s' % outfile, dir, data_dir 166 self.mkpath(os.path.dirname(outfile)) 167 f = open(outfile, 'w') 168 f.write('"""\nVersion information generated by setup.py. DO NOT EDIT.\n"""\n\n') 169 f.write('VERSION=\'%s\'\n' % VERSION) 170 # expand backspaces 171 f.write('DATA_DIR=\'%s\'\n' % data_dir.replace('\\', '\\\\')) 172 if os.name == 'nt': 173 home = 'USERPROFILE' 174 else: 175 home = 'HOME' 176 f.write('import os\n') 177 f.write('USER_DATA_DIR=os.path.join(os.getenv(\'%s\'), \'.gaphor\')\n' % home) 178 f.write('del os\n') 179 f.close() 180 self.byte_compile([outfile]) 181 182 183 class build_py_Gaphor(build_py, version_py): 184 185 description = "build_py and generate gaphor/UML/uml2.py." 186 187 def run(self): 188 build_py.run(self) 189 sys.path.insert(0, self.build_lib) 190 # All data is stored in the local data directory 191 data_dir = os.path.join(os.getcwd(), 'data') 192 #data_dir = "os.path.join(os.getcwd(), 'data')" 193 self.generate_version(self.build_lib, data_dir) 194 self.generate_uml2() 195 196 def generate_uml2(self): 197 """Generate gaphor/UML/uml2.py in the build directory.""" 238 Generate gaphor/UML/uml2.py in the build directory. 239 """ 198 240 import utils.genUML2 199 241 gen = os.path.join('utils', 'genUML2.py') … … 211 253 else: 212 254 print 'not generating %s (up-to-date)' % py_model 213 self.byte_compile([outfile]) 214 215 216 class install_lib_Gaphor(install_lib, version_py): 255 byte_compile([outfile]) 256 257 build.sub_commands.append(('build_uml', None)) 258 259 260 class install_version(Command): 261 262 user_options = [ 263 ('install-dir=', 'd', "directory to install to"), 264 ('install-data=', 'd', "directory where data files are installed"), 265 ] 266 217 267 218 268 def initialize_options(self): 219 269 install_lib.initialize_options(self) 270 self.install_dir= None 220 271 self.install_data= None 221 272 222 273 def finalize_options(self): 223 274 install_lib.finalize_options(self) 275 self.set_undefined_options('install_lib', 276 ('install_dir', 'install_dir')) 224 277 self.set_undefined_options('install_data', 225 ('install_d ir', 'install_data'))278 ('install_data', 'install_dir')) 226 279 227 280 def run(self): … … 233 286 skip = len(self.get_finalized_command('install').root or '') 234 287 235 self.generate_version(self.install_dir, self.install_data[skip:]) 236 install_lib.run(self) 237 238 239 class install_schemas(Command): 240 """Do something like this: 241 242 GCONF_CONFIG_SOURCE=`gconftool-2 --get-default-source` \ 243 gconftool --makefile-install-rule data/gaphor.schemas 244 245 in a pythonic way. 246 """ 247 248 description = "Install a configuration (using GConf)." 249 250 user_options = [ 251 ('install-data=', None, 'installation directory for data files'), 252 ('gconftool', None, 'The gconftool to use for installation'), 253 ('gconf-config-source', None, 'Overrule the GConf config source'), 254 ('force', 'f', 'force installation (overwrite existing keys)') 255 ] 256 257 boolean_options = ['force'] 258 259 def initialize_options(self): 260 self.install_data = None 261 self.gconftool = 'gconftool-2' 262 self.gconf_config_source = '' 263 self.force = None 264 self.schemas_file = 'data/gaphor.schemas' 265 266 def finalize_options(self): 267 self.set_undefined_options('install', 268 ('force', 'force'), 269 ('install_data', 'install_data')) 270 271 def run(self): 272 getstatus('GCONF_CONFIG_SOURCE="%s" %s --makefile-install-rule %s' % (self.gconf_config_source, self.gconftool, self.schemas_file)) 273 274 self._set_value('/schemas/apps/gaphor/data_dir', self.install_data, 'string') 275 276 def _set_value(self, key, value, type): 277 print "setting gconf value '%s' to '%s'" % (key, value) 278 #apply(getattr(self.gconf_client, 'set_' + type), 279 # (GCONF_DOMAIN + key, value)) 280 getstatus('%s --type=%s --set %s %s' % (self.gconftool, type, key, value)) 281 282 #install.sub_commands.append(('install_schemas', None)) 288 generate_version(self.install_dir, self.install_data[skip:]) 283 289 284 290 … … 314 320 print 'Starting Gaphor...' 315 321 print 'Starting with model file', self.model 316 self.run_command('build') 322 for cmd_name in self.get_sub_commands(): 323 self.run_command(cmd_name) 317 324 318 325 import os.path … … 377 384 print 'Launching Gaphor...' 378 385 gaphor.main(self.model) 386 387 sub_commands = [('build', None)] 388 379 389 380 390 class tests_Gaphor(Command): … … 459 469 scripts=['bin/gaphor', 'bin/gaphorconvert'], 460 470 461 # distclass=Distribution,462 471 cmdclass={'config': config_Gaphor, 463 'build_py': build_py_Gaphor, 464 #'install_schemas': install_schemas, 465 'build': build_Gaphor, 466 # 'build_ext': BuildExt, 472 'build_uml': build_uml, 473 'build_version': build_version, 467 474 'build_mo': build_mo, 468 475 'build_pot': build_pot, 469 'install': install,470 'install_lib': install_lib_Gaphor,471 476 'install_mo': install_mo, 472 477 'run': run_Gaphor, gaphor/trunk/utils/build_mo.py
r1124 r1139 10 10 from distutils.core import Command 11 11 from distutils.dep_util import newer 12 from distutils.command.build import build as _build13 12 import os.path 14 13 import msgfmt 15 14 16 class build(_build):17 description = "New build class, which adds the property to add locales."18 19 def initialize_options(self):20 _build.initialize_options(self)21 self.build_locales = None22 23 def finalize_options(self):24 _build.finalize_options(self)25 if not self.build_locales:26 self.build_locales = os.path.join(self.build_base, 'locale')27 28 build.sub_commands.append(('build_mo', None))29 15 30 16 class build_mo(Command): … … 49 35 def finalize_options (self): 50 36 self.set_undefined_options('build', 51 ('build_locales', 'build_dir'),52 37 ('force', 'force')) 38 if self.build_dir is None: 39 self.set_undefined_options('build', 40 ('build_base', 'build_dir')) 41 self.build_dir = os.path.join(self.build_dir, 'linguas') 42 53 43 self.all_linguas = self.all_linguas.split(',') 54 44 … … 68 58 print 'not converting %s (output up-to-date)' % pofile 69 59 60 from distutils.command.build import build 61 build.sub_commands.append(('build_mo', None)) 62 63 64 gaphor/trunk/utils/build_pot.py
r1124 r1139 141 141 142 142 def create_pot_file(self): 143 """Create a new .pot file. This is basically a rework of the 143 """ 144 Create a new .pot file. This is basically a rework of the 144 145 main function of pygettext. 145 146 """ gaphor/trunk/utils/genUML2.py
r1121 r1139 302 302 redefines = l[0] 303 303 304 print 'found', subsets, redefines304 #print 'found', subsets, redefines 305 305 return subsets, redefines 306 306 gaphor/trunk/utils/install_mo.py
r1124 r1139 14 14 except ImportError: 15 15 from distutils.core import Command 16 from distutils.command.install import install as _install17 16 from distutils.util import change_root 18 17 import os.path 19 18 20 class install(_install):21 22 def initialize_options(self):23 _install.initialize_options(self)24 self.install_locales = None25 26 def finalize_options(self):27 _install.finalize_options(self)28 #if not self.install_locales:29 self.install_locales = os.path.join(self.install_base, 'share', 'locale')30 31 install.sub_commands.append(('install_mo', None))32 19 33 20 class install_mo(Command): … … 43 30 self.install_dir = None 44 31 self.build_dir = None 45 self.root = None46 32 self.all_linguas = None 47 33 48 34 def finalize_options(self): 49 self.set_undefined_options('build', 50 ('build_locales', 'build_dir')) 51 self.set_undefined_options('install', 52 ('install_locales', 'install_dir'), 53 ('root', 'root')) 35 self.set_undefined_options('build_mo', 36 ('build_dir', 'build_dir')) 37 if self.install_dir is None: 38 self.set_undefined_options('install', 39 ('prefix', 'install_dir')) 40 self.install_dir = os.path.join(self.install_dir, 'share') 54 41 55 42 self.name = self.distribution.get_name() 56 43 self.all_linguas = self.all_linguas.split(',') 57 58 if self.root:59 self.install_dir = change_root(self.root, self.install_dir)60 44 61 45 def run(self): … … 63 47 return 64 48 65 for l inguain self.all_linguas:66 mofile = os.path.join(self.build_dir, '%s.mo' % l ingua)67 path = os.path.join(self.install_dir, l ingua, 'LC_MESSAGES')49 for lang in self.all_linguas: 50 mofile = os.path.join(self.build_dir, '%s.mo' % lang) 51 path = os.path.join(self.install_dir, lang, 'LC_MESSAGES') 68 52 self.mkpath(path) 69 53 outfile = os.path.join(path, '%s.mo' % self.name) 70 54 self.copy_file(mofile, outfile) 71 55 56 from distutils.command.install import install 57 install.sub_commands.append(('install_mo', None))
