Skip to content

Commit

Permalink
Merge pull request #76 from jcwinkler/feature/universal_build_package
Browse files Browse the repository at this point in the history
Universal build package script and modified Windows installer
  • Loading branch information
jcwinkler committed Nov 30, 2018
2 parents 8088af8 + 6e252af commit 0935ae6
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 59 deletions.
45 changes: 0 additions & 45 deletions build_linux_package.py

This file was deleted.

58 changes: 58 additions & 0 deletions build_packages.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import shutil
import argparse
import tempfile
import os


class TmpDir:
def __init__(self):
self.path = None

def __enter__(self):
self.path = tempfile.mkdtemp()
return self.path

def __exit__(self, exc_type, exc_val, exc_tb):
if self.path:
shutil.rmtree(self.path)


if __name__ == "__main__":

TexTextVersion = "0.8.1"

parser = argparse.ArgumentParser(description="Build TexText distribution archive for selected platforms."
"If not otherwise specified zip and tgz packages are built "
"for Linux and a zip package for Windows.")
available_formats = [fmt for fmt, desc in shutil.get_archive_formats()]
parser.add_argument('--linux',
type=str,
nargs="+",
choices=available_formats,
help="Build package for Linux with archive formats [%s]" % ", ".join(available_formats))
parser.add_argument('--windows',
type=str,
nargs="+",
choices=available_formats,
help="Build package for Windows with archive formats [%s]" % ", ".join(available_formats))

args = vars(parser.parse_args())
if not any(args.values()):
args = {'linux': ['zip', 'gztar'], 'windows': ['zip']}

for platform, formats in {p: f for p, f in args.items() if f}.items():
PackageName = "TexText-%s-" % platform.capitalize() + TexTextVersion
git_ignore_patterns = shutil.ignore_patterns(*open(".gitignore").read().split("\n"))

with TmpDir() as tmpdir:
shutil.copytree("./extension",
os.path.join(tmpdir, "extension"),
ignore=git_ignore_patterns # exclude .gitignore files
)
shutil.copy("setup.py", tmpdir)
shutil.copy("LICENSE.txt", tmpdir)
if platform == "Windows":
shutil.copy("setup_win.bat", tmpdir)
for fmt in formats:
filename = shutil.make_archive(PackageName, fmt, tmpdir)
print("Successfully created %s" % os.path.basename(filename))
20 changes: 6 additions & 14 deletions build_windows_installer.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -75,30 +75,22 @@ Section "TexText" -SEC01
SetOutPath "$INSTDIR\textext"
File "extension\textext\__init__.py"
File "extension\textext\asktext.py"
File "extension\textext\typesetter.py"
File "extension\textext\errors.py"
File "extension\textext\latexlogparser.py"
File "extension\textext\requirements_check.py"
File "extension\textext\typesetter.py"
File "extension\textext\utility.py"
File "extension\textext\default_packages.tex"
File "extension\textext\win_app_paths.py"

; Make sure that extension files from old TexText versions < 0.9
; are removed (they were put directly into Inkscape's extension
; directory and not in a subdirectory)
; Any Tex files existing in the old extension directory are most likely
; default packages files for TexText from previous versions. Hence,
; we _copy_ them into the textext subdir and ask the user if
; it is OK to delete them. (He might want to use it in other extensions,
; so we should not delete them by default).
; Keep old default_packages.tex, i.e. move it to the new location
IfFileExists "$INSTDIR\textext.py" OldExtensionFound InstallFinished

OldExtensionFound:
CopyFiles $INSTDIR\*.tex $INSTDIR\textext
MessageBox MB_YESNO "Old installation of TexText detected! $\n$\nThe preamble files in the old TexText extension directory will be copied into the new TexText extension directory so you do not loose your modifications in the preamble files. $\n$\nWould you like to delete the old files in their original place after this operation? If you do use TexText as the only LaTeX extension it is safe to click <Yes>." IDYES DeleteOldTexFiles IDNO DeleteOldExtension

DeleteOldTexFiles:
Delete "$INSTDIR\*.tex"
Goto DeleteOldExtension

DeleteOldExtension:
CopyFiles $INSTDIR\default_packages.tex $INSTDIR\textext
Delete "$INSTDIR\textext.py"
Delete "$INSTDIR\textext.pyc"
Delete "$INSTDIR\asktext.py"
Expand Down

0 comments on commit 0935ae6

Please sign in to comment.