carnisj / bcdi

BCDI: tools for pre(post)-processing Bragg coherent X-ray diffraction imaging data
Other
23 stars 17 forks source link

Add version function #270

Closed DSimonne closed 2 years ago

DSimonne commented 2 years ago

I added the version function that may work to get the commit hash saved in the version.

It works for me on my personal laptop but not on slurm ...

You should try it

I don't know how to want to use it, maybe :

version = "0.2.7"

def get_git_version():
    """
    Get the full version name with git hash, e.g. "2020.1-65-g958b7254-dirty"
    Only works if the current directory is part of the git repository.
    :return: the version name
    """
    from subprocess import Popen, PIPE
    try:
        p = Popen(['git', 'describe', '--tags', '--dirty', '--always'],
                  stdout=PIPE, stderr=PIPE)
        return p.stdout.readlines()[0].strip().decode("UTF-8")
    except:
        # in distributed & installed versions this is replaced by a string
        __git_version_static__ = "git_version_placeholder"
        if "placeholder" in __git_version_static__:
            return version
        return __git_version_static__

__version__ = get_git_version()
carnisj commented 2 years ago

I don't think that modifying __version__ is a good idea, because it is used for example by PyPi. You could call the function get_git_version in the GUI when you want to check the version of bcdi instead.

DSimonne commented 2 years ago

Indeed, so keep the function there but no modification of version ?

DSimonne commented 2 years ago

Indeed, so keep the function there but no modification of version ?

That is how the files are for now so it should be OK, not sure why there are so many errors though

DSimonne commented 2 years ago

Not sure how to fix the second DeepSource error, I'll try and find the possible exception raised for the fist one