diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000000..5a5dbe4663 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,15 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file + +version: 2 +updates: + - package-ecosystem: github-actions + directory: / + schedule: + interval: weekly + - package-ecosystem: github-actions + directory: .github/actions/workspace/ + schedule: + interval: weekly diff --git a/.github/workflows/conda_canary.yml b/.github/workflows/conda_canary.yml index 2e12a75d14..3eade7a640 100644 --- a/.github/workflows/conda_canary.yml +++ b/.github/workflows/conda_canary.yml @@ -52,18 +52,16 @@ jobs: restore-keys: conda-canary- - name: build libmamba Python bindings run: | - mkdir build - cd build - cmake .. -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX \ - -DBUILD_LIBMAMBAPY=ON \ - -DBUILD_LIBMAMBA=ON \ - -DBUILD_SHARED=ON \ - -DBUILD_MAMBA_PACKAGE=ON \ - -DCMAKE_CXX_COMPILER_LAUNCHER=sccache \ - -DCMAKE_C_COMPILER_LAUNCHER=sccache \ - -GNinja - ninja - ninja install + cmake -B build/ -G Ninja \ + -D CMAKE_INSTALL_PREFIX=$CONDA_PREFIX \ + -D BUILD_LIBMAMBAPY=ON \ + -D BUILD_LIBMAMBA=ON \ + -D BUILD_SHARED=ON \ + -D BUILD_MAMBA_PACKAGE=ON \ + -D CMAKE_CXX_COMPILER_LAUNCHER=sccache \ + -D CMAKE_C_COMPILER_LAUNCHER=sccache + cmake --build build/ --parallel + cmake --install build/ - name: install libmambapy run: pip install -e ./libmambapy/ --no-deps - name: build cache statistics diff --git a/.github/workflows/static_build.yml b/.github/workflows/static_build.yml index 9d2c32a9a5..ce65e5e848 100644 --- a/.github/workflows/static_build.yml +++ b/.github/workflows/static_build.yml @@ -167,18 +167,16 @@ jobs: shell: cmd /C call {0} run: | set CMAKE_PREFIX_PATH=.\vcpkg_installed\x64-windows-static-md;%CONDA_PREFIX%\Library - cmake -S . ^ - -B build ^ + cmake -B build/ -G Ninja ^ -D CMAKE_CXX_COMPILER_LAUNCHER=sccache ^ -D CMAKE_C_COMPILER_LAUNCHER=sccache ^ -D CMAKE_MSVC_RUNTIME_LIBRARY="MultiThreadedDLL" ^ -D CMAKE_BUILD_TYPE="Release" ^ -D BUILD_LIBMAMBA=ON ^ -D BUILD_STATIC=ON ^ - -D BUILD_MICROMAMBA=ON ^ - -G "Ninja" + -D BUILD_MICROMAMBA=ON if %errorlevel% neq 0 exit /b %errorlevel% - cmake --build build + cmake --build build/ --parallel if %errorlevel% neq 0 exit /b %errorlevel% sccache --show-stats if %errorlevel% neq 0 exit /b %errorlevel% diff --git a/.github/workflows/windows_impl.yml b/.github/workflows/windows_impl.yml index a3b3ca3cea..f545d5e5bb 100644 --- a/.github/workflows/windows_impl.yml +++ b/.github/workflows/windows_impl.yml @@ -38,7 +38,7 @@ jobs: - name: Build mamba run: | cmake -B build/ -G Ninja ^ - --preset mamba-win-shared-${{ inputs.build_type }} ^ + --preset mamba-win-shared-${{ inputs.build_type }} ^ -D CMAKE_MSVC_RUNTIME_LIBRARY="MultiThreadedDLL" ^ -D CMAKE_CXX_COMPILER_LAUNCHER=sccache ^ -D CMAKE_C_COMPILER_LAUNCHER=sccache ^ diff --git a/docs/source/installation/micromamba-installation.rst b/docs/source/installation/micromamba-installation.rst index 64d4b9148c..2f2ff36562 100644 --- a/docs/source/installation/micromamba-installation.rst +++ b/docs/source/installation/micromamba-installation.rst @@ -25,6 +25,9 @@ On macOS, you can install ``micromamba`` from `Homebrew `_: brew install micromamba +.. hint:: + + (2024-10-03) Homebrew currently only has version 1 of micromamba, not version 2. See https://github.com/mamba-org/mamba/issues/3495 for updates. Mamba-org releases ****************** @@ -52,6 +55,11 @@ On Windows Powershell, use Invoke-Expression ((Invoke-WebRequest -Uri https://micro.mamba.pm/install.ps1).Content) +A specific micromamba release can be installed by setting the ``VERSION`` environment variable. +The release versions contain a build number in addition to the micromamba version. + +Micromamba releases can be found on Github: https://github.com/mamba-org/micromamba-releases/releases + Self updates ^^^^^^^^^^^^ Once installed, ``micromamba`` can be updated with diff --git a/docs/source/user_guide/micromamba.rst b/docs/source/user_guide/micromamba.rst index b92b0cc281..ad1fc7640c 100644 --- a/docs/source/user_guide/micromamba.rst +++ b/docs/source/user_guide/micromamba.rst @@ -156,7 +156,7 @@ More powerful are ``YAML`` files like the following, because they already contai dependencies: - python >=3.6,<3.7 - ipykernel >=5.1 - - ipywidgets + - ipywidgets[build_number=!=0] They are used the same way as text files: diff --git a/libmamba/src/core/activation.cpp b/libmamba/src/core/activation.cpp index 46169e7fbb..29f999b591 100644 --- a/libmamba/src/core/activation.cpp +++ b/libmamba/src/core/activation.cpp @@ -554,10 +554,14 @@ namespace mamba auto conda_environment_env_vars = get_environment_vars(prefix); // TODO check with conda if that's really what's supposed to happen ... - std::remove_if( - conda_environment_env_vars.begin(), - conda_environment_env_vars.end(), - [](auto& el) { return el.second == CONDA_ENV_VARS_UNSET_VAR; } + // TODO: C++20 replace by `std::erase_if` + conda_environment_env_vars.erase( + std::remove_if( + conda_environment_env_vars.begin(), + conda_environment_env_vars.end(), + [](auto& el) { return el.second == CONDA_ENV_VARS_UNSET_VAR; } + ), + conda_environment_env_vars.end() ); std::vector clobbering_env_vars; diff --git a/libmamba/src/core/prefix_data.cpp b/libmamba/src/core/prefix_data.cpp index c7031dbaff..50e574506d 100644 --- a/libmamba/src/core/prefix_data.cpp +++ b/libmamba/src/core/prefix_data.cpp @@ -17,6 +17,7 @@ #include "mamba/core/output.hpp" #include "mamba/core/prefix_data.hpp" #include "mamba/core/util.hpp" +#include "mamba/core/util_scope.hpp" #include "mamba/specs/conda_url.hpp" #include "mamba/util/environment.hpp" #include "mamba/util/graph.hpp" @@ -215,37 +216,58 @@ namespace mamba const auto get_python_path = [&] { return util::which_in("python", util::get_path_dirs(m_prefix_path)).string(); }; - const auto args = std::array{ get_python_path(), - "-m", - "pip", - "inspect", - "--local" }; + const auto args = std::array{ get_python_path(), "-q", "-m", "pip", + "inspect", "--local" }; - const std::vector> env{ { "PYTHONIOENCODING", "utf-8" } }; + const std::vector> env{ + { "PYTHONIOENCODING", "utf-8" }, + { "NO_COLOR", "1" }, + { "PIP_NO_COLOR", "1" }, + { "PIP_NO_PYTHON_VERSION_WARNING", "1" }, + }; reproc::options run_options; run_options.env.extra = reproc::env{ env }; - LOG_TRACE << "Running command: " - << fmt::format("{}\n env options:{}", fmt::join(args, " "), fmt::join(env, " ")); - - auto [status, ec] = reproc::run( - args, - run_options, - reproc::sink::string(out), - reproc::sink::string(err) - ); - - if (ec) - { - const auto message = fmt::format( - "failed to run python command :\n error: {}\n command ran: {}\n env options:{}\n-> output:\n{}\n\n-> error output:{}", - ec.message(), - fmt::join(args, " "), - fmt::join(env, " "), - out, - err + { // Scoped environment changes + + // We need FORCE_COLOR to be removed to avoid rich output, + // we restore it as soon as the command is run. + const auto maybe_previous_force_color = util::get_env("FORCE_COLOR"); + util::unset_env("FORCE_COLOR"); + on_scope_exit _{ [&] + { + if (maybe_previous_force_color) + { + util::set_env("FORCE_COLOR", maybe_previous_force_color.value()); + } + } }; + + LOG_TRACE << "Running command: " + << fmt::format( + "{}\n env options (FORCE_COLOR is unset):{}", + fmt::join(args, " "), + fmt::join(env, " ") + ); + + auto [status, ec] = reproc::run( + args, + run_options, + reproc::sink::string(out), + reproc::sink::string(err) ); - throw mamba_error{ message, mamba_error_code::internal_failure }; + + if (ec) + { + const auto message = fmt::format( + "failed to run python command :\n error: {}\n command ran: {}\n env options:{}\n-> output:\n{}\n\n-> error output:{}", + ec.message(), + fmt::join(args, " "), + fmt::join(env, " "), + out, + err + ); + throw mamba_error{ message, mamba_error_code::internal_failure }; + } } // Nothing installed with `pip` @@ -261,11 +283,11 @@ namespace mamba { j = nlohmann::json::parse(out); } - catch (const std::exception& exc) + catch (const std::exception& parse_error) { const auto message = fmt::format( "failed to parse python command output:\n error: {}\n command ran: {}\n env options:{}\n-> output:\n{}\n\n-> error output:{}", - exc.what(), + parse_error.what(), fmt::join(args, " "), fmt::join(env, " "), out,