summaryrefslogtreecommitdiff
path: root/var/spack/repos/builtin.mock/packages/find-externals1/package.py
blob: 25e26dcced482172a0c11e88420346ba14eb9e95 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Copyright 2013-2020 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)

from spack import *

import os
import re


class FindExternals1(AutotoolsPackage):
    executables = ['find-externals1-exe']

    url = "http://www.example.com/find-externals-1.0.tar.gz"

    version('1.0', 'hash-1.0')

    @classmethod
    def determine_spec_details(cls, prefix, exes_in_prefix):
        exe_to_path = dict(
            (os.path.basename(p), p) for p in exes_in_prefix
        )
        if 'find-externals1-exe' not in exe_to_path:
            return None

        exe = spack.util.executable.Executable(
            exe_to_path['find-externals1-exe'])
        output = exe('--version', output=str)
        if output:
            match = re.search(r'find-externals1.*version\s+(\S+)', output)
            if match:
                version_str = match.group(1)
                return Spec('find-externals1@{0}'.format(version_str))