Skip to content

Commit 9c352c5

Browse files
committed
Remove redundant SDL version check from setup.py
This duplicates build_sdl.py and maybe isn't as useful as it used to be. I could import from that module if I really need the check in setup.py. Ensured updated code was moved to build_sdl.py
1 parent 6d2b2c7 commit 9c352c5

File tree

2 files changed

+13
-39
lines changed

2 files changed

+13
-39
lines changed

build_sdl.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,19 @@ def check_sdl_version() -> None:
134134
sdl_version_str = subprocess.check_output(
135135
["pkg-config", "sdl3", "--modversion"], universal_newlines=True
136136
).strip()
137-
except FileNotFoundError as exc:
138-
msg = (
139-
"libsdl3-dev or equivalent must be installed on your system and must be at least version"
140-
f" {needed_version}.\nsdl3-config must be on PATH."
141-
)
142-
raise RuntimeError(msg) from exc
137+
except FileNotFoundError:
138+
try:
139+
sdl_version_str = subprocess.check_output(["sdl3-config", "--version"], universal_newlines=True).strip()
140+
except FileNotFoundError as exc:
141+
msg = (
142+
f"libsdl3-dev or equivalent must be installed on your system and must be at least version {needed_version}."
143+
"\nsdl3-config must be on PATH."
144+
)
145+
raise RuntimeError(msg) from exc
146+
except subprocess.CalledProcessError as exc:
147+
if sys.version_info >= (3, 11):
148+
exc.add_note(f"Note: {os.environ.get('PKG_CONFIG_PATH')=}")
149+
raise
143150
logger.info(f"Found SDL {sdl_version_str}.")
144151
sdl_version = tuple(int(s) for s in sdl_version_str.split("."))
145152
if sdl_version < SDL_MIN_VERSION:

setup.py

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33

44
from __future__ import annotations
55

6-
import os
76
import platform
8-
import subprocess
97
import sys
108
from pathlib import Path
119

@@ -37,42 +35,11 @@ def get_package_data() -> list[str]:
3735
return files
3836

3937

40-
def check_sdl_version() -> None:
41-
"""Check the local SDL version on Linux distributions."""
42-
if not sys.platform.startswith("linux"):
43-
return
44-
needed_version = "{}.{}.{}".format(*SDL_VERSION_NEEDED)
45-
try:
46-
sdl_version_str = subprocess.check_output(
47-
["pkg-config", "sdl3", "--modversion"], # noqa: S607
48-
universal_newlines=True,
49-
).strip()
50-
except FileNotFoundError:
51-
try:
52-
sdl_version_str = subprocess.check_output(["sdl3-config", "--version"], universal_newlines=True).strip() # noqa: S607
53-
except FileNotFoundError as exc:
54-
msg = (
55-
f"libsdl3-dev or equivalent must be installed on your system and must be at least version {needed_version}."
56-
"\nsdl3-config must be on PATH."
57-
)
58-
raise RuntimeError(msg) from exc
59-
except subprocess.CalledProcessError as exc:
60-
if sys.version_info >= (3, 11):
61-
exc.add_note(f"Note: {os.environ.get('PKG_CONFIG_PATH')=}")
62-
raise
63-
print(f"Found SDL {sdl_version_str}.")
64-
sdl_version = tuple(int(s) for s in sdl_version_str.split("."))
65-
if sdl_version < SDL_VERSION_NEEDED:
66-
msg = f"SDL version must be at least {needed_version}, (found {sdl_version_str})"
67-
raise RuntimeError(msg)
68-
69-
7038
if not (SETUP_DIR / "libtcod/src").exists():
7139
print("Libtcod submodule is uninitialized.")
7240
print("Did you forget to run 'git submodule update --init'?")
7341
sys.exit(1)
7442

75-
check_sdl_version()
7643

7744
setup(
7845
py_modules=["libtcodpy"],

0 commit comments

Comments
 (0)