Add new package: micromamba (#34195)

* Add new packages

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* style

* wip

* Respond to comments

* Respond to comments

* Spack style

* Remove linkage=full_static to pass package audit

* Spack style

* Moved tl-expected version
This commit is contained in:
Sam Grayson 2022-12-12 13:00:41 -07:00 committed by GitHub
parent cd9c9b47e8
commit 94bac8d6dd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 263 additions and 0 deletions

View file

@ -14,6 +14,7 @@ class Cli11(CMakePackage):
url = "https://github.com/CLIUtils/CLI11/archive/v1.9.1.tar.gz"
maintainers = ["nightlark"]
version("2.3.1", sha256="378da73d2d1d9a7b82ad6ed2b5bda3e7bc7093c4034a1d680a2e009eb067e7b2")
version("2.1.1", sha256="d69023d1d0ab6a22be86b4f59d449422bc5efd9121868f4e284d6042e52f682e")
version("2.1.0", sha256="2661b0112b02478bad3dc7f1749c4825bfc7e37b440cbb4c8c0e2ffaa3999112")
version("2.0.0", sha256="2c672f17bf56e8e6223a3bfb74055a946fa7b1ff376510371902adb9cb0ab6a3")

View file

@ -74,6 +74,10 @@ def configure_args(self):
else:
args.append("--disable-static")
# https://github.com/spack/spack/issues/34193
if "%gcc@10:" in self.spec:
args.append("CFLAGS=-fcommon")
return args
def setup_build_environment(self, env):

View file

@ -0,0 +1,30 @@
# 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)
from spack.package import *
class Libreproc(CMakePackage):
"""A cross-platform process library"""
homepage = "https://github.com/DaanDeMeyer/reproc/"
url = "https://github.com/DaanDeMeyer/reproc/archive/v14.2.4.tar.gz"
maintainers = ["charmoniumQ"]
version("14.2.4", sha256="55c780f7faa5c8cabd83ebbb84b68e5e0e09732de70a129f6b3c801e905415dd")
variant("cxx", default=False, description="Build reproc C++ bindings")
variant("shared", default=True, description="Build shared libraries")
depends_on("cmake@3.14:", type="build")
depends_on("zlib+shared", type="link", when="+shared")
depends_on("zlib~shared", type="link", when="~shared")
def cmake_args(self):
return [
self.define_from_variant("REPROC++", "cxx"),
self.define_from_variant("BUILD_SHARED_LIBS", "shared"),
]

View file

@ -0,0 +1,31 @@
# 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)
from spack.package import *
class Libsolv(CMakePackage):
"""Library for solving packages and reading repositories."""
homepage = "https://en.opensuse.org/OpenSUSE:Libzypp_satsolver"
url = "https://github.com/opensuse/libsolv/archive/0.7.22.tar.gz"
maintainers = ["charmoniumQ"]
version("0.7.22", sha256="968aef452b5493751fa0168cd58745a77c755e202a43fe8d549d791eb16034d5")
variant("shared", default=True, description="Build shared libraries")
variant("conda", default=False, description="Include solv/conda.h")
depends_on("expat", type="link")
depends_on("zlib+shared", type="link", when="+shared")
depends_on("zlib~shared", type="link", when="~shared")
def cmake_args(self):
return [
self.define("ENABLE_STATIC", "~shared" in self.spec),
self.define("DISABLE_DYNAMIC", "~shared" in self.spec),
self.define_from_variant("ENABLE_CONDA", "conda"),
]

View file

@ -0,0 +1,19 @@
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -13,6 +13,16 @@ cmake_policy(SET CMP0077 NEW)
# cmake_policy(SET CMP0028 NEW)
#endif()
+# https://stackoverflow.com/questions/54587052/cmake-on-mac-could-not-find-threads-missing-threads-found
+# assume built-in pthreads on Unix
+IF(UNIX)
+ set(CMAKE_THREAD_LIBS_INIT "-lpthread")
+ set(CMAKE_HAVE_THREADS_LIBRARY 1)
+ set(CMAKE_USE_WIN32_THREADS_INIT 0)
+ set(CMAKE_USE_PTHREADS_INIT 1)
+ set(THREADS_PREFER_PTHREAD_FLAG ON)
+ENDIF()
+
project(mamba)
# Build options

View file

@ -0,0 +1,155 @@
# 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)
from spack.package import *
linkage_url = (
"https://mamba.readthedocs.io/en/latest/developer_zone/build_locally.html#build-micromamba"
)
class Micromamba(CMakePackage):
"""Mamba is a fast, robust, and cross-platform package manager (Miniconda alternative).
Micromamba is faster than Miniconda, and it is a standalone
executable, whereas Miniconda pulls in its own Python environment.
"""
homepage = "https://mamba.readthedocs.io/"
url = "https://github.com/mamba-org/mamba/archive/micromamba-1.1.0.tar.gz"
maintainers = ["charmoniumQ"]
version("1.1.0", sha256="e2392cd90221234ae8ea92b37f40829fbe36d80278056269aa1994a5efe7f530")
variant(
"linkage",
default="dynamic",
description=f"See MICROMAMBA_LINKAGE in {linkage_url}.",
values=(
"dynamic",
"static",
# "full_static",
),
multi=False,
)
patch("fix-threads.patch")
with when("linkage=dynamic"):
# See https://github.com/mamba-org/mamba/blob/micromamba-1.0.0/libmamba/CMakeLists.txt#L423
depends_on("libsolv+conda", type="link")
depends_on("curl libs=shared", type="link")
depends_on("libarchive crypto=mbedtls xar=libxml2", type="link")
depends_on("openssl", type="link")
depends_on("yaml-cpp", type="link")
depends_on("libreproc+cxx+shared", type="link")
depends_on("tl-expected@2022-11-24", type="link")
depends_on("fmt", type="link")
depends_on("spdlog", type="link")
# https://github.com/mamba-org/mamba/blob/micromamba-1.0.0/libmamba/include/mamba/core/validate.hpp#L13
depends_on("nlohmann-json", type="link")
# https://github.com/mamba-org/mamba/blob/micromamba-1.0.0/libmamba/src/core/context.cpp#L7
depends_on("cpp-termcolor", type="link")
# https://github.com/mamba-org/mamba/blob/micromamba-1.0.0/micromamba/src/common_options.hpp#L12
depends_on("cli11@2.2:", type="link")
with when("linkage=static"):
# When linkage is static, BUILD_STATIC=ON
# and then
# https://github.com/mamba-org/mamba/blob/micromamba-1.0.0/libmamba/CMakeLists.txt#L523
# calls libmamba_create_target(libmamba-static STATIC SHARED libmamba)
# where the third argument, SHARED, is the deps_linkage
# as defined here,
# https://github.com/mamba-org/mamba/blob/micromamba-1.0.0/libmamba/CMakeLists.txt#L256
# which would use dynamic linkage here,
# https://github.com/mamba-org/mamba/blob/micromamba-1.0.0/libmamba/CMakeLists.txt#L420
# See linkage=dynamic for what that entails.
depends_on("libsolv+conda", type="link")
depends_on("curl libs=shared", type="link")
depends_on("libarchive crypto=mbedtls xar=libxml2", type="link")
depends_on("openssl", type="link")
depends_on("yaml-cpp", type="link")
depends_on("libreproc+cxx", type="link")
depends_on("tl-expected@2022-11-24", type="link")
depends_on("fmt", type="link")
depends_on("spdlog", type="link")
depends_on("nlohmann-json", type="link")
depends_on("cpp-termcolor", type="link")
depends_on("cli11@2.2:", type="link")
if False:
# This variant currently fails with:
#
# libarchive/archive_digest.c:191: undefined reference to `mbedtls_sha512_free'
#
# These shouldn't be necessary,
# since they are already in 'libarchive crypto=mbedtls xar=libxml2'
# but even adding them doesn't fix it.
#
# depends_on("libxml2", type="link")
# depends_on("mbedtls", type="link")
#
# However, I wanted to live this variant in the code,
# so it serves as a starting point.
with when("linkage=full_static"):
# https://github.com/mamba-org/mamba/blob/micromamba-1.0.0/libmamba/CMakeLists.txt#L276
depends_on("curl libs=static", type="link")
depends_on("libssh2~shared", type="link")
depends_on("krb5~shared", type="link")
depends_on("openssl~shared", type="link")
depends_on("libarchive crypto=mbedtls xar=libxml2", type="link")
depends_on("iconv", type="link")
depends_on("bzip2", type="link")
depends_on("lz4", type="link")
depends_on("zstd", type="link")
depends_on("zlib", type="link")
depends_on("xz libs=static", type="link")
depends_on("lzo", type="link")
depends_on("libsolv+conda~shared", type="link")
depends_on("nghttp2", type="link")
depends_on("yaml-cpp~shared", type="link")
depends_on("libreproc+cxx~shared", type="link")
# https://github.com/mamba-org/mamba/blob/micromamba-1.0.0/libmamba/CMakeLists.txt#L342
depends_on("fmt", type="link")
depends_on("spdlog~shared", type="link")
# https://github.com/mamba-org/mamba/blob/micromamba-1.0.0/libmamba/include/mamba/core/error_handling.hpp#L9
depends_on("tl-expected@2022-11-24", type="link")
# See linkage=dynamic for usage location
depends_on("nlohmann-json", type="link")
depends_on("cpp-termcolor", type="link")
depends_on("cli11@2.2:", type="link")
def cmake_args(self):
# See https://mamba.readthedocs.io/en/latest/developer_zone/build_locally.html#build-micromamba
if "linkage=dynamic" in self.spec:
linkage = "dynamic"
elif "linkage=static" in self.spec:
linkage = "static"
elif "linkage=full_static" in self.spec:
linkage = "full_static"
else:
raise ValueError(f"Unknown linkage type {self.spec}")
return [
self.define("BUILD_LIBMAMBA", True),
self.define("BUILD_MICROMAMBA", True),
self.define("BUILD_STATIC", linkage == "static"),
self.define("BUILD_STATIC_DEPS", linkage == "full_static"),
self.define("BUILD_SHARED", linkage == "dynamic"),
self.define("MICROMAMBA_LINKAGE", linkage.upper()),
]
@run_after("install")
@on_package_attributes(run_tests=True)
def check_install(self):
Executable("micromamba")("--version")

View file

@ -0,0 +1,23 @@
# 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)
from spack.package import *
class TlExpected(CMakePackage):
"""C++11/14/17 std::expected with functional-style extensions."""
homepage = "https://tl.tartanllama.xyz/en/latest/"
url = "https://github.com/TartanLlama/expected/archive/1.0.0.tar.gz"
git = "https://github.com/TartanLlama/expected.git"
maintainers = ["charmoniumQ"]
# Note that the 1.0.0 has this issue:
# https://github.com/TartanLlama/expected/issues/114
# But no new patch version has been released,
# so I will use the latest commit at the time of writing:
version("2022-11-24", commit="b74fecd4448a1a5549402d17ddc51e39faa5020c")
version("1.0.0", sha256="8f5124085a124113e75e3890b4e923e3a4de5b26a973b891b3deb40e19c03cee")