Skip to content

Commit

Permalink
Merge pull request #37 from KristofferC/kc/show_pkg_name_on_req_fail
Browse files Browse the repository at this point in the history
show pkg name on resolution failure
  • Loading branch information
KristofferC authored Nov 26, 2017
2 parents 1fc2c3f + 682cef5 commit 706a600
Show file tree
Hide file tree
Showing 14 changed files with 2,016 additions and 16 deletions.
9 changes: 5 additions & 4 deletions bin/loadmeta.jl
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#!/usr/bin/env julia

using Base: thispatch, thisminor, nextpatch, nextminor
using Base.Pkg.Reqs: Reqs, Requirement
using Base.Pkg.Types
using Base.LinAlg: checksquare
using Base.Random: UUID
using SHA

## Computing UUID5 values from (namespace, key) pairs ##
import Pkg3.Pkg2
import Pkg2.Reqs: Reqs, Requirement
import Pkg2.Types: VersionInterval

## Computing UUID5 values from (namespace, key) pairs ##
function uuid5(namespace::UUID, key::String)
data = [reinterpret(UInt8, [namespace.value]); Vector{UInt8}(key)]
u = reinterpret(UInt128, sha1(data)[1:16])[1]
Expand Down Expand Up @@ -153,6 +154,6 @@ end

## Load package data ##

const pkgs = load_packages(Pkg.dir("METADATA"))
const pkgs = load_packages(Pkg2.dir("METADATA"))
delete!(pkgs, "CardinalDicts") # package repo no longer exists
prune!(pkgs)
2 changes: 1 addition & 1 deletion bin/sha1map.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env julia

using TOML
using Pkg3.TOML
using Base: LibGit2

function sha1map(pkgs::Dict{String,Package})
Expand Down
19 changes: 13 additions & 6 deletions src/Operations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ module Operations

using Base.Random: UUID
using Base: LibGit2
using Base: Pkg
using Pkg3.TerminalMenus
using Pkg3.Types
import Pkg3: depots, BinaryProvider, USE_LIBGIT2_FOR_ALL_DOWNLOADS, NUM_CONCURRENT_DOWNLOADS
import Pkg3: Pkg2, depots, BinaryProvider, USE_LIBGIT2_FOR_ALL_DOWNLOADS, NUM_CONCURRENT_DOWNLOADS

const SlugInt = UInt32 # max p = 4
const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
Expand Down Expand Up @@ -153,18 +152,26 @@ function resolve_versions!(env::EnvCache, pkgs::Vector{PackageSpec})::Dict{UUID,
info("Resolving package versions")
# anything not mentioned is fixed
uuids = UUID[pkg.uuid for pkg in pkgs]
uuid_to_name = Dict{String, String}()
for (name::String, uuid::UUID) in env.project["deps"]
uuid_to_name[string(uuid)] = name
uuid in uuids && continue
info = manifest_info(env, uuid)
haskey(info, "version") || continue
ver = VersionNumber(info["version"])
push!(pkgs, PackageSpec(name, uuid, ver))
end
# construct data structures for resolver and call it
reqs = Dict{String,Pkg.Types.VersionSet}(string(pkg.uuid) => pkg.version for pkg in pkgs)
deps = convert(Dict{String,Dict{VersionNumber,Pkg.Types.Available}}, deps_graph(env, pkgs))
deps = Pkg.Query.prune_dependencies(reqs, deps)
vers = convert(Dict{UUID,VersionNumber}, Pkg.Resolve.resolve(reqs, deps))
reqs = Dict{String,Pkg2.Types.VersionSet}(string(pkg.uuid) => pkg.version for pkg in pkgs)
deps = convert(Dict{String,Dict{VersionNumber,Pkg2.Types.Available}}, deps_graph(env, pkgs))
for dep_uuid in keys(deps)
info = manifest_info(env, UUID(dep_uuid))
if info != nothing
uuid_to_name[info["uuid"]] = info["name"]
end
end
deps = Pkg2.Query.prune_dependencies(reqs, deps, uuid_to_name)
vers = convert(Dict{UUID,VersionNumber}, Pkg2.Resolve.resolve(reqs, deps, uuid_to_name))
find_registered!(env, collect(keys(vers)))
# update vector of package versions
for pkg in pkgs
Expand Down
47 changes: 47 additions & 0 deletions src/Pkg2/Pkg2.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
module Pkg2

struct PkgError <: Exception
msg::AbstractString
ex::Nullable{Exception}
end
PkgError(msg::AbstractString) = PkgError(msg, Nullable{Exception}())
function Base.showerror(io::IO, pkgerr::PkgError)
print(io, pkgerr.msg)
if !isnull(pkgerr.ex)
pkgex = get(pkgerr.ex)
if isa(pkgex, CompositeException)
for cex in pkgex
print(io, "\n=> ")
showerror(io, cex)
end
else
print(io, "\n")
showerror(io, pkgex)
end
end
end

# DIR
const DIR_NAME = ".julia"
_pkgroot() = abspath(get(ENV,"JULIA_PKGDIR",joinpath(homedir(),DIR_NAME)))
isversioned(p::AbstractString) = ((x,y) = (VERSION.major, VERSION.minor); basename(p) == "v$x.$y")

function dir()
b = _pkgroot()
x, y = VERSION.major, VERSION.minor
d = joinpath(b,"v$x.$y")
if isdir(d) || !isdir(b) || !isdir(joinpath(b, "METADATA"))
return d
end
return b
end
dir(pkg::AbstractString...) = normpath(dir(),pkg...)

include("types.jl")
include("reqs.jl")
include("query.jl")
# include("read.jl")
include("resolve.jl")


end
Loading

0 comments on commit 706a600

Please sign in to comment.