11#!/usr/bin/env python3
22
33import os
4+ import pathlib
45import platform
56import sys
67import warnings
1112
1213SDL_VERSION_NEEDED = (2 , 0 , 5 )
1314
15+ PATH = pathlib .Path (__file__ ).parent # setup.py current directory
16+
1417
1518def get_version () -> str :
1619 """Get the current version from a git tag, or by reading tcod/version.py"""
@@ -29,13 +32,13 @@ def get_version() -> str:
2932 version += ".dev%i" % commits_since_tag
3033
3134 # update tcod/version.py
32- with open ("tcod/version.py" , "w" ) as version_file :
35+ with open (PATH / "tcod/version.py" , "w" ) as version_file :
3336 version_file .write ('__version__ = "%s"\n ' % version )
3437 return version
3538 except CalledProcessError :
3639 try :
3740 __version__ = "0.0.0"
38- with open ("tcod/version.py" ) as version_file :
41+ with open (PATH / "tcod/version.py" ) as version_file :
3942 exec (version_file .read (), globals ()) # Update __version__
4043 except FileNotFoundError :
4144 warnings .warn ("Unknown version: " "Not in a Git repository and not from a sdist bundle or wheel." )
@@ -66,7 +69,7 @@ def get_package_data() -> List[str]:
6669
6770def get_long_description () -> str :
6871 """Return this projects description."""
69- with open ("README.rst" , "r" ) as readme_file :
72+ with open (PATH / "README.rst" , "r" ) as readme_file :
7073 return readme_file .read ()
7174
7275
@@ -89,7 +92,7 @@ def check_sdl_version() -> None:
8992 raise RuntimeError ("SDL version must be at least %s, (found %s)" % (needed_version , sdl_version_str ))
9093
9194
92- if not os .path .exists ("libtcod/src" ):
95+ if not os .path .exists (PATH / "libtcod/src" ):
9396 print ("Libtcod submodule is uninitialized." )
9497 print ("Did you forget to run 'git submodule update --init'?" )
9598 sys .exit (1 )
0 commit comments