WindowsBuild: Install Gajim as a python package
This commit is contained in:
parent
4ffc1cf8b6
commit
94324625fe
|
@ -29,6 +29,7 @@ function set_build_root {
|
||||||
BUILD_ROOT="$1"
|
BUILD_ROOT="$1"
|
||||||
REPO_CLONE="${BUILD_ROOT}/${MINGW}"/gajim
|
REPO_CLONE="${BUILD_ROOT}/${MINGW}"/gajim
|
||||||
MINGW_ROOT="${BUILD_ROOT}/${MINGW}"
|
MINGW_ROOT="${BUILD_ROOT}/${MINGW}"
|
||||||
|
PACKAGE_DIR="${BUILD_ROOT}/${MINGW}/lib/python3.6/site-packages"
|
||||||
}
|
}
|
||||||
|
|
||||||
set_build_root "${DIR}/_build_root"
|
set_build_root "${DIR}/_build_root"
|
||||||
|
@ -120,8 +121,10 @@ pillow
|
||||||
function install_gajim {
|
function install_gajim {
|
||||||
[ -z "$1" ] && (echo "Missing arg"; exit 1)
|
[ -z "$1" ] && (echo "Missing arg"; exit 1)
|
||||||
|
|
||||||
|
rm -Rf "${PACKAGE_DIR}/gajim"
|
||||||
rm -Rf "${REPO_CLONE}"
|
rm -Rf "${REPO_CLONE}"
|
||||||
git clone "${DIR}"/.. "${REPO_CLONE}"
|
git clone "${DIR}"/.. "${REPO_CLONE}"
|
||||||
|
mv "${REPO_CLONE}/gajim" "${PACKAGE_DIR}"
|
||||||
|
|
||||||
(cd "${REPO_CLONE}" && git checkout "$1") || exit 1
|
(cd "${REPO_CLONE}" && git checkout "$1") || exit 1
|
||||||
|
|
||||||
|
@ -186,6 +189,7 @@ function cleanup_install {
|
||||||
-exec rm -f {} \;
|
-exec rm -f {} \;
|
||||||
|
|
||||||
rm -Rf "${REPO_CLONE}"/.git
|
rm -Rf "${REPO_CLONE}"/.git
|
||||||
|
rm -Rf "${REPO_CLONE}"/.gitlab-ci.yml
|
||||||
rm -Rf "${REPO_CLONE}"/debian
|
rm -Rf "${REPO_CLONE}"/debian
|
||||||
rm -Rf "${REPO_CLONE}"/doc
|
rm -Rf "${REPO_CLONE}"/doc
|
||||||
rm -Rf "${REPO_CLONE}"/m4
|
rm -Rf "${REPO_CLONE}"/m4
|
||||||
|
@ -313,7 +317,7 @@ function cleanup_install {
|
||||||
find "${MINGW_ROOT}"/bin -name "*.pyo" -exec rm -f {} \;
|
find "${MINGW_ROOT}"/bin -name "*.pyo" -exec rm -f {} \;
|
||||||
find "${MINGW_ROOT}"/bin -name "*.pyc" -exec rm -f {} \;
|
find "${MINGW_ROOT}"/bin -name "*.pyc" -exec rm -f {} \;
|
||||||
build_compileall -q "${MINGW_ROOT}"
|
build_compileall -q "${MINGW_ROOT}"
|
||||||
find "${MINGW_ROOT}" -name "*.py" ! -name "gajim.py" ! -name "history_manager.py" ! -name "*theme.py" -exec rm -f {} \;
|
find "${MINGW_ROOT}" -name "*.py" ! -name "*theme.py" -exec rm -f {} \;
|
||||||
find "${MINGW_ROOT}"/bin -name "*.pyc" -exec rm -f {} \;
|
find "${MINGW_ROOT}"/bin -name "*.pyc" -exec rm -f {} \;
|
||||||
find "${MINGW_ROOT}" -type d -name "__pycache__" -prune -exec rm -rf {} \;
|
find "${MINGW_ROOT}" -type d -name "__pycache__" -prune -exec rm -rf {} \;
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ def build_exe(source_path, resource_path, is_gui, out_path):
|
||||||
subprocess.check_call(args)
|
subprocess.check_call(args)
|
||||||
|
|
||||||
|
|
||||||
def get_launcher_code(entry_point):
|
def get_launcher_code():
|
||||||
template = """\
|
template = """\
|
||||||
#include "Python.h"
|
#include "Python.h"
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
|
@ -87,19 +87,17 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||||
Py_FrozenFlag = 1;
|
Py_FrozenFlag = 1;
|
||||||
Py_Initialize();
|
Py_Initialize();
|
||||||
PySys_SetArgvEx(__argc, szArglist, 0);
|
PySys_SetArgvEx(__argc, szArglist, 0);
|
||||||
FILE* file = fopen("../gajim/gajim/%(filename)s", "r");
|
result = PyRun_SimpleString("import sys; import os;"
|
||||||
PyRun_SimpleString("import sys; import os;"
|
"sys.frozen=True;"
|
||||||
"os.chdir('../gajim/gajim');"
|
"os.chdir('../gajim');"
|
||||||
"sys.path.append(os.getcwd());"
|
"import gajim.gajim as g;"
|
||||||
"sys.frozen=True;"
|
"g.GajimApplication().run(sys.argv);");
|
||||||
);
|
|
||||||
result = PyRun_SimpleFile(file, "../gajim/gajim/%(filename)s");
|
|
||||||
Py_Finalize();
|
Py_Finalize();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return template % {"filename": entry_point}
|
return template
|
||||||
|
|
||||||
|
|
||||||
def get_resouce_code(filename, file_version, file_desc, icon_path,
|
def get_resouce_code(filename, file_version, file_desc, icon_path,
|
||||||
|
@ -150,7 +148,7 @@ END
|
||||||
|
|
||||||
|
|
||||||
def build_launcher(out_path, icon_path, file_desc, product_name, product_version,
|
def build_launcher(out_path, icon_path, file_desc, product_name, product_version,
|
||||||
company_name, entry_point, is_gui):
|
company_name, is_gui):
|
||||||
|
|
||||||
src_ico = os.path.abspath(icon_path)
|
src_ico = os.path.abspath(icon_path)
|
||||||
target = os.path.abspath(out_path)
|
target = os.path.abspath(out_path)
|
||||||
|
@ -162,7 +160,7 @@ def build_launcher(out_path, icon_path, file_desc, product_name, product_version
|
||||||
try:
|
try:
|
||||||
os.chdir(temp)
|
os.chdir(temp)
|
||||||
with open("launcher.c", "w") as h:
|
with open("launcher.c", "w") as h:
|
||||||
h.write(get_launcher_code(entry_point))
|
h.write(get_launcher_code())
|
||||||
shutil.copyfile(src_ico, "launcher.ico")
|
shutil.copyfile(src_ico, "launcher.ico")
|
||||||
with open("launcher.rc", "w") as h:
|
with open("launcher.rc", "w") as h:
|
||||||
h.write(get_resouce_code(
|
h.write(get_resouce_code(
|
||||||
|
@ -188,17 +186,17 @@ def main():
|
||||||
build_launcher(
|
build_launcher(
|
||||||
os.path.join(target, "Gajim.exe"),
|
os.path.join(target, "Gajim.exe"),
|
||||||
os.path.join(misc, "gajim.ico"), "Gajim", "Gajim",
|
os.path.join(misc, "gajim.ico"), "Gajim", "Gajim",
|
||||||
version, company_name, 'gajim.py', True)
|
version, company_name, True)
|
||||||
|
|
||||||
build_launcher(
|
build_launcher(
|
||||||
os.path.join(target, "Gajim-Debug.exe"),
|
os.path.join(target, "Gajim-Debug.exe"),
|
||||||
os.path.join(misc, "gajim.ico"), "Gajim", "Gajim",
|
os.path.join(misc, "gajim.ico"), "Gajim", "Gajim",
|
||||||
version, company_name, 'gajim.py', False)
|
version, company_name, False)
|
||||||
|
|
||||||
build_launcher(
|
# build_launcher(
|
||||||
os.path.join(target, "history_manager.exe"),
|
# os.path.join(target, "history_manager.exe"),
|
||||||
os.path.join(misc, "gajim.ico"), "History Manager", "History Manager",
|
# os.path.join(misc, "gajim.ico"), "History Manager", "History Manager",
|
||||||
version, company_name, 'history_manager.py', True)
|
# version, company_name, 'history_manager.py', True)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -105,9 +105,9 @@ Section "Gajim" SecGajim
|
||||||
|
|
||||||
SetOutPath "$INSTDIR\bin"
|
SetOutPath "$INSTDIR\bin"
|
||||||
CreateShortCut "$INSTDIR\Gajim-Portable.lnk" "$INSTDIR\bin\Gajim.exe" \
|
CreateShortCut "$INSTDIR\Gajim-Portable.lnk" "$INSTDIR\bin\Gajim.exe" \
|
||||||
"-c ..\..\UserData" "" "" SW_SHOWNORMAL "" "Gajim Portable"
|
"-c ..\UserData" "" "" SW_SHOWNORMAL "" "Gajim Portable"
|
||||||
CreateShortCut "$INSTDIR\Gajim-Portable-Debug.lnk" "$INSTDIR\bin\Gajim-Debug.exe" \
|
CreateShortCut "$INSTDIR\Gajim-Portable-Debug.lnk" "$INSTDIR\bin\Gajim-Debug.exe" \
|
||||||
"-c ..\..\UserData" "" "" SW_SHOWNORMAL "" "Gajim Portable Debug"
|
"-c ..\UserData" "" "" SW_SHOWNORMAL "" "Gajim Portable Debug"
|
||||||
|
|
||||||
SectionEnd
|
SectionEnd
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue