3232 long_description = fh .read ()
3333
3434
35- # Read in the version information
36- FASM_VERSION_FILE = os .path .join (__dir__ , 'fasm' , 'version.py' )
37- with open (FASM_VERSION_FILE ) as f :
38- if 'UNKNOWN' in f .read ():
39- print (
40- "Running update_version.py to generate {}" .format (
41- FASM_VERSION_FILE ))
42- subprocess .check_call (['python' , 'update_version.py' ], cwd = __dir__ )
43- with open (FASM_VERSION_FILE ) as f :
44- lines = f .readlines ()
45- version_line = [v .strip () for v in lines if v .startswith ('version_str' )]
46- assert len (version_line ) == 1 , version_line
47- version_value = version_line [0 ].split (' = ' , 1 )[- 1 ]
48- assert version_value [0 ] == '"' , version_value
49- assert version_value [- 1 ] == '"' , version_value
50- version = version_value [1 :- 1 ]
35+ # Generate the version number
36+ def scm_version ():
37+ def local_scheme (version ):
38+ if version .tag and not version .distance :
39+ return version .format_with ("" )
40+ else :
41+ return version .format_choice ("+{node}" , "+{node}.dirty" )
42+ return {
43+ "relative_to" : __file__ ,
44+ "version_scheme" : "guess-next-dev" ,
45+ "local_scheme" : local_scheme
46+ }
5147
5248
5349# Based on: https://www.benjack.io/2018/02/02/python-cpp-revisited.html
@@ -256,7 +252,7 @@ def run(self):
256252setuptools .setup (
257253 # Package human readable information
258254 name = "fasm" ,
259- version = version ,
255+ use_scm_version = scm_version () ,
260256 author = "SymbiFlow Authors" ,
261257 author_email = "symbiflow@lists.librecores.org" ,
262258 description = "FPGA Assembly (FASM) Parser and Generation library" ,
@@ -280,8 +276,10 @@ def run(self):
280276 setup_requires = [
281277 "wheel" ,
282278 "setuptools" ,
279+ "setuptools_scm" ,
283280 ],
284281 install_requires = [
282+ "importlib_metadata; python_version<'3.8'" , # for __version__
285283 'textx' ,
286284 ],
287285 # C extension building
0 commit comments