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

Handle git+https pip urls #3764

Merged
merged 3 commits into from
Jan 23, 2025
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
14 changes: 14 additions & 0 deletions libmamba/src/specs/package_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,20 @@ namespace mamba::specs
}
}

// A git repository URL over https and used by `pip`
// git+https://<repository-url>@<commit|branch|tag>#egg=<package-name>
if (util::starts_with(str, "git+https"))
{
auto pkg = PackageInfo();
pkg.package_url = str;
const std::string pkg_name_marker = "#egg=";
if (const auto idx = str.rfind(pkg_name_marker); idx != std::string_view::npos)
{
pkg.name = str.substr(idx + pkg_name_marker.length());
}
return pkg;
}

return make_unexpected_parse(fmt::format(R"(Fail to parse PackageInfo URL "{}")", str));
}

Expand Down
9 changes: 9 additions & 0 deletions libmamba/tests/src/specs/test_package_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ namespace
static constexpr std::string_view url = "https://conda.anaconda.org/conda-forge/linux-64/pkg.conda";
REQUIRE_FALSE(PackageInfo::from_url(url).has_value());
}

SECTION("git+https://github.com/urllib3/urllib3.git@1.19.1#egg=urllib3")
{
static constexpr std::string_view url = "git+https://github.com/urllib3/urllib3.git@1.19.1#egg=urllib3";
auto pkg = PackageInfo::from_url(url).value();

REQUIRE(pkg.name == "urllib3");
REQUIRE(pkg.package_url == url);
}
}

TEST_CASE("PackageInfo serialization")
Expand Down
Loading
Loading