SetupWin extends Setup, used to build a windows distribution
This commit is contained in:
parent
e467b65224
commit
72ed607bd0
|
@ -82,6 +82,8 @@ class Configuration(RawConfigParser):
|
|||
set_option(section, "resources-path-identifier", "resources_path")
|
||||
set_option(section, "special-char-placeholder", "_")
|
||||
set_option(section, "whitespace-placeholder", "-")
|
||||
set_option(section, "icon-path", "")
|
||||
set_option(section, "windows-dist-path", "dist/win/")
|
||||
section = "display"
|
||||
add_section(section)
|
||||
set_option(section, "dimensions", "480, 320")
|
||||
|
@ -225,8 +227,9 @@ class TypeDeclarations(dict):
|
|||
"setup": {"list": ["classifiers", "resources-search-path",
|
||||
"requirements", "data-exclude"],
|
||||
"path": ["installation-dir", "package-root",
|
||||
"changelog", "description-file",
|
||||
"main-object"]},
|
||||
"changelog", "description-file",
|
||||
"main-object", "icon-path",
|
||||
"windows-dist-path"]},
|
||||
"keys": {"list": ["up", "right", "down", "left"]}}
|
||||
additional_defaults = {}
|
||||
|
||||
|
|
|
@ -14,6 +14,9 @@ class Setup:
|
|||
config = Configuration()
|
||||
manifest_path = "MANIFEST"
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def remove_old_mainfest(self):
|
||||
path = self.manifest_path
|
||||
if exists(path):
|
||||
|
@ -81,7 +84,7 @@ class Setup:
|
|||
translation += " " + line + "\n"
|
||||
return translation
|
||||
|
||||
def setup(self):
|
||||
def setup(self, windows=[], options={}):
|
||||
self.remove_old_mainfest()
|
||||
config = self.config.get_section("setup")
|
||||
setup(cmdclass={"install": insert_resources_path},
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
from os import makedirs, walk, sep, remove
|
||||
from os.path import join, dirname, basename, exists
|
||||
from shutil import rmtree, copy, rmtree
|
||||
from itertools import chain
|
||||
from zipfile import ZipFile
|
||||
|
||||
import py2exe
|
||||
|
||||
from Setup import Setup
|
||||
|
||||
class SetupWin(Setup):
|
||||
|
||||
def __init__(self):
|
||||
Setup.__init__(self)
|
||||
self.replace_isSystemDLL()
|
||||
|
||||
def replace_isSystemDLL(self):
|
||||
origIsSystemDLL = py2exe.build_exe.isSystemDLL
|
||||
def isSystemDLL(pathname):
|
||||
if basename(pathname).lower() in ("libogg-0.dll", "sdl_ttf.dll"):
|
||||
return 0
|
||||
return origIsSystemDLL(pathname)
|
||||
py2exe.build_exe.isSystemDLL = isSystemDLL
|
||||
|
||||
def setup(self):
|
||||
config = self.config.get_section("setup")
|
||||
Setup.setup(self,
|
||||
[{"script": config["init-script"],
|
||||
"icon_resources": [(1, config["icon-path"])]
|
||||
}],
|
||||
{"py2exe": {"packages": self.build_package_list(),
|
||||
"dist_dir": config["windows-dist-path"]}})
|
||||
rmtree("build")
|
||||
self.copy_data_files()
|
||||
self.create_archive()
|
||||
|
||||
def copy_data_files(self):
|
||||
for path in chain(*zip(*self.build_data_map())[1]):
|
||||
dest = join(self.config.get("setup", "windows-dist-path"),
|
||||
dirname(path))
|
||||
if not exists(dest):
|
||||
makedirs(dest)
|
||||
copy(path, dest)
|
||||
|
||||
def create_archive(self):
|
||||
config = self.config.get_section("setup")
|
||||
title = self.translate_title() + "-" + config["version"] + "-win"
|
||||
archive_name = title + ".zip"
|
||||
archive = ZipFile(archive_name, "w")
|
||||
destination = config["windows-dist-path"]
|
||||
for root, dirs, names in walk(destination):
|
||||
for name in names:
|
||||
path = join(root, name)
|
||||
archive.write(path, path.replace(destination, title + sep))
|
||||
archive.close()
|
||||
copy(archive_name, "dist")
|
||||
remove(archive_name)
|
||||
rmtree(destination)
|
Loading…
Reference in New Issue