summaryrefslogtreecommitdiff
path: root/var/spack/repos/builtin.mock/packages/find-externals1/package.py
blob: 9200668d7cf730a38b47894a6a822e654b672324 (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
35
# Copyright 2013-2022 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)
import os
import re

import spack.package


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

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

    version('1.0', 'abcdef1234567890abcdef1234567890')

    @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.from_detection(
                    'find-externals1@{0}'.format(version_str)
                )