-
Notifications
You must be signed in to change notification settings - Fork 418
Introduce resolvo #3947
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
base: main
Are you sure you want to change the base?
Introduce resolvo #3947
Changes from all commits
ebe9e91
237ad2a
b8795f7
7bab460
d2a3160
4a0b12c
baca592
5d326dd
183e365
c28affb
de9d09b
0fc9676
7f05c6f
e97546d
6dbe87c
b5a7dcd
4ff86b7
5f577a1
d05f0d2
c7d32dc
6260b22
c78107e
3864c84
b1f764f
34f91a0
ade5030
3f84945
14a2010
4814795
83d85c5
fd80f65
623b3ff
44b563e
8afe9a4
92df455
2590c52
8350a72
05eb464
0926f05
d727e79
f0487f6
0976153
bb06b21
b50b59a
28fda54
7a7fdc2
413dd82
4bce239
cac9ad6
3e00e99
2748de1
71e83ac
0a2a79d
01f324f
a790564
61a4d1a
0c3136c
d9c2e01
107188f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| // Copyright (c) 2024, 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_SOLVER_DATABASE_HPP | ||
| #define MAMBA_SOLVER_DATABASE_HPP | ||
|
|
||
| #include <string> | ||
| #include <variant> | ||
| #include <vector> | ||
|
|
||
| #include "mamba/fs/filesystem.hpp" | ||
| #include "mamba/specs/channel.hpp" | ||
| #include "mamba/specs/match_spec.hpp" | ||
| #include "mamba/specs/package_info.hpp" | ||
|
|
||
| namespace mamba::solver | ||
| { | ||
| class Database | ||
| { | ||
| public: | ||
|
|
||
| virtual ~Database() = default; | ||
|
|
||
| virtual void add_repo_from_repodata_json( | ||
| const fs::u8path& filename, | ||
| const std::string& repo_url, | ||
| const std::string& channel_id, | ||
| bool verify_artifacts = false | ||
| ) = 0; | ||
|
|
||
| virtual void add_repo_from_packages( | ||
| const std::vector<specs::PackageInfo>& packages, | ||
| const std::string& repo_name, | ||
| bool pip_as_python_dependency = false | ||
| ) = 0; | ||
|
|
||
| virtual void set_installed_repo(const std::string& repo_name) = 0; | ||
|
|
||
| virtual bool has_package(const specs::MatchSpec& spec) = 0; | ||
| }; | ||
|
|
||
| namespace libsolv | ||
| { | ||
| class Database; | ||
| } | ||
|
|
||
| namespace resolvo | ||
| { | ||
| class Database; | ||
| } | ||
|
|
||
| using DatabaseVariant = std::variant<libsolv::Database, resolvo::Database>; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think a classical inheritance tree (or type erasure) would be more flexible and extensible on the long run than a variant.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, this is temporary for now, and this can later be changed so that the plan from #3387 is implemented. |
||
|
|
||
| // Remove or comment out the inline database_has_package function if DatabaseVariant is not | ||
| // visible or causes errors inline auto database_has_package(DatabaseVariant& database, const | ||
| // specs::MatchSpec& spec) -> bool; | ||
| } | ||
|
|
||
| #endif // MAMBA_SOLVER_DATABASE_HPP | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| #ifndef MAMBA_SOLVER_DATABASE_UTILS_HPP | ||
| #define MAMBA_SOLVER_DATABASE_UTILS_HPP | ||
|
|
||
| #include <stdexcept> | ||
|
|
||
| #include "mamba/solver/database.hpp" | ||
|
|
||
| namespace mamba::solver | ||
| { | ||
| inline bool database_has_package(DatabaseVariant& database, const specs::MatchSpec& spec) | ||
| { | ||
| if (auto* libsolv_db = std::get_if<libsolv::Database>(&database)) | ||
| { | ||
| return libsolv_db->has_package(spec); | ||
| } | ||
| else if (auto* resolvo_db = std::get_if<resolvo::Database>(&database)) | ||
| { | ||
| return resolvo_db->has_package(spec); | ||
| } | ||
| throw std::runtime_error("Invalid database variant"); | ||
| } | ||
| } | ||
|
|
||
| #endif // MAMBA_SOLVER_DATABASE_UTILS_HPP |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should remove this before merging.