"spack commands --update-completion"

This commit is contained in:
John Parent
2022-01-24 14:35:44 -05:00
committed by Peter Scheibel
parent e4d4a5193f
commit cf1349ba35
105 changed files with 691 additions and 1065 deletions

View File

@@ -5,7 +5,6 @@
import os
import re
import shutil
import sys
import spack.build_environment
@@ -145,11 +144,7 @@ class Cmake(Package):
# https://gitlab.kitware.com/cmake/cmake/merge_requests/4075
patch('fix-xlf-ninja-mr-4075.patch', sha256="42d8b2163a2f37a745800ec13a96c08a3a20d5e67af51031e51f63313d0dedd1", when="@3.15.5")
generator = "Unix Makefiles"
if sys.platform == 'win32':
generator = "Ninja"
depends_on('ninja')
depends_on('ninja', when='platform=windows')
# We default ownlibs to true because it greatly speeds up the CMake
# build, and CMake is built frequently. Also, CMake is almost always
@@ -232,6 +227,18 @@ class Cmake(Package):
conflicts('%intel@:14', when='@3.14:',
msg="Intel 14 has immature C++11 support")
resource(name='cmake-bootstrap',
url='https://cmake.org/files/v3.21/cmake-3.21.2-windows-x86_64.zip',
checksum='213a4e6485b711cb0a48cbd97b10dfe161a46bfe37b8f3205f47e99ffec434d2',
placement='cmake-bootstrap',
when='@3.0.2: platform=windows')
resource(name='cmake-bootstrap',
url='https://cmake.org/files/v2.8/cmake-2.8.4-win32-x86.zip',
checksum='8b9b520f3372ce67e33d086421c1cb29a5826d0b9b074f44a8a0304e44cf88f3',
placement='cmake-bootstrap',
when='@:2.8.10.2 platform=windows')
phases = ['bootstrap', 'build', 'install']
@classmethod
@@ -259,7 +266,9 @@ def setup_build_environment(self, env):
def bootstrap_args(self):
spec = self.spec
args = []
if not os.name == 'nt':
self.generator = make
if not sys.platform == 'win32':
args.extend(
['--prefix={0}'.format(self.prefix),
'--parallel={0}'.format(make_jobs)]
@@ -290,9 +299,9 @@ def bootstrap_args(self):
args.append('--')
else:
args.append('-DCMAKE_INSTALL_PREFIX=%s' % self.prefix)
if self.spec.satisfies('generator=Ninja'):
if self.spec.satisfies('platform=windows'):
args.append('-GNinja')
self.generator = ninja
args.append('-DCMAKE_BUILD_TYPE={0}'.format(
self.spec.variants['build_type'].value))
@@ -318,35 +327,15 @@ def bootstrap_args(self):
return args
def winbootcmake(self, spec):
from spack import fetch_strategy, stage
urls = {
'3': ('https://cmake.org/files/v3.21/cmake-3.21.2-windows-x86_64.zip', "f21e72ede9d15070602b60b2c14dc779"),
'2': ('https://cmake.org/files/v2.8/cmake-2.8.4-win32-x86.zip', "a2525342e495518101381203bf4484c4")
}
if spec.satisfies('@3.0.2:'):
bootstrap_url = urls['3']
else:
bootstrap_url = urls['2']
remote = fetch_strategy.URLFetchStrategy(url=bootstrap_url[0],
checksum=bootstrap_url[1])
bootstrap_stage_path = os.path.join(self.stage.path, "cmake-bootstraper")
with stage.Stage(remote, path=bootstrap_stage_path) as bootstrap_stage:
remote.stage = bootstrap_stage
remote.fetch()
remote.check()
remote.expand()
shutil.move(bootstrap_stage.source_path, self.stage.source_path)
def cmake_bootstrap(self):
exe_prefix = self.stage.source_path
relative_cmake_exe = os.path.join('spack-src', 'bin', 'cmake.exe')
relative_cmake_exe = os.path.join('cmake-bootstrap', 'bin', 'cmake.exe')
return Executable(os.path.join(exe_prefix, relative_cmake_exe))
def bootstrap(self, spec, prefix):
bootstrap_args = self.bootstrap_args()
if os.name == 'nt':
self.winbootcmake(spec)
if sys.platform == 'win32':
# self.winbootcmake(spec)
bootstrap = self.cmake_bootstrap()
bootstrap_args.extend(['.'])
else:
@@ -354,25 +343,16 @@ def bootstrap(self, spec, prefix):
bootstrap(*bootstrap_args)
def build(self, spec, prefix):
if self.generator == "Ninja":
ninja()
else:
make()
self.generator()
@run_after('build')
@on_package_attributes(run_tests=True)
def build_test(self):
# Some tests fail, takes forever
if self.generator == "Ninja":
ninja('test')
else:
make('test')
self.generator('test')
def install(self, spec, prefix):
if self.generator == "Ninja":
ninja('install')
else:
make('install')
self.generator('install')
if spec.satisfies('%fj'):
for f in find(self.prefix, 'FindMPI.cmake', recursive=True):

View File

@@ -16,18 +16,17 @@ class Nasm(Package):
url = "https://www.nasm.us/pub/nasm/releasebuilds/2.14.02/nasm-2.14.02.tar.gz"
list_url = "https://www.nasm.us/pub/nasm/releasebuilds"
list_depth = 1
a = '3caf6729c1073bf96629b57cee31eeb54f4f8129b01902c73428836550b30a3f'
version('2.15.05', sha256='9182a118244b058651c576baa9d0366ee05983c4d4ae1d9ddd3236a9f2304997')
version('2.14.02', sha256='e24ade3e928f7253aa8c14aa44726d1edf3f98643f87c9d72ec1df44b26be8f5')
version('2.13.03', sha256='812ecfb0dcbc5bd409aaa8f61c7de94c5b8752a7b00c632883d15b2ed6452573')
version('2.11.06', sha256='90f60d95a15b8a54bf34d87b9be53da89ee3d6213ea739fb2305846f4585868a')
version('2.14.02', sha256='b34bae344a3f2ed93b2ca7bf25f1ed3fb12da89eeda6096e3551fd66adeae9fc')
version('2.13.03', sha256='23e1b679d64024863e2991e5c166e19309f0fe58a9765622b35bd31be5b2cc99')
version('2.11.06', sha256='3a72476f3cb45294d303f4d34f20961b15323ac24e84eb41bc130714979123bb')
# Fix compilation with GCC 8
# https://bugzilla.nasm.us/show_bug.cgi?id=3392461
patch('https://src.fedoraproject.org/rpms/nasm/raw/0cc3eb244bd971df81a7f02bc12c5ec259e1a5d6/f/0001-Remove-invalid-pure_func-qualifiers.patch', level=1, sha256='ac9f315d204afa6b99ceefa1fe46d4eed2b8a23c7315d32d33c0f378d930e950', when='@2.13.03 %gcc@8:')
patch('msvc.mak.patch', when='platform=windows')
patch('msvc.mak.patch', when='@2.15.05 platform=windows')
conflicts('%intel@:14', when='@2.14:',
msg="Intel 14 has immature C11 support")

View File

@@ -91,7 +91,8 @@ class Openssl(Package): # Uses Fake Autotools, should subclass Package
'package, symlink system certificates, or none'))
variant('docs', default=False, description='Install docs and manpages')
variant('shared', default=False, description="Build shared library version")
variant('dynamic', default=False, description="Link with MSVC's dynamic runtime library")
with when('platform=windows'):
variant('dynamic', default=False, description="Link with MSVC's dynamic runtime library")
depends_on('zlib')
depends_on('perl@5.14.0:', type=('build', 'test'))
@@ -144,25 +145,35 @@ def install(self, spec, prefix):
if spec.satisfies('~shared'):
shared_flag = 'no-shared'
def configure_args():
base_args = ['--prefix=%s' % prefix,
'--openssldir=%s'
% join_path(prefix, 'etc', 'openssl')]
if spec.satisfies('platform=windows'):
base_args.extend([
'CC=%s' % os.environ.get('CC'),
'CXX=%s' % os.environ.get('CXX'),
'%s' % shared_flag,
'VC-WIN64A',
])
base_args.insert(0, 'Configure')
else:
base_args.extend(
[
'-I{0}'.format(self.spec['zlib'].prefix.include),
'-L{0}'.format(self.spec['zlib'].prefix.lib)
]
)
base_args.extend(options)
return base_args
# On Windows, we use perl for configuration and build through MSVC
# nmake.
if spec.satisfies('platform=windows'):
config = Executable('perl')
config('Configure',
'--prefix=%s' % prefix,
'--openssldir=%s' % join_path(prefix, 'etc', 'openssl'),
'CC=\"%s\"' % os.environ.get('SPACK_CC'),
'CXX=\"%s\"' % os.environ.get('SPACK_CXX'),
'%s' % shared_flag,
'VC-WIN64A', ignore_quotes=True)
else:
config = Executable('./config')
config('--prefix=%s' % prefix,
'--openssldir=%s' % join_path(prefix, 'etc', 'openssl'),
'-I{0}'.format(self.spec['zlib'].prefix.include),
'-L{0}'.format(self.spec['zlib'].prefix.lib),
*options)
config(*configure_args())
# Remove non-standard compiler options if present. These options are
# present e.g. on Darwin. They are non-standard, i.e. most compilers
# (e.g. gcc) will not accept them.
@@ -178,26 +189,17 @@ def install(self, spec, prefix):
"+dynamic to suppress this warning.")
if spec.satisfies('platform=windows'):
nmake = Executable('nmake')
nmake()
host_make = nmake
else:
make()
host_make = make
if self.run_tests:
if spec.satisfies('platform=windows'):
nmake = Executable('nmake')
nmake('test', parallel=False)
else:
make('test', parallel=False) # 'VERBOSE=1'
host_make('test', parallel=False) # 'VERBOSE=1'
install_tgt = 'install' if self.spec.satisfies('+docs') else 'install_sw'
# See https://github.com/openssl/openssl/issues/7466#issuecomment-432148137
if spec.satisfies('platform=windows'):
nmake = Executable('nmake')
nmake(install_tgt, parallel=False)
else:
make(install_tgt, parallel=False)
host_make(install_tgt, parallel=False)
@run_after('install')
def link_system_certs(self):

View File

@@ -13,6 +13,7 @@
#
import os
import platform
import re
from contextlib import contextmanager
@@ -22,8 +23,7 @@
from spack import *
from spack.operating_systems.mac_os import macos_version
host = spack.platforms.host()
is_windows = str(host) == 'windows'
is_windows = str(spack.platforms.host()) == 'windows'
class Perl(Package): # Perl doesn't use Autotools, it should subclass Package
@@ -200,10 +200,13 @@ def nmake_arguments(self):
args.append("ALL_STATIC=%s" % "define")
if self.spec.satisfies('~threads'):
args.extend(["USE_MULTI=undef", "USE_ITHREADS=undef", "USE_IMP_SYS=undef"])
if not host.is_64bit():
if not self.is_64bit():
args.append("WIN64=undef")
return args
def is_64bit(self):
return platform.machine().endswith('64')
def configure_args(self):
spec = self.spec
prefix = self.prefix
@@ -286,7 +289,7 @@ def symlink_windows(self):
if not is_windows:
return
win_install_path = os.path.join(self.prefix.bin, "MSWin32")
if host.is_64bit():
if self.is_64bit():
win_install_path += "-x64"
else:
win_install_path += "-x86"
@@ -305,12 +308,12 @@ def symlink_windows(self):
def install_cpanm(self):
spec = self.spec
maker = make
win_prefix = ''
cpan_dir = join_path('cpanm', 'cpanm')
if is_windows:
maker = nmake
win_prefix = self.stage.source_path
cpan_dir = join_path(self.stage.source_path, cpan_dir)
if '+cpanm' in spec:
with working_dir(join_path(win_prefix, 'cpanm', 'cpanm')):
with working_dir(cpan_dir):
perl = spec['perl'].command
perl('Makefile.PL')
maker()

View File

@@ -22,9 +22,7 @@
from spack.util.environment import is_system_path
from spack.util.prefix import Prefix
arch_map = {"AMD64": "x64", "x86": "Win32",
"IA64": "Win32", "EM64T": "Win32"}
is_windows = os.name == 'nt'
is_windows = sys.platform == 'win32'
class Python(Package):
@@ -37,7 +35,6 @@ class Python(Package):
maintainers = ['adamjstewart', 'skosukhin', 'scheibelp', 'varioustoxins']
phases = ['configure', 'build', 'install']
#: phase
@@ -182,7 +179,7 @@ class Python(Package):
variant('tix', default=False, description='Build Tix module')
variant('ensurepip', default=True, description='Build ensurepip module', when='@2.7.9:2,3.4:')
if os.name != 'nt':
if not is_windows:
depends_on('pkgconfig@0.9.0:', type='build')
depends_on('gettext +libxml2', when='+libxml2')
depends_on('gettext ~libxml2', when='~libxml2')
@@ -456,20 +453,20 @@ def flag_handler(self, name, flags):
# allow flags to be passed through compiler wrapper
return (flags, None, None)
@property
def configure_directory(self):
"""Returns the directory where 'configure' resides.
:return: directory where to find configure
"""
return self.stage.source_path
@property
def build_directory(self):
"""Override to provide another place to build the package"""
return self.configure_directory
@property
def plat_arch(self):
"""
String referencing platform architecture
filtered through Python's Windows build file
architecture support map
Note: This function really only makes
sense to use on Windows, could be overridden to
cross compile however.
"""
arch_map = {"AMD64": "x64", "x86": "Win32",
"IA64": "Win32", "EM64T": "Win32"}
arch = platform.machine()
if arch in arch_map:
arch = arch_map[arch]
@@ -477,6 +474,13 @@ def plat_arch(self):
@property
def win_build_params(self):
"""
Arguments must be passed to the Python build batch script
in order to configure it to spec and system.
A number of these toggle optional MSBuild Projects
directly corresponding to the python support of the same
name.
"""
args = []
args.append("-p %s" % self.plat_arch)
if self.spec.satisfies('+debug'):
@@ -490,6 +494,15 @@ def win_build_params(self):
return args
def win_installer(self, prefix):
"""
Python on Windows does not export an install target
so we must handcraft one here. This structure
directly mimics the install tree of the Python
Installer on Windows.
Parameters:
prefix (str): Install prefix for package
"""
proj_root = self.stage.source_path
pcbuild_root = os.path.join(proj_root, "PCbuild")
build_root = os.path.join(pcbuild_root, platform.machine().lower())
@@ -636,7 +649,7 @@ def configure(self, spec, prefix):
:meth:`~spack.build_systems.autotools.AutotoolsPackage.configure_args`
and an appropriately set prefix.
"""
with working_dir(self.build_directory, create=True):
with working_dir(self.stage.source_path, create=True):
if is_windows:
pass
else:
@@ -651,7 +664,7 @@ def build(self, spec, prefix):
"""
# Windows builds use a batch script to drive
# configure and build in one step
with working_dir(self.build_directory):
with working_dir(self.stage.source_path):
if is_windows:
pcbuild_root = os.path.join(self.stage.source_path, "PCbuild")
builder_cmd = os.path.join(pcbuild_root, 'build.bat')
@@ -673,7 +686,7 @@ def install(self, spec, prefix):
"""Makes the install targets specified by
:py:attr:``~.AutotoolsPackage.install_targets``
"""
with working_dir(self.build_directory):
with working_dir(self.stage.source_path):
if is_windows:
self.win_installer(prefix)
else:
@@ -846,7 +859,7 @@ def command(self):
# in that order if using python@3.6.5, for example.
version = self.spec.version
for ver in [version.up_to(2), version.up_to(1), '']:
if sys.platform != "win32":
if not is_windows:
path = os.path.join(self.prefix.bin, 'python{0}'.format(ver))
else:
path = os.path.join(self.prefix, 'python{0}.exe'.format(ver))
@@ -897,10 +910,6 @@ def config_vars(self):
dict: variable definitions
"""
# TODO: distutils is deprecated in Python 3.10 and will be removed in
# Python 3.12, find a different way to access this information.
# Also, calling the python executable disallows us from cross-compiling,
# so we want to try to avoid that if possible.
cmd = """
import json
from sysconfig import (
@@ -1007,9 +1016,6 @@ def libs(self):
# In Ubuntu 16.04.6 and python 2.7.12 from the system, lib could be
# in LBPL
# https://mail.python.org/pipermail/python-dev/2013-April/125733.html
# LIBPL does not exist in Windows, avoid uneccesary KeyError while allowing
# later failures.
# Return empty string rather than none so os.path doesn't complain
libpl = self.config_vars['LIBPL']
# The system Python installation on macOS and Homebrew installations
@@ -1359,7 +1365,7 @@ def deactivate(self, ext_pkg, view, **args):
))
def add_files_to_view(self, view, merge_map):
bin_dir = self.spec.prefix.bin if os.name != 'nt'\
bin_dir = self.spec.prefix.bin if sys.platform != 'win32'\
else self.spec.prefix
for src, dst in merge_map.items():
if not path_contains_subdirectory(src, bin_dir):
@@ -1392,7 +1398,7 @@ def add_files_to_view(self, view, merge_map):
view.link(new_link_target, dst, spec=self.spec)
def remove_files_from_view(self, view, merge_map):
bin_dir = self.spec.prefix.bin if os.name != 'nt'\
bin_dir = self.spec.prefix.bin if not is_windows\
else self.spec.prefix
for src, dst in merge_map.items():
if not path_contains_subdirectory(src, bin_dir):

View File

@@ -4,10 +4,11 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import re
import sys
from spack import *
is_windows = str(spack.platforms.host()) == 'windows'
is_windows = sys.platform == 'win32'
class Ruby(Package):
@@ -123,13 +124,13 @@ def setup_dependent_package(self, module, dependent_spec):
def configure(self, spec, prefix):
with working_dir(self.stage.source_path, create=True):
# if is_windows:
Executable("win32\\configure.bat")("--prefix=%s" % self.prefix)
# else:
# options = getattr(self, 'configure_flag_args', [])
# options += ['--prefix={0}'.format(prefix)]
# options += self.configure_args()
# configure(*options)
if is_windows:
Executable("win32\\configure.bat")("--prefix=%s" % self.prefix)
else:
options = getattr(self, 'configure_flag_args', [])
options += ['--prefix={0}'.format(prefix)]
options += self.configure_args()
configure(*options)
def build(self, spec, prefix):
with working_dir(self.stage.source_path):

View File

@@ -10,14 +10,15 @@
from os import O_NONBLOCK
from os.path import basename
from subprocess import PIPE, Popen
from sys import platform as _platform
from sys import stdout
from sys import platform, stdout
from llnl.util import tty
from spack import *
if _platform != 'win32':
is_windows = platform == 'win32'
if not is_windows:
from fcntl import F_GETFL, F_SETFL, fcntl
from os import O_NONBLOCK, rename
else:
@@ -36,9 +37,8 @@ def setNonBlocking(fd):
Set the given file descriptor to non-blocking
Non-blocking pipes are not supported on windows
"""
if _platform != 'win32':
flags = fcntl(fd, F_GETFL) | O_NONBLOCK
fcntl(fd, F_SETFL, flags)
flags = fcntl(fd, F_GETFL) | O_NONBLOCK
fcntl(fd, F_SETFL, flags)
def collect_platform_options(stdoutpipe):
@@ -303,8 +303,9 @@ def configure(self, spec, prefix):
)
p = Popen("./configure", stdin=PIPE, stdout=PIPE, stderr=PIPE)
setNonBlocking(p.stdout)
setNonBlocking(p.stderr)
if not is_windows:
setNonBlocking(p.stdout)
setNonBlocking(p.stderr)
# Because of WRFs custom configure scripts that require interactive
# input we need to parse and respond to questions. The details can

View File

@@ -49,20 +49,19 @@ def win_install(self):
compose_src_path = lambda x: os.path.join(build_dir, x)
install_tree["include"] = [compose_src_path("zlib.h"),
compose_src_path("zconf.h")]
install_tree["share"] = {"man": {"man3": [compose_src_path("zlib.3")]}}
# Windows path seps are fine here as this method is Windows specific.
install_tree["share\\man\\man3"] = [compose_src_path("zlib.3")]
def installtree(dst, tree):
for inst_dir in tree:
if type(tree[inst_dir]) is list:
install_dst = getattr(dst, inst_dir)
try:
os.makedirs(install_dst)
except OSError:
pass
for file in tree[inst_dir]:
copy(file, install_dst)
else:
installtree(getattr(dst, inst_dir), tree[inst_dir])
install_dst = getattr(dst, inst_dir)
try:
os.makedirs(install_dst)
except OSError:
pass
for file in tree[inst_dir]:
install(file, install_dst)
installtree(self.prefix, install_tree)
def setup_build_environment(self, env):