@@ -348,6 +348,37 @@ function Context!(ctx::Context; kwargs...)
348
348
end
349
349
end
350
350
351
+ # target === nothing : main dependencies
352
+ # target === "*" : main + all extras
353
+ # target === "name" : named target deps
354
+
355
+ function deps_names (project:: Dict , target:: Union{Nothing,String} = nothing ):: Vector{String}
356
+ deps = sort! (collect (keys (project[" deps" ])))
357
+ target == " *" && return ! haskey (project, " extras" ) ? deps :
358
+ sort! (union! (deps, collect (keys (project[" extras" ]))))
359
+ haskey (project, " targets" ) || return deps
360
+ targets = project[" targets" ]
361
+ haskey (targets, target) || return deps
362
+ return sort! (union! (deps, targets[target]))
363
+ end
364
+
365
+ function get_deps (project:: Dict , target:: Union{Nothing,String} = nothing )
366
+ names = deps_names (project, target)
367
+ deps = filter (((dep, _),) -> dep in names, project[" deps" ])
368
+ extras = get (project, " extras" , Dict {String,Any} ())
369
+ for name in names
370
+ haskey (deps, name) && continue
371
+ haskey (extras, name) ||
372
+ cmderror (" target `$target ` has unlisted dependency `$name `" )
373
+ deps[name] = extras[name]
374
+ end
375
+ return deps
376
+ end
377
+ get_deps (env:: EnvCache , target:: Union{Nothing,String} = nothing ) =
378
+ get_deps (env. project, target)
379
+ get_deps (ctx:: Context , target:: Union{Nothing,String} = nothing ) =
380
+ get_deps (ctx. env, target)
381
+
351
382
function project_compatibility (ctx:: Context , name:: String )
352
383
v = VersionSpec ()
353
384
project = ctx. env. project
0 commit comments