Commits

abudden  committed 8a7d6ce

Include version data in executable folder in case executable is installed at a separate time. Add an option to print the whole config out (including the version information).

  • Participants
  • Parent commits 9473e69

Comments (0)

Files changed (5)

File dist/make_taghighlight_release.py

 def main():
     version_file, clean = GenerateVersionInfo()
 
-    if clean or True:
+    if clean:
         MakeZipFile()
         MakeWin32Compiled()
     else:

File plugin/TagHighlight/TagHighlight.spec

 # Work out what language files are needed
 a = Analysis([os.path.join(HOMEPATH,'support\\_mountzlib.py'), os.path.join(HOMEPATH,'support\\useUnicode.py'), 'TagHighlight.py'],
         pathex=['.'])
+version_data = [('version_info.txt','data/version_info.txt','DATA')]
 pyz = PYZ(a.pure)
 exe = EXE(pyz,
         a.scripts,
         a.binaries,
         a.zipfiles,
         a.datas,
+        version_data,
         strip=False,
         upx=True,
         name='Compiled/Win32')

File plugin/TagHighlight/data/options.txt

 	Default:False
 	Help:Just print the version of python
 
+print_config:
+	CommandLineSwitches:--print-config
+	Type:bool
+	Default:False
+	Help:Parse the various options and then print the configuration and exit (for debugging)
+
 # vim: ff=unix:noet

File plugin/TagHighlight/module/config.py

 
 config = TagHighlightOptionDict()
 
-if hasattr(sys, 'frozen'):
-    # Compiled variant, executable should be in
-    # plugin/TagHighlight/Compiled/Win32, so data
-    # is in ../../data relative to executable
-    config['data_directory'] = os.path.abspath(
-            os.path.join(os.path.dirname(sys.executable),
-            '../../data'))
-else:
-    # Script variant: this file in
-    # plugin/TagHighlight/module, so data is in
-    # ../data relative to this file
-    config['data_directory'] = os.path.abspath(
-            os.path.join(os.path.dirname(__file__),
-            '../data'))
-if not os.path.exists(config['data_directory']):
-    raise IOError("Data directory doesn't exist, have you installed the main distribution?")
+def SetDataDirectories():
+    global config
+    if hasattr(sys, 'frozen'):
+        # Compiled variant, executable should be in
+        # plugin/TagHighlight/Compiled/Win32, so data
+        # is in ../../data relative to executable
+        config['data_directory'] = os.path.abspath(
+                os.path.join(os.path.dirname(sys.executable),
+                '../../data'))
+        config['version_info_dir'] = os.path.abspath(os.path.dirname(sys.executable))
+    else:
+        # Script variant: this file in
+        # plugin/TagHighlight/module, so data is in
+        # ../data relative to this file
+        config['data_directory'] = os.path.abspath(
+                os.path.join(os.path.dirname(__file__),
+                '../data'))
+        config['version_info_dir'] = config['data_directory']
 
+    if not os.path.exists(config['data_directory']):
+        raise IOError("Data directory doesn't exist, have you installed the main distribution?")
+
+def LoadVersionInfo():
+    global config
+    config['version'] = {}
+    try:
+        fh = open(os.path.join(config['version_info_dir'],'version_info.txt'), 'r')
+        for line in fh:
+            if line.startswith('release_'):
+                parts = line.strip().split(':')
+                config['version'][parts[0]] = parts[1]
+    except IOError:
+        for name in ['clean','date','revno','revision_id']:
+            config['version']['release_'+name] = 'Unreleased'
 
 def SetInitialOptions(new_options):
     global config
         config['language_list'] = full_language_list
     else:
         config['language_list'] = [i for i in full_language_list if i in config['languages']]
+
+SetDataDirectories()
+LoadVersionInfo()

File plugin/TagHighlight/module/worker.py

 
     LoadLanguages()
 
+    if config['print_config']:
+        import pprint
+        pprint.pprint(config)
+        return
+
     if config['print_py_version']:
         print(sys.version)
         return