Skip to content

Commit

Permalink
No .solv files on Windows (slow)
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoinePrv committed Sep 19, 2023
1 parent e8be2d5 commit 3036111
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
19 changes: 7 additions & 12 deletions libmamba/src/core/repo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ extern "C" // Incomplete header
#include "mamba/core/prefix_data.hpp"
#include "mamba/core/repo.hpp"
#include "mamba/core/util.hpp"
#include "mamba/util/build.hpp"
#include "mamba/util/string.hpp"
#include "mamba/util/url_manip.hpp"
#include "solv-cpp/pool.hpp"
Expand Down Expand Up @@ -533,21 +534,15 @@ namespace mamba
bool is_solv = filename.extension() == ".solv";

fs::u8path solv_file = filename;
solv_file.replace_extension("solv");
fs::u8path json_file = filename;

if (is_solv)
{
json_file.replace_extension("json");
}
else
{
solv_file.replace_extension("solv");
}
json_file.replace_extension("json");

LOG_INFO << "Reading cache files '" << (filename.parent_path() / filename).string()
<< ".*' for repo index '" << name() << "'";

if (is_solv && (use_cache == LibsolvCache::yes))
// .solv files are slower to load than simdjson on Windows
if (!util::on_win && is_solv && (use_cache == LibsolvCache::yes))
{
const auto lock = LockFile(solv_file);
const bool read = read_solv(solv_file);
Expand All @@ -570,6 +565,7 @@ namespace mamba
else
{
libsolv_read_json(json_file);
set_solvables_url(repo, m_metadata.url);
}
}

Expand All @@ -579,11 +575,10 @@ namespace mamba
add_pip_as_python_dependency();
}

if (name() != "installed")
if (!util::on_win && (name() != "installed"))
{
write_solv(solv_file);
}
set_solvables_url(repo, m_metadata.url);
}

void MRepo::write_solv(fs::u8path filename)
Expand Down
19 changes: 13 additions & 6 deletions micromamba/tests/test_pkg_cache.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import platform
import shutil
import subprocess
from pathlib import Path
Expand Down Expand Up @@ -345,7 +346,8 @@ def test_first_writable_extracted_dir_corrupted(
# check repodata files
assert repodata_json(tmp_cache) == set()
assert repodata_json(tmp_cache_alt) != set()
assert same_repodata_json_solv(tmp_cache_alt)
if platform.system() != "Windows": # No .solv on Windows
assert same_repodata_json_solv(tmp_cache_alt)

# check tarballs
assert find_cache_archive(tmp_cache, xtensor_bld) is None
Expand Down Expand Up @@ -385,7 +387,8 @@ def test_extracted_tarball_only_in_non_writable_cache(

# check repodata files
assert repodata_json(tmp_cache) != set()
assert same_repodata_json_solv(tmp_cache)
if platform.system() != "Windows": # No .solv on Windows
assert same_repodata_json_solv(tmp_cache)
assert repodata_json(tmp_cache_alt) == set()

# check tarballs
Expand Down Expand Up @@ -424,7 +427,8 @@ def test_missing_extracted_dir_in_non_writable_cache(

# check repodata files
assert repodata_json(tmp_cache) != set()
assert same_repodata_json_solv(tmp_cache)
if platform.system() != "Windows": # No .solv on Windows
assert same_repodata_json_solv(tmp_cache)
assert repodata_json(tmp_cache_alt) == set()

# check tarballs
Expand Down Expand Up @@ -458,7 +462,8 @@ def test_corrupted_extracted_dir_in_non_writable_cache(

# check repodata files
assert repodata_json(tmp_cache) != set()
assert same_repodata_json_solv(tmp_cache)
if platform.system() != "Windows": # No .solv on Windows
assert same_repodata_json_solv(tmp_cache)
assert repodata_json(tmp_cache_alt) == set()

# check tarballs
Expand Down Expand Up @@ -505,9 +510,11 @@ def test_expired_but_valid_repodata_in_non_writable_cache(

# check repodata files
assert repodata_json(tmp_cache) != set()
assert same_repodata_json_solv(tmp_cache)
if platform.system() != "Windows": # No .solv on Windows
assert same_repodata_json_solv(tmp_cache)
assert repodata_json(tmp_cache_alt) != set()
assert same_repodata_json_solv(tmp_cache_alt)
if platform.system() != "Windows": # No .solv on Windows
assert same_repodata_json_solv(tmp_cache_alt)

# check tarballs
assert find_cache_archive(tmp_cache, xtensor_bld).exists()
Expand Down

0 comments on commit 3036111

Please sign in to comment.