-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #76 from jcwinkler/feature/universal_build_package
Universal build package script and modified Windows installer
- Loading branch information
Showing
3 changed files
with
64 additions
and
59 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters