File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -679,6 +679,7 @@ install(DIRECTORY tools/ DESTINATION ${DATA_PATH}tools
679679 PATTERN "*.pyc" EXCLUDE
680680 PATTERN "*.egg-info" EXCLUDE
681681 PATTERN ".git" EXCLUDE)
682+ install (CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR} /tools/build_config/version.py --sumolib \$ ENV{DESTDIR}${CMAKE_INSTALL_PREFIX} /${DATA_PATH} tools/sumolib/version.py)" )
682683if (DATA_PATH)
683684 install (CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ../../bin \$ ENV{DESTDIR}${CMAKE_INSTALL_PREFIX} /${DATA_PATH} bin)" )
684685endif ()
@@ -914,6 +915,7 @@ if (GIT_FOUND)
914915 COMMAND rm -r sumo-${PACKAGE_VERSION}/tests
915916 COMMAND cp -a docs/tutorial docs/examples sumo-${PACKAGE_VERSION}/docs
916917 COMMAND find tools/contributed/saga/ tools/contributed/traci4matlab -type f | grep -v .git | xargs cp --parents --target-dir sumo-${PACKAGE_VERSION}
918+ COMMAND ${PYTHON_EXECUTABLE} tools/build_config/version.py --sumolib sumo-${PACKAGE_VERSION}/tools/sumolib/version.py
917919 COMMAND mkdir sumo-${PACKAGE_VERSION}/include
918920 COMMAND cp ${CMAKE_BINARY_DIR} /src/version.h sumo-${PACKAGE_VERSION}/include
919921 COMMAND zip -rq sumo-src-${PACKAGE_VERSION}.zip sumo-${PACKAGE_VERSION}
Original file line number Diff line number Diff line change @@ -59,6 +59,13 @@ def create_version_file(versionFile, revision):
5959 print ('#define VERSION_STRING "%s"' % revision , file = f )
6060
6161
62+ def filter_sumolib (version_py ):
63+ with open (version_py ) as inf :
64+ inp = inf .read ()
65+ with open (version_py , "w" ) as outf :
66+ outf .write (inp .replace ('0.0.0' , get_pep440_version ()))
67+
68+
6269def filter_setup_py (in_file , out_file ):
6370 with open (in_file ) as inf , open (out_file , "w" ) as outf :
6471 for line in inf :
@@ -72,7 +79,10 @@ def filter_setup_py(in_file, out_file):
7279
7380def main ():
7481 if len (sys .argv ) > 2 :
75- filter_setup_py (sys .argv [1 ], sys .argv [2 ])
82+ if sys .argv [1 ] == "--sumolib" :
83+ filter_sumolib (sys .argv [2 ])
84+ else :
85+ filter_setup_py (sys .argv [1 ], sys .argv [2 ])
7686 return
7787 # determine output file
7888 if len (sys .argv ) > 1 :
Original file line number Diff line number Diff line change 2828# the visualization submodule is not imported to avoid an explicit matplotlib dependency
2929from .miscutils import openz
3030from .options import pullOptions , ArgumentParser
31+ from .version import _version as __version__
3132from .xml import writeHeader as writeXMLHeader # noqa
3233
3334
Original file line number Diff line number Diff line change 2525import subprocess
2626from os .path import dirname , exists , join
2727
28+ try :
29+ # this tries to determine the version number of an installed wheel
30+ import importlib .metadata # noqa
31+ _version = importlib .metadata .version ("sumolib" )
32+ except ImportError :
33+ # this is the fallback version, it gets replaced with the current version on "make install" or "make dist"
34+ _version = "0.0.0"
35+
2836GITDIR = join (dirname (__file__ ), '..' , '..' , '.git' )
2937
3038
@@ -48,7 +56,7 @@ def fromVersionHeader():
4856 version = config .find ("VERSION_STRING" ) + 16
4957 if version > 16 :
5058 return "v" + config [version :config .find ('"\n ' , version )] + "-" + (10 * "0" )
51- raise EnvironmentError ( "Could not determine version." )
59+ return "v" + _version
5260
5361
5462def gitDescribe (commit = "HEAD" , gitDir = GITDIR , padZero = True ):
You can’t perform that action at this time.
0 commit comments