spack / spack

A flexible package manager that supports multiple versions, configurations, platforms, and compilers.
https://spack.io
Other
4.27k stars 2.26k forks source link

Issue with patch cache when branch is used as a version #32044

Open uturuncoglu opened 2 years ago

uturuncoglu commented 2 years ago

Steps to reproduce

I tried to install a development branch of the ESMF package but it did not work. I just add following code to ESMF package.py to make available all branches and tags in the package.

   import subprocess
...
...
...
   # list refs/heads and refs/tags and add them as version
    git_exe = which('git', required=True)
    cmd = '{} ls-remote --refs {}'.format(git_exe, git)
    git_lst = subprocess.run(cmd, shell=True, text=True, stdout=subprocess.PIPE).stdout.splitlines()

    # loop over list and define them as version
    for item in git_lst:
        # split item as hash, branch/tag name
        item_lst = list(item.split('\t'))

        # replace / with _ in version name since spack does not good with / in the version string
        _name = item_lst[1]
        refs_name = _name.replace('refs/heads/', '')
        refs_name = refs_name.replace('refs/tags/', '')
        version_name = refs_name.replace('/', '_')

        # skip some common branches
        if 'gh-pages' in _name:
            continue

        # add tags and branches to the version
        if 'refs/tags' in _name:
            version(version_name, tag=refs_name)
        elif 'refs/heads' in _name:
            version(version_name, branch=refs_name)

and then I tried to install esmf@io_multitile.

Error message

spack_debug.txt

Information on your system

General information

uturuncoglu commented 2 years ago

@becker33 @climbfuji I also forgot to mention but gcc patch for ESMF https://github.com/spack/spack/blob/develop/var/spack/repos/builtin/packages/esmf/gcc.patch is failing with this version of code (up-to-date with head of develop of ESMF) since the code is already fixed in the ESMF side.

I am not sure how we need to check the version when we are trying to use branch to install ESMF as spack package since gcc patch is defined like following,

patch("gcc.patch", when="@:7.0 %gcc@6:")

So, it is version dependent but getting version from branch is not supported currently (I think). We could implement a way of running make info first before the build and this will output bunch of staff related with the configuration but also output information like following

--------------------------------------------------------------
ESMF_VERSION_STRING:      8.4.0 beta snapshot
ESMF_VERSION_STRING_GIT: v8.4.0b09-17-g9b07e88eec
--------------------------------------------------------------

So, this can be parsed and used as a version but as I know there is no way to define version if you add as branch. Maybe ESMF_VERSION_STRING_GIT can be retrieved with git command. Anyway, this is another thing that I need to explore. So, at this point the gcc patch can be manually commented for this special case.