Preparation for Windows build

This commit is contained in:
Mark Qvist 2024-11-27 13:14:46 +01:00
parent 2e5d557aa7
commit ee18dcab31
4 changed files with 76 additions and 3 deletions

1
main.py Normal file
View File

@ -0,0 +1 @@
import sbapp.main

View File

@ -6118,3 +6118,6 @@ def run():
if __name__ == "__main__":
run()
if __name__ == "sbapp.main":
run()

View File

@ -178,19 +178,21 @@ class SidebandCore():
self.cache_dir = self.app_dir+"/cache"
self.rns_configdir = None
core_path = os.path.abspath(__file__)
if "core.pyc" in core_path:
core_path = core_path.replace("core.pyc", "core.py")
if RNS.vendor.platformutils.is_android():
self.app_dir = android_app_dir+"/io.unsigned.sideband/files/"
self.cache_dir = self.app_dir+"/cache"
self.rns_configdir = self.app_dir+"/app_storage/reticulum"
self.asset_dir = self.app_dir+"/app/assets"
elif RNS.vendor.platformutils.is_darwin():
core_path = os.path.abspath(__file__)
self.asset_dir = core_path.replace("/sideband/core.py", "/assets")
elif RNS.vendor.platformutils.get_platform() == "linux":
core_path = os.path.abspath(__file__)
self.asset_dir = core_path.replace("/sideband/core.py", "/assets")
elif RNS.vendor.platformutils.is_windows():
core_path = os.path.abspath(__file__)
self.asset_dir = core_path.replace("\\sideband\\core.py", "\\assets")
else:
self.asset_dir = plyer.storagepath.get_application_dir()+"/sbapp/assets"

67
sideband.spec Normal file
View File

@ -0,0 +1,67 @@
# -*- mode: python ; coding: utf-8 -*-
from kivy_deps import sdl2, glew
a = Analysis(
['main.py'],
pathex=[],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
noarchive=False,
optimize=0,
)
pyz = PYZ(a.pure)
def extra_datas(mydir):
def rec_glob(p, files):
import os
import glob
for d in glob.glob(p):
if os.path.isfile(d):
files.append(d)
rec_glob("%s/*" % d, files)
files = []
rec_glob("%s/*" % mydir, files)
extra_datas = []
for f in files:
extra_datas.append((f, f, 'DATA'))
return extra_datas
a.datas += extra_datas('sbapp')
a.datas += extra_datas('RNS')
a.datas += extra_datas('LXMF')
exe = EXE(
pyz,
a.scripts,
[],
exclude_binaries=True,
name='main',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=True,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)
coll = COLLECT(
exe,
a.binaries,
a.datas,
*[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins)],
strip=False,
upx=True,
upx_exclude=[],
name='main',
)