Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some backports #2936

Merged
merged 4 commits into from
Oct 26, 2023
Merged
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
3 changes: 1 addition & 2 deletions libmamba/include/mamba/core/channel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ namespace mamba

const Channel& get_channel_alias() const;
const channel_map& get_custom_channels() const;
const multichannel_map& get_custom_multichannels() const;

private:

Expand All @@ -111,8 +112,6 @@ namespace mamba
Channel build_channel_alias();
void init_custom_channels();

const multichannel_map& get_custom_multichannels() const;

Channel make_simple_channel(
const Channel& channel_alias,
const std::string& channel_url,
Expand Down
33 changes: 29 additions & 4 deletions libmamba/src/core/pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,15 @@ namespace mamba
}
std::string needle_subdir = util::rsplit(needle_channel, "/", 1)[1];

auto known_platforms = get_known_platforms();
if (std::find(known_platforms.begin(), known_platforms.end(), needle_subdir)
== known_platforms.end())
{
// Not a known subdir. This can happen for specs like pkgs/main.
// so any subdir is fine
return true;
}

std::string candidate_repo_subdir = util::rsplit(candidate_repo_url, "/", 1)[1];

if (candidate_repo_subdir == needle_subdir)
Expand Down Expand Up @@ -207,7 +216,20 @@ namespace mamba
ms.conda_build_form().c_str()
);

const Channel& c = channel_context.make_channel(ms.channel);
auto multi_channels = channel_context.get_custom_multichannels();
std::vector<const Channel*> channels;
auto multi_channels_it = multi_channels.find(ms.channel);
if (multi_channels_it != multi_channels.end())
{
for (auto& c : multi_channels_it->second)
{
channels.push_back(&channel_context.make_channel(c));
}
}
else
{
channels.push_back(&channel_context.make_channel(ms.channel));
}
solv::ObjQueue selected_pkgs = {};
pool.for_each_whatprovides(
match,
Expand All @@ -218,11 +240,14 @@ namespace mamba
auto repo = solv::ObjRepoView(*s.raw()->repo);
// TODO make_channel should disapear avoiding conflict here
auto const url = std::string(repo.url());
if (channel_match(channel_context, channel_context.make_channel(url), c))
for (auto& c : channels)
{
if (subdir_match(url, ms.spec))
if (channel_match(channel_context, channel_context.make_channel(url), *c))
{
selected_pkgs.push_back(s.id());
if (subdir_match(url, ms.spec))
{
selected_pkgs.push_back(s.id());
}
}
}
}
Expand Down
30 changes: 29 additions & 1 deletion libmamba/src/core/virtual_packages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,34 @@ namespace mamba
return res;
}

std::string get_archspec_x86_64()
{
#if (defined(__GNUC__) || defined(__clang__)) && __x86_64__
/* if (__builtin_cpu_supports ("x86-64-v4")) */
if (__builtin_cpu_supports("avx512f") && __builtin_cpu_supports("avx512bw")
&& __builtin_cpu_supports("avx512cd") && __builtin_cpu_supports("avx512dq")
&& __builtin_cpu_supports("avx512vl"))
{
return "x86_64-v4";
}
/* if (__builtin_cpu_supports ("x86-64-v3")) */
if (__builtin_cpu_supports("avx") && __builtin_cpu_supports("avx2")
&& __builtin_cpu_supports("bmi") && __builtin_cpu_supports("bmi2")
&& __builtin_cpu_supports("fma"))
{
return "x86_64-v3";
}
/* if (__builtin_cpu_supports ("x86-64-v2")) */
if (__builtin_cpu_supports("popcnt") && __builtin_cpu_supports("sse3")
&& __builtin_cpu_supports("ssse3") && __builtin_cpu_supports("sse4.1")
&& __builtin_cpu_supports("sse4.2"))
{
return "x86_64-v2";
}
#endif
return "x86_64";
}

std::vector<PackageInfo> dist_packages()
{
LOG_DEBUG << "Loading distribution virtual packages";
Expand Down Expand Up @@ -221,7 +249,7 @@ namespace mamba

if (arch == "64")
{
arch = "x86_64";
arch = get_archspec_x86_64();
}
else if (arch == "32")
{
Expand Down
2 changes: 1 addition & 1 deletion libmamba/tests/src/core/test_virtual_packages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ namespace mamba
}
#if __x86_64__ || defined(_WIN64)
CHECK_EQ(pkgs.back().name, "__archspec");
CHECK_EQ(pkgs.back().build_string, "x86_64");
CHECK_EQ(pkgs.back().build_string.find("x86_64"), 0);
#endif

// This is bad design, tests should not interfer
Expand Down
20 changes: 20 additions & 0 deletions micromamba/tests/test_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,26 @@ def test_spec_with_channel_and_subdir():
)


def test_spec_with_multichannel(tmp_home, tmp_root_prefix):
"https://github.com/mamba-org/mamba/pull/2927"
helpers.create("-n", "myenv", "defaults::zlib", "--dry-run")


def test_spec_with_slash_in_channel(tmp_home, tmp_root_prefix):
"https://github.com/mamba-org/mamba/pull/2926"
with pytest.raises(subprocess.CalledProcessError) as info:
helpers.create("-n", "env1", "pkgs/main/noarch::python", "--dry-run")

assert info.value.stderr.decode() == (
'critical libmamba The package "pkgs/main/noarch::python" is '
"not available for the specified platform\n"
)

os.environ["CONDA_SUBDIR"] = "linux-64"
helpers.create("-n", "env2", "pkgs/main/linux-64::python", "--dry-run")
helpers.create("-n", "env3", "pkgs/main::python", "--dry-run")


@pytest.mark.parametrize("shared_pkgs_dirs", [True], indirect=True)
def test_channel_nodefaults(tmp_home, tmp_root_prefix, tmp_path):
rc_file = tmp_path / "rc.yaml"
Expand Down