Skip to content

Commit 5d9f00c

Browse files
committed
Specify pyinstaller version in makefile, make engine autorefresh configuration
1 parent 697af09 commit 5d9f00c

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ py = python3
33
cc := ${py} -m PyInstaller
44

55
pgg = dist/gui/pygame_gui
6-
data = ${pgg}/data
6+
data := ${pgg}/data
77
pggdatacdn = https://raw.githubusercontent.com/MyreMylar/pygame_gui/main/pygame_gui/data
88

99
all: init build data
1010

1111
.PHONY: init build data test clean
1212

1313
init:
14-
$(py) -m pip install pyinstaller pytest
14+
$(py) -m pip install PyInstaller==3.6 pytest==5.4.3
1515
$(py) -m pip install -r requirements.txt
1616

1717
build:

gui.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@
1010
from threading import Thread, Lock
1111

1212
# Pygame sends a stdout message
13-
actual_stdout = sys.stdout
1413
with io.StringIO() as sys.stdout:
1514
import cpuinfo
1615
import pygame
1716
import pygame.gfxdraw
1817
import pygame_gui
19-
sys.stdout = actual_stdout
18+
sys.stdout = sys.__stdout__
2019

2120
import lib
2221
from core import Database

lib/enginelib.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def get_config(default_options={}):
129129
try:
130130
with open(Path.home() / ".waychess" / "engineoptions.json", 'r') as fin:
131131
return {
132-
k: v for k, v in json.loads(fin.read()).items()
132+
k: v for k, v in json.load(fin).items()
133133
if k.lower() not in {"ponder", "multipv", "uci_chess960"}
134134
}
135135
except FileNotFoundError:
@@ -149,6 +149,14 @@ def configure_engine_options(self):
149149
path.touch()
150150
self.stdout("[ENGINE CONFIGURE", webbrowser.open(str(path)))
151151

152+
def reconfigure_engine(self):
153+
try:
154+
self.engine.configure(get_config({
155+
k: v.default for k, v in self.engine.options.items()
156+
}))
157+
except Exception as e:
158+
self.stderr("[EGNINE RECONFIGURE]", e)
159+
152160
def set_analysis(self):
153161
self.stdout("Set engine task")
154162
beg = time.time()
@@ -161,9 +169,7 @@ def set_analysis(self):
161169
self.stdout("Failed due to", e)
162170
self.exit()
163171
self.stdout("Loading engine options")
164-
self.engine.configure(get_config({
165-
k: v.default for k, v in self.engine.options.items()
166-
}))
172+
self.reconfigure_engine()
167173
self.is_analysing = True
168174
self.show_engine = True
169175
self.analysis_display = GUIAnalysis(self)
@@ -208,6 +214,7 @@ def stop_analysis(self):
208214
def engine_callback(self):
209215
try:
210216
if not self.show_engine:
217+
self.reconfigure_engine()
211218
self.set_analysis()
212219
else:
213220
self.stop_analysis()

0 commit comments

Comments
 (0)