-
Notifications
You must be signed in to change notification settings - Fork 440
Fix duplicated packages with categories from env lock file #4340
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?
Changes from all commits
e72536d
7164eb8
d6c76a8
abf34d6
5d4ab74
6e98a81
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 |
|---|---|---|
|
|
@@ -12,7 +12,6 @@ | |
| #include <stack> | ||
| #include <string> | ||
| #include <utility> | ||
| #include <vector> | ||
|
|
||
| #include <fmt/color.h> | ||
| #include <fmt/format.h> | ||
|
|
@@ -301,7 +300,7 @@ namespace mamba | |
| MTransaction::MTransaction( | ||
| const Context& ctx, | ||
| solver::libsolv::Database& database, | ||
| std::vector<specs::PackageInfo> packages, | ||
| std::unordered_set<specs::PackageInfo> packages, | ||
| MultiPackageCache& caches | ||
| ) | ||
| : MTransaction(ctx.command_params, caches) | ||
|
|
@@ -324,12 +323,11 @@ namespace mamba | |
| ); | ||
|
|
||
| m_solution.actions.reserve(packages.size()); | ||
| std::transform( | ||
| std::move_iterator(packages.begin()), | ||
| std::move_iterator(packages.end()), | ||
| std::back_insert_iterator(m_solution.actions), | ||
| [](specs::PackageInfo&& pkg) { return solver::Solution::Install{ std::move(pkg) }; } | ||
| ); | ||
| for (auto it = packages.begin(); it != packages.end();) | ||
|
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'm not sure I understand the change, what this loop is doing that's different from the original?
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
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 exactly. And it seems |
||
| { | ||
| auto node = packages.extract(it++); | ||
| m_solution.actions.emplace_back(solver::Solution::Install{ std::move(node.value()) }); | ||
| } | ||
|
|
||
| std::tie( | ||
| m_py_versions, | ||
|
|
@@ -1519,19 +1517,15 @@ namespace mamba | |
|
|
||
| // TODO: FIXME: inject channel info coming from the lockfile! | ||
|
|
||
| std::vector<specs::PackageInfo> conda_packages = {}; | ||
| std::vector<specs::PackageInfo> pip_packages = {}; | ||
| std::unordered_set<specs::PackageInfo> conda_package_set; | ||
|
Hind-M marked this conversation as resolved.
|
||
| std::unordered_set<specs::PackageInfo> pip_package_set; | ||
|
|
||
| for (const auto& category : categories) | ||
| { | ||
| std::vector<specs::PackageInfo> selected_packages = lockfile_data.get_packages_for( | ||
| { .category = category, .platform = ctx.platform, .manager = "conda" } | ||
| ); | ||
| std::copy( | ||
| selected_packages.begin(), | ||
| selected_packages.end(), | ||
| std::back_inserter(conda_packages) | ||
| ); | ||
| conda_package_set.insert(selected_packages.begin(), selected_packages.end()); | ||
|
|
||
| if (selected_packages.empty()) | ||
| { | ||
|
|
@@ -1550,21 +1544,17 @@ namespace mamba | |
| // specified we filter to the current platform. | ||
| .allow_no_platform = true } | ||
| ); | ||
| std::copy( | ||
| selected_packages.begin(), | ||
| selected_packages.end(), | ||
| std::back_inserter(pip_packages) | ||
| ); | ||
| pip_package_set.insert(selected_packages.begin(), selected_packages.end()); | ||
| } | ||
|
|
||
| // extract pip packages | ||
| if (!pip_packages.empty()) | ||
| if (!pip_package_set.empty()) | ||
| { | ||
| std::vector<std::string> pip_specs = {}; | ||
| pip_specs.reserve(pip_packages.size()); | ||
| pip_specs.reserve(pip_package_set.size()); | ||
| std::transform( | ||
| pip_packages.cbegin(), | ||
| pip_packages.cend(), | ||
| pip_package_set.cbegin(), | ||
| pip_package_set.cend(), | ||
| std::back_inserter(pip_specs), | ||
| [](const specs::PackageInfo& pkg) | ||
| { return fmt::format("{} @ {}#sha256={}", pkg.name, pkg.package_url, pkg.sha256); } | ||
|
|
@@ -1575,12 +1565,12 @@ namespace mamba | |
| } | ||
|
|
||
|
|
||
| for (const auto& package : pip_packages) | ||
| for (const auto& package : pip_package_set) | ||
| { | ||
| LOG_DEBUG << "pip package to install: " << package.name; | ||
| } | ||
|
|
||
| return MTransaction{ ctx, database, std::move(conda_packages), package_caches }; | ||
| return MTransaction{ ctx, database, std::move(conda_package_set), package_caches }; | ||
| } | ||
|
|
||
| } // namespace mamba | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| version: 1 | ||
| metadata: | ||
| content_hash: | ||
| linux-64: df674ed55f81a1c751a6c1777786882528055c0ccbbd093c6262e435ab7306ad | ||
| channels: | ||
| - url: conda-forge | ||
| used_env_vars: [] | ||
| platforms: | ||
| - linux-64 | ||
| sources: | ||
| - myenv.yml | ||
| package: | ||
| # conda: pkg_a is in both foo and bar → should be deduped | ||
| - name: pkg_a | ||
| version: "1.0" | ||
| manager: conda | ||
| platform: linux-64 | ||
| dependencies: {} | ||
| url: https://example.com/pkg-a-1.0-0.tar.bz2 | ||
| hash: | ||
| md5: a9f577daf3de00bca7c3c76c0ecbd1de | ||
| sha256: 1dd3fffd892081df9726d7eb7e0dea6198962ba775bd88842135a4ddb4deb3c9 | ||
| category: foo | ||
| optional: true | ||
| - name: pkg_a | ||
| version: "1.0" | ||
| manager: conda | ||
| platform: linux-64 | ||
| dependencies: {} | ||
| url: https://example.com/pkg-a-1.0-0.tar.bz2 | ||
| hash: | ||
| md5: a9f577daf3de00bca7c3c76c0ecbd1de | ||
| sha256: 1dd3fffd892081df9726d7eb7e0dea6198962ba775bd88842135a4ddb4deb3c9 | ||
| category: bar | ||
| optional: true | ||
| # conda: pkg_b is only in bar | ||
| - name: pkg_b | ||
| version: "2.0" | ||
| manager: conda | ||
| platform: linux-64 | ||
| dependencies: {} | ||
| url: https://example.com/pkg-b-2.0-0.tar.bz2 | ||
| hash: | ||
| md5: a9f577daf3de00bca7c3c76c0ecbd1df | ||
| sha256: 1dd3fffd892081df9726d7eb7e0dea6198962ba775bd88842135a4ddb4deb3c5 | ||
| category: bar | ||
| optional: true | ||
| # pip: pip_a is in both foo and bar → should be deduped | ||
| - name: pip_a | ||
| version: "1.0.0" | ||
| manager: pip | ||
| platform: linux-64 | ||
| dependencies: {} | ||
| url: https://example.com/pip_a-1.0.0-py3-none-any.whl | ||
| hash: | ||
| md5: a9f577daf3de00bca7c3c76c0ecbd2e3 | ||
| sha256: 1dd3fffd892081df9726d7eb7e0dea6198962ba775bd88842135a4ddb4deb7d5 | ||
| category: foo | ||
| optional: true | ||
| - name: pip_a | ||
| version: "1.0.0" | ||
| manager: pip | ||
| platform: linux-64 | ||
| dependencies: {} | ||
| url: https://example.com/pip_a-1.0.0-py3-none-any.whl | ||
| hash: | ||
| md5: a9f577daf3de00bca7c3c76c0ecbd2e3 | ||
| sha256: 1dd3fffd892081df9726d7eb7e0dea6198962ba775bd88842135a4ddb4deb7d5 | ||
| category: bar | ||
| optional: true | ||
| # pip: pip_b is only in bar | ||
| - name: pip_b | ||
| version: "2.0.0" | ||
| manager: pip | ||
| platform: linux-64 | ||
| dependencies: {} | ||
| url: https://example.com/pip_b-2.0.0-py3-none-any.whl | ||
| hash: | ||
| md5: a9f577daf3de00bca7c3c76c06cbd2e3 | ||
| sha256: 1dd3fffd892081df9726d7eb7e0dea6198962ba775b888842135a4ddb4deb7d5 | ||
| category: bar | ||
| optional: true | ||
| # pip: pip_c is only in bar | ||
| - name: pip_c | ||
| version: "3.0.0" | ||
| manager: pip | ||
| platform: linux-64 | ||
| dependencies: {} | ||
| url: https://example.com/pip_c-3.0.0-py3-none-any.whl | ||
| hash: | ||
| md5: a9f577daf3de00bca7c3c76c07cbd2e3 | ||
| sha256: 1dd3fffd892081df9726d7eb7e0dea6198962bf775b888842135a4ddb4deb7d5 | ||
| category: bar | ||
| optional: true |
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.
Did you consider using
flat_set? (reminder: it's like unordered_set except implemented as a vector).It seems it would be more appropriate as we have loops going through it.
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.
To follow up on the comment, I think it would also need implementing some missing parts like
operator<forPackageInfoasflat_setis sorted.