示例#1
0
    def patch(self):
        filter_file(
            'INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/../include"',
            'INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"',
            'hip-config.cmake.in',
            string=True)

        perl = self.spec['perl'].command
        kwargs = {'ignore_absent': False, 'backup': False, 'string': False}

        with working_dir('bin'):
            match = '^#!/usr/bin/perl'
            substitute = "#!{perl}".format(perl=perl)
            files = [
                'hipify-perl', 'hipcc', 'extractkernel', 'hipconfig',
                'hipify-cmakefile'
            ]
            filter_file(match, substitute, *files, **kwargs)

            # This guy is used during the cmake phase, so we have to fix the
            # shebang already here in case it is too long.
            filter_shebang('hipconfig')

        if '@3.7.0:' in self.spec:
            numactl = self.spec['numactl'].prefix.lib
            kwargs = {'ignore_absent': False, 'backup': False, 'string': False}

            with working_dir('bin'):
                match = ' -lnuma'
                substitute = " -L{numactl} -lnuma".format(numactl=numactl)
                filter_file(match, substitute, 'hipcc', **kwargs)
示例#2
0
def test_sbang_hook_handles_non_writable_files_preserving_permissions(tmpdir):
    path = str(tmpdir.join('file.sh'))
    with open(path, 'w') as f:
        f.write(long_line)
    os.chmod(path, 0o555)
    sbang.filter_shebang(path)
    with open(path, 'r') as f:
        assert 'sbang' in f.readline()
    assert os.stat(path).st_mode & 0o777 == 0o555
示例#3
0
文件: package.py 项目: koning/axom
    def install(self, spec, prefix):
        # simply install to the spack python
        python('setup.py', 'install') 

        # shroud lives in python's bin dir
        shroud_scripts = ["shroud"]
        for script in shroud_scripts:
            script_path = join_path(spec["python"].prefix,"bin",script)
            # use spack sbang to fix issues with shebang that is too long
            filter_shebang(script_path)
示例#4
0
 def install(self, spec, prefix):
     # simply install to the spack python
     python('setup.py', 'install') #, '--prefix=%s' % prefix)
     # sphinx_build lives in python's bin dir
     sphinx_scripts = ["sphinx-apidoc",
                       "sphinx-autogen",
                       "sphinx-build",
                       "sphinx-quickstart"]
     for script in sphinx_scripts:
         script_path = join_path(spec["python3"].prefix,"bin",script)
         # use spack sbang to fix issues with shebang that is too long
         filter_shebang(script_path)
示例#5
0
 def install(self, spec, prefix):
     # simply install to the spack python
     python('setup.py', 'install')  #, '--prefix=%s' % prefix)
     # sphinx_build lives in python's bin dir
     sphinx_scripts = [
         "sphinx-apidoc", "sphinx-autogen", "sphinx-build",
         "sphinx-quickstart"
     ]
     for script in sphinx_scripts:
         script_path = join_path(spec["python"].prefix, "bin", script)
         # use spack sbang to fix issues with shebang that is too long
         filter_shebang(script_path)
示例#6
0
 def install(self, spec, prefix):
     # breathe + sphinx doesn't play well with --prefix installs, for now simply 
     # install to the spack python
     python('setup.py', 'install') #, '--prefix=%s' % prefix)
     # sphinx_build lives in python's bin dir and for some reason breathe's
     # setuptools install reinstalls the sphinx build scripts (even though
     # it finds the existing sphinx install).
     # To keep this from undermining us, we need to patch the new copies
     # of these scripts.
     sphinx_scripts = ["sphinx-apidoc",
                       "sphinx-autogen",
                       "sphinx-build",
                       "sphinx-quickstart"]
     for script in sphinx_scripts:
         script_path = join_path(spec["python3"].prefix,"bin",script)
         # use spack sbang to fix issues with shebang that is too long
         filter_shebang(script_path)
示例#7
0
def test_shebang_exceeds_spack_shebang_limit(shebang_limits_system_8_spack_16, tmpdir):
    """Tests whether shebangs longer than Spack's limit are skipped"""
    file = str(tmpdir.join('longer_than_spack_limit.sh'))
    with open(file, 'wb') as f:
        f.write(b'#!' + b'x' * sbang.spack_shebang_limit)

    # Then Spack shouldn't try to add a shebang
    assert not sbang.filter_shebang(file)

    with open(file, 'rb') as f:
        assert b'sbang' not in f.read()
示例#8
0
def test_sbang_handles_non_utf8_files(tmpdir):
    # We have an executable with a copyright sign as filename
    contents = (b'#!' + b'\xa9' * sbang.system_shebang_limit +
                b'\nand another symbol: \xa9')

    # Make sure it's indeed valid latin1 but invalid utf-8.
    assert contents.decode('latin1')
    with pytest.raises(UnicodeDecodeError):
        contents.decode('utf-8')

    # Put it in an executable file
    file = str(tmpdir.join('latin1.sh'))
    with open(file, 'wb') as f:
        f.write(contents)

    # Run sbang
    assert sbang.filter_shebang(file)

    with open(file, 'rb') as f:
        new_contents = f.read()

    assert contents in new_contents
    assert b'sbang' in new_contents