@@ -55,7 +55,21 @@ def get_cmake_generator():
5555 else :
5656 return None
5757
58- def get_version ():
58+ def get_git_version ():
59+ """Returns the version of the polyhedral gravity package by using git describe"""
60+ version_string = subprocess .check_output ([
61+ "git" , "describe" , "--tags" , "--abbrev=0" ,
62+ "--match" , "v[0-9]*.[0-9]*.[0-9]*" , # plain
63+ "--match" , "v[0-9]*.[0-9]*.[0-9]*a*" , # alpha
64+ "--match" , "v[0-9]*.[0-9]*.[0-9]*b*" , # beta
65+ "--match" , "v[0-9]*.[0-9]*.[0-9]*rc*" , # release candidate
66+ "--match" , "v[0-9]*.[0-9]*.[0-9]*.post*" , # post
67+ "--match" , "v[0-9]*.[0-9]*.[0-9]*.dev*" , # dev
68+ ]).decode ("utf-8" ).strip ()
69+ # Remove the leading "v"
70+ return version_string [1 :]
71+
72+ def get_cmake_version ():
5973 """Returns the version of the polyhedral gravity package by reading the CMake file."""
6074 # Path to the CMake file
6175 cmake_file = os .path .join (os .path .dirname (__file__ ), "version.cmake" )
@@ -69,7 +83,7 @@ def get_version():
6983 content = file .read ()
7084
7185 # Use regex to extract the PROJECT_VERSION
72- version_match = re .search (r'set\(PROJECT_VERSION \s+([^\s)]+)\) ' , content )
86+ version_match = re .search (r'set\(POLYHEDRAL_GRAVITY_VERSION \s+"(.*)" ' , content )
7387 if version_match :
7488 return version_match .group (1 )
7589 else :
@@ -196,7 +210,7 @@ def build_extension(self, ext):
196210# --------------------------------------------------------------------------------
197211setup (
198212 name = "polyhedral_gravity" ,
199- version = get_version (),
213+ version = get_cmake_version (),
200214 author = "Jonas Schuhmacher" ,
201215 author_email = "jonas.schuhmacher@tum.de" ,
202216 description = "Package to compute full gravity tensor of a given constant density polyhedron for arbitrary points "
@@ -208,7 +222,7 @@ def build_extension(self, ext):
208222 license = "GPLv3" ,
209223 license_file = "LICENSE" ,
210224 zip_safe = False ,
211- python_requires = ">=3.8 " ,
225+ python_requires = ">=3.9 " ,
212226 include_package_data = True ,
213227 project_urls = {
214228 "Homepage" : "https://github.com/esa/polyhedral-gravity-model" ,
0 commit comments