Skip to content

Commit

Permalink
Merge branch 'main' into catch2_ext
Browse files Browse the repository at this point in the history
  • Loading branch information
mathbunnyru committed Nov 20, 2024
2 parents 0da8a00 + d4de99b commit 7dbda11
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 51 deletions.
15 changes: 15 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -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
22 changes: 10 additions & 12 deletions .github/workflows/conda_canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 3 additions & 5 deletions .github/workflows/static_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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%
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows_impl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ^
Expand Down
8 changes: 8 additions & 0 deletions docs/source/installation/micromamba-installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ On macOS, you can install ``micromamba`` from `Homebrew <https://brew.sh/>`_:
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
******************
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/source/user_guide/micromamba.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
12 changes: 8 additions & 4 deletions libmamba/src/core/activation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string> clobbering_env_vars;
Expand Down
78 changes: 50 additions & 28 deletions libmamba/src/core/prefix_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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<std::string, 5>{ get_python_path(),
"-m",
"pip",
"inspect",
"--local" };
const auto args = std::array<std::string, 6>{ get_python_path(), "-q", "-m", "pip",
"inspect", "--local" };

const std::vector<std::pair<std::string, std::string>> env{ { "PYTHONIOENCODING", "utf-8" } };
const std::vector<std::pair<std::string, std::string>> 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`
Expand All @@ -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,
Expand Down

0 comments on commit 7dbda11

Please sign in to comment.