Skip to content

Commit

Permalink
Fix OAuth in Windows when using Pyinstaller version
Browse files Browse the repository at this point in the history
  • Loading branch information
parklez committed Feb 18, 2023
1 parent 2bffcd7 commit 0a131eb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
11 changes: 10 additions & 1 deletion parky_bot/twitch/oauth_implicit_flow.py
Expand Up @@ -15,6 +15,8 @@
import hashlib
import os
import threading
import sys

import requests

from http.server import HTTPServer, SimpleHTTPRequestHandler
Expand All @@ -39,7 +41,14 @@ def do_POST(self):

class RedirectRequestHandler(SimpleHTTPRequestHandler):
def __init__(self, *args, **kwargs):
super().__init__(*args, directory=os.path.dirname(__file__), **kwargs)
html_path = os.path.dirname(__file__)

# In case this this app is bundled with pyinstaller
if getattr(sys, 'frozen', True):
from parky_bot.settings import APP_PATH
html_path = os.path.join(APP_PATH, 'bin')

super().__init__(*args, directory=html_path, **kwargs)


def _send_stop_requests() -> None:
Expand Down
4 changes: 3 additions & 1 deletion scripts/build.py
Expand Up @@ -9,7 +9,7 @@
'_struct.cpython-39-x86_64-linux-gnu.so',
'zlib.cpython-39-x86_64-linux-gnu.so']

IGNORE_LIST = ['bin', 'certifi', 'base_library.zip']
IGNORE_LIST = ['bin', 'base_library.zip']
IGNORE_LIST += (IGNORE_LIST_WIN if platform.system()
== 'Windows' else IGNORE_LIST_LINUX)

Expand All @@ -28,6 +28,8 @@
'--hidden-import', 'requests',
'--hidden-import', 'audioplayer',
'--runtime-hook', HOOK_PATH,
# https://pyinstaller.org/en/stable/usage.html#cmdoption-add-data
'--add-data', 'parky_bot/twitch/index.html;.',
SCRIPT_PATH])

# Moving files to 'lib'
Expand Down

0 comments on commit 0a131eb

Please sign in to comment.