Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions libmamba/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,8 @@ set(
${LIBMAMBA_SOURCE_DIR}/api/configuration.cpp
${LIBMAMBA_SOURCE_DIR}/api/create.cpp
${LIBMAMBA_SOURCE_DIR}/api/env.cpp
${LIBMAMBA_SOURCE_DIR}/api/environment_yaml.cpp
${LIBMAMBA_SOURCE_DIR}/api/export.cpp
${LIBMAMBA_SOURCE_DIR}/api/info.cpp
${LIBMAMBA_SOURCE_DIR}/api/install.cpp
${LIBMAMBA_SOURCE_DIR}/api/list.cpp
Expand Down Expand Up @@ -423,6 +425,8 @@ set(
${LIBMAMBA_INCLUDE_DIR}/mamba/api/constants.hpp
${LIBMAMBA_INCLUDE_DIR}/mamba/api/create.hpp
${LIBMAMBA_INCLUDE_DIR}/mamba/api/env.hpp
${LIBMAMBA_INCLUDE_DIR}/mamba/api/environment_yaml.hpp
${LIBMAMBA_INCLUDE_DIR}/mamba/api/export.hpp
${LIBMAMBA_INCLUDE_DIR}/mamba/api/info.hpp
${LIBMAMBA_INCLUDE_DIR}/mamba/api/install.hpp
${LIBMAMBA_INCLUDE_DIR}/mamba/api/list.hpp
Expand Down
70 changes: 70 additions & 0 deletions libmamba/include/mamba/api/environment_yaml.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// Copyright (c) 2026, 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.

#ifndef MAMBA_API_ENVIRONMENT_YAML_HPP
#define MAMBA_API_ENVIRONMENT_YAML_HPP

#include <iosfwd>
#include <map>
#include <string>
#include <vector>

#include "mamba/fs/filesystem.hpp"

// Include install.hpp for other_pkg_mgr_spec definition (needed by yaml_file_contents)
#include "mamba/api/install.hpp"

namespace mamba
{
class Context;
class PrefixData;

/** Options for converting prefix data to YAML export contents */
struct PrefixToYamlOptions
{
bool no_builds = false;
bool ignore_channels = false;
bool include_md5 = false;
};

namespace detail
{
// yaml_file_contents is now defined here instead of install.hpp
struct yaml_file_contents
{
std::string name;
std::string prefix;
std::vector<std::string> dependencies, channels;
std::map<std::string, std::string> variables;
std::vector<other_pkg_mgr_spec> others_pkg_mgrs_specs;
};
}

// Convert PrefixData to yaml_file_contents
detail::yaml_file_contents prefix_to_yaml_contents(
const PrefixData& prefix_data,
const Context& ctx,
const std::string& env_name = "",
const PrefixToYamlOptions& options = {}
);

// Write yaml_file_contents to output stream
void yaml_contents_to_stream(const detail::yaml_file_contents& contents, std::ostream& out);

// Write yaml_file_contents to YAML file
void
yaml_contents_to_file(const detail::yaml_file_contents& contents, const fs::u8path& yaml_file_path);

// Read YAML file to yaml_file_contents
detail::yaml_file_contents file_to_yaml_contents(
const Context& ctx,
const std::string& yaml_file,
const std::string& platform,
bool use_uv = false
);
}

#endif
19 changes: 19 additions & 0 deletions libmamba/include/mamba/api/export.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright (c) 2026, 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.

#ifndef MAMBA_API_EXPORT_HPP
#define MAMBA_API_EXPORT_HPP

#include "mamba/api/configuration.hpp"

namespace mamba
{
class Configuration;

void export_environment(Configuration& config);
}

#endif
16 changes: 2 additions & 14 deletions libmamba/include/mamba/api/install.hpp
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are changes made to this file API breakages?

Original file line number Diff line number Diff line change
Expand Up @@ -112,23 +112,11 @@ namespace mamba

bool operator==(const other_pkg_mgr_spec& s1, const other_pkg_mgr_spec& s2);

struct yaml_file_contents
{
std::string name;
std::vector<std::string> dependencies, channels;
std::map<std::string, std::string> variables;
std::vector<other_pkg_mgr_spec> others_pkg_mgrs_specs;
};
// yaml_file_contents moved to environment_yaml.hpp
struct yaml_file_contents; // Forward declaration

bool eval_selector(const std::string& selector, const std::string& platform);

yaml_file_contents read_yaml_file(
const Context& ctx,
const std::string& yaml_file,
const std::string& platform,
bool use_uv
);

inline void to_json(nlohmann::json&, const other_pkg_mgr_spec&)
{
}
Expand Down
Loading
Loading