Skip to content

Commit d83b86a

Browse files
Autofix pywin32 + Release 0.1.6
1 parent 8aac53b commit d83b86a

File tree

4 files changed

+804
-3
lines changed

4 files changed

+804
-3
lines changed

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def url_retrieve(url: str, outfile: Path, overwrite: bool = False):
111111
]
112112

113113
if platform.system() == "Windows":
114-
install_req.append('pywin32')
114+
install_req.append('pywin32>=303')
115115
install_req.append('vgamepad')
116116

117117
# The directory containing this file
@@ -123,13 +123,13 @@ def url_retrieve(url: str, outfile: Path, overwrite: bool = False):
123123

124124
setup(
125125
name='tmrl',
126-
version='0.1.4',
126+
version='0.1.6',
127127
description='Autonomous racing in Trackmania',
128128
long_description=README,
129129
long_description_content_type='text/markdown',
130130
keywords='reinforcement learning, trackmania, self driving, roborace',
131131
url='https://github.com/trackmania-rl/tmrl',
132-
download_url='https://github.com/trackmania-rl/tmrl/archive/refs/tags/v0.1.4.tar.gz',
132+
download_url='https://github.com/trackmania-rl/tmrl/archive/refs/tags/v0.1.6.tar.gz',
133133
author='Yann Bouteiller, Edouard Geze',
134134
135135
license='MIT',

tmrl/__init__.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,27 @@
33
import sys
44
logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
55

6+
import platform
7+
if platform.system() == "Windows":
8+
# fix pywin32 in case it fails to import:
9+
try:
10+
import win32gui
11+
import win32ui
12+
import win32con
13+
except ImportError as e1:
14+
logging.info("pywin32 failed to import. Attempting to fix pywin32 installation...")
15+
from tmrl.tools.init_package.init_pywin32 import fix_pywin32
16+
try:
17+
fix_pywin32()
18+
import win32gui
19+
import win32ui
20+
import win32con
21+
except ImportError as e2:
22+
logging.error(f"tmrl could not fix pywin32 on your system. The following exceptions were raised:\
23+
\n=== Exception 1 ===\nstr(e1)\n=== Exception 2 ===\nstr(e2)\
24+
\nPlease install pywin32 manually.")
25+
raise RuntimeError("Please install pywin32 manually: https://github.com/mhammond/pywin32")
26+
627
# standard library imports
728
from dataclasses import dataclass
829
# from tmrl.networking import Server, RolloutWorker, Trainer

tmrl/tools/init_package/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)