Commits

abudden committed 9473e69

Now makes a simple Windows binary (still depends on the normal distribution being installed). Relates to #24.

  • Participants
  • Parent commits 76d9ce1

Comments (0)

Files changed (3)

dist/make_taghighlight_release.py

 import sys
 import zipfile
 import fnmatch
+import subprocess
 
 vimfiles_dir = os.path.abspath(os.path.join(os.path.dirname(__file__),'..'))
 
 release_revid:{revision_id}
 '''
 def GenerateVersionInfo():
-    import subprocess
     args = BZR+['version-info','--custom','--template="'+version_info_format+'"']
     p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
     (stdout,stderr) = p.communicate()
     # Close the zipfile
     zipf.close()
 
+def MakeCompiled(pyexe, pyinstaller_path):
+    initial_dir = os.getcwd()
+    os.chdir(os.path.join(vimfiles_dir, 'plugin/TagHighlight'))
+    args = pyexe + [os.path.join(pyinstaller_path, 'Build.py'), '-y', 'TagHighlight.spec']
+    p = subprocess.Popen(args)#, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+    (stdout,stderr) = p.communicate()
+    zipf = zipfile.ZipFile(os.path.join(vimfiles_dir,'dist','taghighlight_win32.zip'), 'w')
+    for f in Rglob(os.path.join(vimfiles_dir,'plugin/TagHighlight/Compiled/Win32'),'*'):
+        dirname = os.path.dirname(os.path.relpath(f,vimfiles_dir))
+        zipf.write(f,os.path.join(dirname, os.path.basename(f)), zipfile.ZIP_DEFLATED)
+    zipf.close()
+    os.chdir(initial_dir)
+
+def MakeWin32Compiled():
+    if 'WINPYTHON' in os.environ:
+        # Doesn't work with spaces in the path
+        # (doing the split to allow for running python
+        # with wine).
+        pyexe = os.environ['WINPYTHON'].split(' ')
+    else:
+        pyexe = ['python.exe']
+    pyinstaller_path = os.environ['WINPYINSTALLERDIR']
+    MakeCompiled(pyexe, pyinstaller_path)
+
+
 def main():
     version_file, clean = GenerateVersionInfo()
 
-    if clean:
+    if clean or True:
         MakeZipFile()
+        MakeWin32Compiled()
     else:
         print("Distribution not clean: check into Bazaar before making release.")
 

plugin/TagHighlight/TagHighlight.spec

 # -*- mode: python -*-
 # Work out what language files are needed
-language_files = ['module.languages.' + i[:-3] for i in
-        os.listdir('module/languages')
-        if i not in ['__init__.py', 'class_interface.py'] and
-        i[-3:] == '.py']
-# Create a directory for hooks (if it doesn't exist already)
-try:
-    os.mkdir('./hooks')
-except OSError:
-    pass
-# Create a hook for the languages module
-fh = open('./hooks/hook-module.languages.py', 'w')
-fh.write("hiddenimports = %s\n" % str(language_files))
-fh.close()
-# Create an empty hook for the top level module (saveas a warning)
-fh = open('./hooks/hook-module.py', 'w')
-fh.close()
-# Create a module holding the list of languages
-fh = open('./module/languages/all_languages.py', 'w')
-fh.write("languages = %s\n" % str(language_files))
-fh.close()
-
 a = Analysis([os.path.join(HOMEPATH,'support\\_mountzlib.py'), os.path.join(HOMEPATH,'support\\useUnicode.py'), 'TagHighlight.py'],
-        pathex=['.'],
-        hookspath=['./hooks'])
+        pathex=['.'])
 pyz = PYZ(a.pure)
 exe = EXE(pyz,
         a.scripts,
         upx=True,
         name='Compiled/Win32')
 
-# Remove the generated files
-
-os.remove('./hooks/hook-module.languages.py')
-os.remove('./hooks/hook-module.py')
-os.remove('./hooks/hook-module.languages.pyc')
-os.remove('./hooks/hook-module.pyc')
-if len(os.listdir('./hooks')) == 0:
-    os.rmdir('./hooks')
-os.remove('./module/languages/all_languages.py')
-os.remove('./module/languages/all_languages.pyc')
-
 # vim: ft=python

plugin/TagHighlight/module/config.py

     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 SetInitialOptions(new_options):
     global config