Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
73de6d6
cmake: dont force warning compilation options on interface (header-on…
Klaim Oct 20, 2025
9d33727
remove spdlog log-handler from libmamba, moved into it's own library …
Klaim Oct 20, 2025
b92d16f
attempt to enable libmamba-spdlog testing
Klaim Oct 20, 2025
de81483
added missing file that was ignored by git
Klaim Oct 20, 2025
df06ad9
removed problematic git ignore
Klaim Oct 20, 2025
7067dc3
ci: fixed name of the new tests to run
Klaim Oct 20, 2025
092ccb7
cmake fixes to link libmamba-spdlog
Klaim Nov 19, 2025
bca7709
makes sure targets requireing libmamba-spdlog also gets threading fac…
Klaim Nov 19, 2025
ae9ce5d
fixed missing Threads dependency
Klaim Nov 19, 2025
7465127
only build libmamba-spdlog tests for test builds on ci
Klaim Nov 19, 2025
448511e
attempt to fix libmambapy not finding libmamba-spdlog
Klaim Nov 19, 2025
f06aeb4
install setup for libmamba-spdlog
Klaim Nov 21, 2025
cbd6ef2
(micro)mamba and libmambapy uses spdlog based logging
Klaim Nov 21, 2025
11c100d
fixup
Klaim Nov 21, 2025
3db2352
fixup
Klaim Nov 21, 2025
00a7113
woops
Klaim Nov 21, 2025
a10f81c
fix install
Klaim Nov 21, 2025
1254f18
not sure if it's visible that I dont like cmake at all
Klaim Nov 21, 2025
1a6801b
fix from @jjerphan
Klaim Nov 24, 2025
b6b401a
fix config cmake location after install
Klaim Nov 24, 2025
157e30c
fix attempts
Klaim Nov 24, 2025
b4770f2
fixup form @jjerphan
Klaim Nov 24, 2025
c304af7
fixup from @jjerphan
Klaim Nov 24, 2025
9b05c2e
fixup libmambapy
Klaim Nov 24, 2025
1009c50
ci debug info
Klaim Nov 24, 2025
e12d289
potential tests fixup
Klaim Nov 24, 2025
df156d4
fix attempt test_libmamba_logging_spdlog
Klaim Nov 24, 2025
0fbe8f3
ci debug info
Klaim Nov 24, 2025
bcbab18
more debug info
Klaim Nov 24, 2025
a60c9e1
more info
Klaim Nov 24, 2025
cc9652f
debug info
Klaim Nov 24, 2025
e680bcb
more cmake info
Klaim Nov 24, 2025
0c3275f
fix attempt
Klaim Nov 25, 2025
a06ac6e
removed debug info ci
Klaim Nov 25, 2025
9715774
formatting
Klaim Nov 25, 2025
be9628b
tweak
Klaim Nov 25, 2025
5297af2
updates Context documentation to new behavior
Klaim Nov 25, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/unix_impl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ jobs:
-D CMAKE_C_COMPILER_LAUNCHER=sccache \
-D MAMBA_WARNING_AS_ERROR=ON \
-D BUILD_LIBMAMBAPY=OFF \
-D BUILD_LIBMAMBA_SPDLOG_TESTS=ON \
-D ENABLE_MAMBA_ROOT_PREFIX_FALLBACK=OFF
cmake --build build/ --parallel
- name: Show build cache statistics
Expand Down Expand Up @@ -87,6 +88,11 @@ jobs:
run: |
unset CONDARC # Interferes with tests
./build/libmamba/tests/test_libmamba_logging
- name: Run libmamba spdlog-based logging tests
shell: bash -elo pipefail {0}
run: |
unset CONDARC # Interferes with tests
./build/libmamba-spdlog/tests/test_libmamba_logging_spdlog

libmambapy_tests_unix:
name: libmambapy tests
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/windows_impl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ jobs:
-D CMAKE_CXX_COMPILER_LAUNCHER=sccache ^
-D CMAKE_C_COMPILER_LAUNCHER=sccache ^
-D BUILD_LIBMAMBAPY=OFF ^
-D BUILD_LIBMAMBA_SPDLOG_TESTS=ON ^
-D ENABLE_MAMBA_ROOT_PREFIX_FALLBACK=OFF
if %errorlevel% neq 0 exit /b %errorlevel%
cmake --build build/ --parallel
Expand Down Expand Up @@ -89,6 +90,11 @@ jobs:
run: |
unset CONDARC # Interferes with tests
cd ./build/libmamba && ./tests/test_libmamba_logging
- name: Run libmamba spdlog-based logging tests
shell: bash -elo pipefail {0}
run: |
unset CONDARC # Interferes with tests
cd ./build/libmamba && ../libmamba-spdlog/tests/test_libmamba_logging_spdlog
- name: Run libmamba tests
shell: bash -elo pipefail {0}
run: |
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ CMakeLists.txt.user
CMakeCache.txt
CMakeFiles
CMakeScripts
Testing

# There exist other Makefiles in /docs
/Makefile
cmake_install.cmake
Expand Down
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ project(mamba)
option(BUILD_SHARED "Build shared libmamba library" OFF)
option(BUILD_STATIC "Build static libmamba library with static linkage to its dependencies" OFF)
option(BUILD_LIBMAMBA "Build libmamba library" OFF)
option(BUILD_LIBMAMBA_SPDLOG_TESTS "Build libmamba-spdlog library tests" OFF)
option(BUILD_LIBMAMBAPY "Build libmamba Python bindings" OFF)
option(BUILD_LIBMAMBA_TESTS "Build libmamba C++ tests" OFF)
option(BUILD_MAMBA "Build mamba" OFF)
Expand Down Expand Up @@ -74,6 +75,9 @@ endif()
# libmamba library and tests
if(BUILD_LIBMAMBA)
add_subdirectory(libmamba)

# libmamba-spdlog library and tests (if enabled)
add_subdirectory(libmamba-spdlog)
endif()

# Python bindings of libmamba
Expand Down
5 changes: 4 additions & 1 deletion cmake/CompilerWarnings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ function(mamba_target_add_compile_warnings target)
set(warnings ${gcc_warnings})
endif()

target_compile_options("${target}" PRIVATE ${warnings})
get_target_property(type ${target} TYPE)
if(NOT ${type} STREQUAL "INTERFACE_LIBRARY")
target_compile_options("${target}" PRIVATE ${warnings})
endif()

endfunction()
1 change: 1 addition & 0 deletions dev/CMakePresetsMamba.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"BUILD_LIBMAMBA": "ON",
"BUILD_LIBMAMBAPY": "ON",
"BUILD_LIBMAMBA_TESTS": "ON",
"BUILD_LIBMAMBA_SPDLOG_TESTS": "ON",
"BUILD_MAMBA_PACKAGE": "ON"
},
"description": "Base profile for building libmamba and related",
Expand Down
96 changes: 96 additions & 0 deletions libmamba-spdlog/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# Copyright (c) 2025, QuantStack and Mamba Contributors
#
# Distributed under the terms of the BSD 3-Clause License.
#
# The full license is in the file LICENSE, distributed with this software.
cmake_minimum_required(VERSION 3.18.2)

include("../cmake/CompilerWarnings.cmake")

project(libmamba-spdlog)

if(NOT TARGET mamba::libmamba)
find_package(libmamba CONFIG REQUIRED)
set(libmamba_target mamba::libmamba-dyn)
else()
set(libmamba_target mamba::libmamba)
endif()

find_package(spdlog CONFIG REQUIRED)
find_package(Threads REQUIRED)

# For some reasons, using target_compile_definitions does not set the definitions properly
add_compile_definitions(SPDLOG_FMT_EXTERNAL "SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_${BUILD_LOG_LEVEL}")

add_library(libmamba-spdlog INTERFACE)
# target_sources(libmamba-spdlog INTERFACE include/mamba/spdlog/logging_spdlog.hpp
# include/mamba/spdlog/logging_spdlog_impl.hpp )
add_library(mamba::libmamba-spdlog ALIAS libmamba-spdlog)

target_include_directories(
libmamba-spdlog
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include>
)

target_link_libraries(
libmamba-spdlog
INTERFACE
${libmamba_target}
# Since conda-forge spdlog is built with a bundled version of fmt we use the header only
# version to avoid chasing after the correct fmt version matching the one used in the
# bundle.
spdlog::spdlog_header_only
# We need the threading facilities available whatever the user use. This should have been
# part of depending on spdlog but for some reason it's not made available automatically.
Threads::Threads
)

mamba_target_add_compile_warnings(libmamba-spdlog WARNING_AS_ERROR ${MAMBA_WARNING_AS_ERROR})

target_compile_features(libmamba-spdlog INTERFACE cxx_std_20)
set_target_properties(
libmamba-spdlog
PROPERTIES
CXX_STANDARD 20
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
)

include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}Version.cmake"
VERSION 1.0
COMPATIBILITY AnyNewerVersion
)
install(
TARGETS libmamba-spdlog
EXPORT ${PROJECT_NAME}Targets
LIBRARY DESTINATION lib COMPONENT Runtime
ARCHIVE DESTINATION lib COMPONENT Development
RUNTIME DESTINATION bin COMPONENT Runtime
PUBLIC_HEADER DESTINATION include COMPONENT Development
BUNDLE DESTINATION bin COMPONENT Runtime
)
configure_package_config_file(
"${PROJECT_SOURCE_DIR}/cmake/${PROJECT_NAME}Config.cmake.in"
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
)

install(
EXPORT ${PROJECT_NAME}Targets
NAMESPACE mamba::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
)

install(
FILES "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Version.cmake"
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
)

install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/ DESTINATION include)

if(BUILD_LIBMAMBA_SPDLOG_TESTS)
add_subdirectory(tests/)
endif()
5 changes: 5 additions & 0 deletions libmamba-spdlog/cmake/libmamba-spdlogConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

@PACKAGE_INIT@

include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]")
check_required_components("@PROJECT_NAME@")
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
//
// The full license is in the file LICENSE, distributed with this software.

#ifndef MAMBA_CORE_LOGGING_SPDLOG_HPP
#define MAMBA_CORE_LOGGING_SPDLOG_HPP
#ifndef MAMBA_LOGGING_SPDLOG_HPP
#define MAMBA_LOGGING_SPDLOG_HPP

#include <memory>
#include <vector>
Expand Down Expand Up @@ -112,4 +112,6 @@ namespace mamba::logging::spdlogimpl

}

#include "./logging_spdlog_impl.hpp"

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
// Distributed under the terms of the BSD 3-Clause License.
//
// The full license is in the file LICENSE, distributed with this software.
#pragma once

#include <atomic>
#include <memory>
#include <mutex>
Expand All @@ -15,7 +17,6 @@

#include <mamba/core/context.hpp>
#include <mamba/core/execution.hpp>
#include <mamba/core/logging_spdlog.hpp>
#include <mamba/core/tasksync.hpp>
#include <mamba/core/util.hpp>

Expand Down
37 changes: 37 additions & 0 deletions libmamba-spdlog/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
cmake_minimum_required(VERSION 3.16)

find_package(Catch2 REQUIRED)
find_package(Threads REQUIRED)

add_executable(test_libmamba_logging_spdlog test_logging_spdlog.cpp)

target_link_libraries(
test_libmamba_logging_spdlog
PUBLIC
mamba::libmamba
mamba::libmamba-spdlog
mamba::libtesting_mamba_logging_common
Catch2::Catch2WithMain
Threads::Threads
)

target_compile_features(test_libmamba_logging_spdlog PUBLIC cxx_std_20)
set_target_properties(
test_libmamba_logging_spdlog
PROPERTIES
CXX_STANDARD 20
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
)

mamba_target_add_compile_warnings(
test_libmamba_logging_spdlog WARNING_AS_ERROR ${MAMBA_WARNING_AS_ERROR}
)

# ##################################################################################################

add_custom_target(
test_logging_spdlog
COMMAND test_libmamba_logging_spdlog
DEPENDS test_libmamba_logging
)
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
#include <algorithm>
#include <deque>

#define CATCH_CONFIG_MAIN
#include <catch2/catch_all.hpp>
#include <fmt/core.h>

#include <mamba/core/logging_spdlog.hpp>

#include "test_logging_common.hpp"
#include <mamba/spdlog/logging_spdlog.hpp>
#include <mamba/testing/test_logging_common.hpp>

namespace mamba::logging
{
Expand Down
20 changes: 2 additions & 18 deletions libmamba/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ set(
${LIBMAMBA_SOURCE_DIR}/core/link.cpp
${LIBMAMBA_SOURCE_DIR}/core/link.hpp
${LIBMAMBA_SOURCE_DIR}/core/logging.cpp
${LIBMAMBA_SOURCE_DIR}/core/logging_spdlog.cpp
${LIBMAMBA_SOURCE_DIR}/core/menuinst.cpp
${LIBMAMBA_SOURCE_DIR}/core/output.cpp
${LIBMAMBA_SOURCE_DIR}/core/package_cache.cpp
Expand Down Expand Up @@ -382,7 +381,6 @@ set(
${LIBMAMBA_INCLUDE_DIR}/mamba/core/history.hpp
${LIBMAMBA_INCLUDE_DIR}/mamba/core/invoke.hpp
${LIBMAMBA_INCLUDE_DIR}/mamba/core/logging.hpp
${LIBMAMBA_INCLUDE_DIR}/mamba/core/logging_spdlog.hpp
${LIBMAMBA_INCLUDE_DIR}/mamba/core/logging_tools.hpp
${LIBMAMBA_INCLUDE_DIR}/mamba/core/menuinst.hpp
${LIBMAMBA_INCLUDE_DIR}/mamba/core/output.hpp
Expand Down Expand Up @@ -431,7 +429,6 @@ set(
# ================

find_package(fmt CONFIG REQUIRED)
find_package(spdlog CONFIG REQUIRED)
find_package(tl-expected CONFIG REQUIRED)
find_package(nlohmann_json CONFIG REQUIRED)
find_package(simdjson CONFIG REQUIRED)
Expand Down Expand Up @@ -472,11 +469,6 @@ macro(libmamba_create_target target_name linkage output_name)
mamba_target_add_compile_warnings(${target_name} WARNING_AS_ERROR ${MAMBA_WARNING_AS_ERROR})
mamba_target_set_lto(${target_name} MODE ${MAMBA_LTO})

# For some reasons, using target_compile_definitions does not set the definitions properly
add_compile_definitions(
SPDLOG_FMT_EXTERNAL "SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_${BUILD_LOG_LEVEL}"
)

if(${linkage_upper} STREQUAL "STATIC")
message(" -> Statically linking against libmamba (static) dependencies")

Expand All @@ -486,7 +478,7 @@ macro(libmamba_create_target target_name linkage output_name)

target_link_libraries(
${target_name}
PUBLIC fmt::fmt-header-only spdlog::spdlog_header_only yaml-cpp::yaml-cpp
PUBLIC fmt::fmt-header-only yaml-cpp::yaml-cpp
PRIVATE
reproc
reproc++
Expand Down Expand Up @@ -629,15 +621,7 @@ macro(libmamba_create_target target_name linkage output_name)

target_link_libraries(
${target_name}
PUBLIC
${LIBSOLV_LIBRARIES}
${LIBSOLVEXT_LIBRARIES}
yaml-cpp::yaml-cpp
fmt::fmt
# Since conda-forge spdlog is built with a bundled version of fmt we use the header
# only version to avoid chasing after the correct fmt version matching the one used
# in the bundle
spdlog::spdlog_header_only
PUBLIC ${LIBSOLV_LIBRARIES} ${LIBSOLVEXT_LIBRARIES} yaml-cpp::yaml-cpp fmt::fmt
PRIVATE
${LibArchive_LIBRARIES}
${CURL_LIBRARIES}
Expand Down
4 changes: 3 additions & 1 deletion libmamba/include/mamba/core/context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,9 @@ namespace mamba
Ignored if `options.enable_logging == false`.
If `options.enable_logging == true and log_handler.has_value() == false`,
which is the default if this parameter is not specified,
then a default implementation-defined log handler implementation will be used.
then the log handler will not be changed; the current one, if it exists, stays.
If there is a current log-handler and your intent is to remove it, consider using
`mamba::logging::stop_logging()` instead.
*/
Context(const ContextOptions& options = {}, logging::AnyLogHandler log_handler = {});

Expand Down
14 changes: 3 additions & 11 deletions libmamba/src/core/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "mamba/api/configuration.hpp"
#include "mamba/core/context.hpp"
#include "mamba/core/execution.hpp"
#include "mamba/core/logging_spdlog.hpp"
#include "mamba/core/output.hpp"
#include "mamba/core/thread_utils.hpp"
#include "mamba/core/util.hpp"
Expand Down Expand Up @@ -54,17 +53,10 @@ namespace mamba

void Context::start_logging(logging::AnyLogHandler log_handler)
{
if (not logging::get_log_handler()) // don't allow replacing one already set; THINK: OR DO
// WE ALLOW THAT????
// Only change the log-handler if specified, keep the current one otherwise.
if (log_handler)
{
if (log_handler)
{
logging::set_log_handler(std::move(log_handler), output_params);
}
else
{
logging::set_log_handler(logging::spdlogimpl::LogHandler_spdlog{}, output_params);
}
logging::set_log_handler(std::move(log_handler), output_params);
}
}

Expand Down
Loading
Loading