This commit is contained in:
David Caro 2025-12-26 21:14:01 -05:00 committed by GitHub
commit b534cafc2d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 36 additions and 8 deletions

View file

@ -127,13 +127,25 @@ def install_environment(
#
# Because of this, we allow specifying "cli" dependencies by prefixing
# with 'cli:'.
cli_deps = {
dep for dep in additional_dependencies if dep.startswith('cli:')
}
lib_deps = set(additional_dependencies) - cli_deps
#
# We can pass arbitrary arguments to the `cargo install` invocation by
# adding '--' before the arguments.
cli_deps = []
lib_deps = []
cargo_params = []
for index, dep in enumerate(additional_dependencies):
if dep == '--':
cargo_params = list(additional_dependencies[index + 1:])
break
if dep.startswith('cli:'):
cli_deps.append(dep)
continue
lib_deps.append(dep)
cli_deps_set = set(cli_deps)
lib_deps_set = set(lib_deps)
packages_to_install: set[tuple[str, ...]] = {('--path', '.')}
for cli_dep in cli_deps:
for cli_dep in cli_deps_set:
cli_dep = cli_dep.removeprefix('cli:')
package, _, crate_version = cli_dep.partition(':')
if crate_version != '':
@ -150,11 +162,12 @@ def install_environment(
tmpdir = ctx.enter_context(tempfile.TemporaryDirectory())
ctx.enter_context(envcontext((('RUSTUP_HOME', tmpdir),)))
if len(lib_deps) > 0:
_add_dependencies(prefix, lib_deps)
if len(lib_deps_set) > 0:
_add_dependencies(prefix, lib_deps_set)
for args in packages_to_install:
cmd_output_b(
'cargo', 'install', '--bins', '--root', envdir, *args,
*cargo_params,
cwd=prefix.prefix_dir,
)