33
44from __future__ import annotations
55
6- import os
76import platform
8- import subprocess
97import sys
108from pathlib import Path
119
1210from setuptools import setup
1311
1412# ruff: noqa: T201
1513
16- SDL_VERSION_NEEDED = (3 , 2 , 0 )
17-
1814SETUP_DIR = Path (__file__ ).parent # setup.py current directory
1915
2016
@@ -37,43 +33,11 @@ def get_package_data() -> list[str]:
3733 return files
3834
3935
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- "\n sdl3-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-
7036if not (SETUP_DIR / "libtcod/src" ).exists ():
7137 print ("Libtcod submodule is uninitialized." )
7238 print ("Did you forget to run 'git submodule update --init'?" )
7339 sys .exit (1 )
7440
75- check_sdl_version ()
76-
7741setup (
7842 py_modules = ["libtcodpy" ],
7943 packages = ["tcod" , "tcod.sdl" , "tcod.__pyinstaller" ],
0 commit comments