From b13bd2ddf6049865ddd8f7984bc9aa2790c14d21 Mon Sep 17 00:00:00 2001 From: Kristoffer Carlsson Date: Tue, 30 Jan 2024 11:46:43 +0100 Subject: [PATCH] support the "path" key in Project.toml, (#3756) code loading has support for this so Pkg should too --- src/Types.jl | 4 +++- src/project.jl | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Types.jl b/src/Types.jl index c3b1ce430e..036b5170e0 100644 --- a/src/Types.jl +++ b/src/Types.jl @@ -247,6 +247,7 @@ Base.@kwdef mutable struct Project uuid::Union{UUID, Nothing} = nothing version::Union{VersionTypes, Nothing} = nothing manifest::Union{String, Nothing} = nothing + path::Union{String, Nothing} = nothing # Sections deps::Dict{String,UUID} = Dict{String,UUID}() # deps that are also in weakdeps for backwards compat @@ -576,7 +577,8 @@ function read_package(path::String) pkgerror("expected a `uuid` entry in project file at `$(abspath(path))`") end name = project.name - if !isfile(joinpath(dirname(path), "src", "$name.jl")) + pkgpath = joinpath(dirname(path), something(project.path, "")) + if !isfile(joinpath(pkgpath, "src", "$name.jl")) pkgerror("expected the file `src/$name.jl` to exist for package `$name` at `$(dirname(path))`") end return project diff --git a/src/project.jl b/src/project.jl index 406de614c1..4e407ba705 100644 --- a/src/project.jl +++ b/src/project.jl @@ -122,6 +122,7 @@ function Project(raw::Dict; file=nothing) project.other = raw project.name = get(raw, "name", nothing)::Union{String, Nothing} project.manifest = get(raw, "manifest", nothing)::Union{String, Nothing} + project.path = get(raw, "path", nothing)::Union{String, Nothing} project.uuid = read_project_uuid(get(raw, "uuid", nothing)) project.version = read_project_version(get(raw, "version", nothing)) project.deps = read_project_deps(get(raw, "deps", nothing), "deps") @@ -179,6 +180,7 @@ function destructure(project::Project)::Dict entry!("uuid", project.uuid) entry!("version", project.version) entry!("manifest", project.manifest) + entry!("path", project.path) entry!("deps", merge(project.deps, project._deps_weak)) entry!("weakdeps", project.weakdeps) entry!("extras", project.extras)