nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 51 lines 2.1 kB view raw
1import Pkg.API: handle_package_input! 2import Pkg.Types: PRESERVE_NONE, UUID, VersionSpec, project_deps_resolve!, registry_resolve!, stdlib_resolve!, ensure_resolved 3import Pkg.Operations: _resolve, assert_can_add, update_package_add 4import TOML 5 6foreach(handle_package_input!, pkgs) 7 8# The handle_package_input! call above clears pkg.path, so we have to apply package overrides after 9println("Package overrides: ") 10println(overrides) 11for pkg in pkgs 12 if pkg.name in keys(overrides) 13 pkg.path = overrides[pkg.name] 14 15 # Try to read the UUID from $(pkg.path)/Project.toml. If successful, put the package into ctx.env.project.deps. 16 # This is necessary for the ensure_resolved call below to succeed, and will allow us to use an override even 17 # if it does not appear in the registry. 18 # See https://github.com/NixOS/nixpkgs/issues/279853 19 project_toml = joinpath(pkg.path, "Project.toml") 20 if isfile(project_toml) 21 toml_data = TOML.parsefile(project_toml) 22 if haskey(toml_data, "uuid") 23 ctx.env.project.deps[pkg.name] = UUID(toml_data["uuid"]) 24 end 25 end 26 end 27end 28 29project_deps_resolve!(ctx.env, pkgs) 30registry_resolve!(ctx.registries, pkgs) 31stdlib_resolve!(pkgs) 32ensure_resolved(ctx, ctx.env.manifest, pkgs, registry=true) 33 34assert_can_add(ctx, pkgs) 35 36for (i, pkg) in pairs(pkgs) 37 entry = Pkg.Types.manifest_info(ctx.env.manifest, pkg.uuid) 38 is_dep = any(uuid -> uuid == pkg.uuid, [uuid for (name, uuid) in ctx.env.project.deps]) 39 if VERSION >= VersionNumber("1.11") && VERSION < VersionNumber("1.12") 40 pkgs[i] = update_package_add(ctx, pkg, entry, nothing, nothing, is_dep) 41 else 42 pkgs[i] = update_package_add(ctx, pkg, entry, is_dep) 43 end 44end 45 46foreach(pkg -> ctx.env.project.deps[pkg.name] = pkg.uuid, pkgs) 47 48# Save the original pkgs for later. We might need to augment it with the weak dependencies 49orig_pkgs = deepcopy(pkgs) 50 51pkgs, deps_map = _resolve(ctx.io, ctx.env, ctx.registries, pkgs, PRESERVE_NONE, ctx.julia_version)