Fix/version propagation
Most actual version information can be taken from the git. In case of a standard installation of the python module the git information became unavailable.
This code stores the version information from the git during installation to the python variable.
In case of a development installation the version is taken directly from the git.
Merge request reports
Activity
34 32 for nb in ctypes.values(): 35 33 data_files.append(nb["notebook"]) 36 34 35 version = check_output(['git', 'describe', '--tag']).decode('utf8') Please add this in form of a proper
PostInstallCommand
. See e.g. here for details:https://stackoverflow.com/questions/20288711/post-install-script-with-python-setuptools.
Note that the discussion explains how to make this a pre-install command.
Also, I suggest to name the file simply
VERSION
, without py, to make it clearer that it includes no code. You could also add a comment that it was autogenerated upon installation to it.Edited by Steffen HaufI tried solution like:
class PostInstallCommand(install): """Post-installation for installation mode.""" def run(self): version = check_output(['git', 'describe', '--tag']).decode('utf8') version = version.replace("\n", "") file = open('xfel_calibrate/_version.py', 'w') file.write('__version__="{}"'.format(version)) file.close() install.run(self) ... setup( cmdclass={ 'install': PostInstallCommand, }, ...
But it does not work. Could point me to the right solution.
changed this line in version 2 of the diff
137 version = version.replace("\n", "") 133 # Try to get version from the git 134 # Will work only in case of the development installation 135 # Suppress output errors 136 # In case of a standard installation a version is stored 137 # in the _version.py file 138 try: 139 git_dir = '{}/../.git'.format(os.path.dirname(__file__)) 140 FNULL = open(os.devnull, 'w') 141 version = check_output(['git', 142 '--git-dir={}'.format(git_dir), 143 'describe', '--tag'], 144 stderr=FNULL).decode('utf8') 145 version = version.replace("\n", "") 146 except: 147 from xfel_calibrate import _version Done.
Edited by Mikhail Karnevskiychanged this line in version 7 of the diff
mentioned in commit d968be02