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

Updates for Julia 1.7-dev. #33

Merged
merged 1 commit into from
May 2, 2021
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
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "LocalRegistry"
uuid = "89398ba2-070a-4b16-a995-9893c55d93cf"
authors = ["Gunnar Farnebäck <[email protected]>"]
version = "0.3.2"
version = "0.3.3"

[deps]
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Expand All @@ -11,7 +11,7 @@ UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"

[compat]
RegistryTools = "1.4"
julia = "1.1"
julia = "~1.1, ~1.2, ~1.3, ~1.4, ~1.5, ~1.6, ~1.7"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Expand Down
30 changes: 25 additions & 5 deletions src/LocalRegistry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ function find_registry_path(registry::AbstractString)
return abspath(expanduser(registry))
end

all_registries = Pkg.Types.collect_registries()
all_registries = collect_registries()
matching_registries = filter(r -> r.name == registry, all_registries)
if isempty(matching_registries)
error("Registry $(registry) not found.")
Expand All @@ -350,11 +350,10 @@ function find_registry_path(registry::AbstractString)
end

function find_registry_path(::Nothing, pkg::Pkg.Types.Project)
all_registries = Pkg.Types.collect_registries()
all_registries = collect_registries()

matching_registries = filter(all_registries) do reg_spec
reg_data = Pkg.Types.read_registry(joinpath(reg_spec.path,
"Registry.toml"))
reg_data = Pkg.TOML.parsefile(joinpath(reg_spec.path, "Registry.toml"))
haskey(reg_data["packages"], string(pkg.uuid))
end

Expand All @@ -367,8 +366,29 @@ function find_registry_path(::Nothing, pkg::Pkg.Types.Project)
return first(matching_registries).path
end

# This replaces the use of `Pkg.Types.collect_registries` which was
# removed in Julia 1.7.
#
# TODO: Once Julia versions before 1.7 are no longer supported,
# consider switching over to use `Pkg.Registry.reachable_registries`
# where this is called.
function collect_registries()
registries = []
for depot in Pkg.depots()
isdir(depot) || continue
reg_dir = joinpath(depot, "registries")
isdir(reg_dir) || continue
for name in readdir(reg_dir)
file = joinpath(reg_dir, name, "Registry.toml")
isfile(file) || continue
push!(registries, (name = name, path = joinpath(reg_dir, name)))
end
end
return registries
end

function has_package(registry_path, pkg::Pkg.Types.Project)
registry = Pkg.Types.read_registry(joinpath(registry_path, "Registry.toml"))
registry = Pkg.TOML.parsefile(joinpath(registry_path, "Registry.toml"))
return haskey(registry["packages"], string(pkg.uuid))
end

Expand Down
3 changes: 3 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,9 @@ register(joinpath(packages_dir, "FirstTest"), registry_push_dir,
# including registries, of the running Julia process.

# Prepare by adding the registry used in previous tests.
# TODO: Needed in Julia 1.7.0-DEV.1046. Check if the `mkdir` can be
# removed for the final Julia 1.7.
mkdir(joinpath(depot_path, "registries"))
Pkg.Registry.add(RegistrySpec(path = registry_dir))

# Use Multibreak as Guinea pig. The sleep is a Travis workaround. See
Expand Down
8 changes: 8 additions & 0 deletions test/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ end
# no error.
function sanity_check_registry(path)
registry = TOML.parsefile(joinpath(path, "Registry.toml"))
if VERSION >= v"1.7-"
# TODO: Check if the `parse_packages` keyword is available
# when the final Julia 1.7 has been released and if so set it
# explicitly to true.
registry = Pkg.Registry.RegistryInstance(path) # , parse_packages = true)
return true
end

for (uuid, package) in registry["packages"]
package_path = joinpath(path, package["path"])
deps_file = joinpath(package_path, "Deps.toml")
Expand Down