Skip to content

Commit 7e09f3d

Browse files
committed
Changed to a dual install/launch exe
1 parent 0912b63 commit 7e09f3d

File tree

3 files changed

+25
-19
lines changed

3 files changed

+25
-19
lines changed

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@ py = python3
22
cc := ${py} -m PyInstaller
33

44

5-
all: build
5+
all: init build
66

77
.PHONY: build
88

9+
init:
10+
$(py) -m pip install pyinstaller requests
11+
912
build:
1013
$(cc) launch.spec
1114

launch.py

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,34 @@
11
import os
2-
import shutil
3-
import sys
2+
import requests
3+
import zipfile
44
from pathlib import Path
55

66

7-
# From https://stackoverflow.com/questions/26577574/python-pyinstaller-onefile-executable
8-
def resource(relative_path):
9-
if getattr(sys, 'frozen', False):
10-
return os.path.join(sys._MEIPASS, relative_path)
7+
chromedir = Path.home() / ".pogify" / "GoogleChromePortable"
118

12-
return os.path.join(os.path.abspath('.'), relative_path)
139

14-
chrome = resource("GoogleChromePortable") # "GoogleChromePortable.exe"))
15-
newpath = Path.home() / ".pogify" / "GoogleChromePortable"
16-
17-
print("Relocating chrome executable")
10+
def unzip(filepath: str, resultpath: str) -> None:
11+
with zipfile.ZipFile(filepath, "r") as zip_ref:
12+
zip_ref.extractall(resultpath)
1813

1914
try:
2015
os.mkdir(Path.home() / ".pogify")
21-
except FileExistsError:
22-
pass
16+
zippath = Path.home() / ".pogify" / "chrome.zip"
17+
18+
with open(zippath, 'wb+') as fout:
19+
fout.write(
20+
requests.get(
21+
"https://github.com/Pogify/pogify-client"
22+
"/releases/latest/download/GoogleChromePortable.zip"
23+
).content)
24+
25+
unzip(str(zippath), Path.home() / ".pogify")
26+
os.remove(str(zippath))
2327

24-
try:
25-
shutil.copytree(chrome, newpath)
2628
except FileExistsError:
2729
pass
2830

31+
2932
os.system(
30-
f"start {newpath / 'GoogleChromePortable.exe'} --app=http://pogify.net/"
33+
f"start {chromedir / 'GoogleChromePortable.exe'} --app=http://pogify.net/"
3134
)

launch.spec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ block_cipher = None
66
a = Analysis(['launch.py'],
77
pathex=[''],
88
binaries=[],
9-
datas=[('GoogleChromePortable', 'GoogleChromePortable')],
9+
datas=[],
1010
hiddenimports=[],
1111
hookspath=[],
1212
runtime_hooks=[],
@@ -30,4 +30,4 @@ exe = EXE(pyz,
3030
upx=False,
3131
upx_exclude=[],
3232
runtime_tmpdir=None,
33-
console=True , icon='favicon.ico')
33+
console=False , icon='favicon.ico')

0 commit comments

Comments
 (0)