diff --git a/src/Operations.jl b/src/Operations.jl index 7c65782242..5e4b12c595 100644 --- a/src/Operations.jl +++ b/src/Operations.jl @@ -225,13 +225,14 @@ end # This has to be done after the packages have been downloaded # since we need access to the Project file to read the information # about extensions -function fixup_ext!(env::EnvCache) +function fixups_from_projectfile!(env::EnvCache) for pkg in values(env.manifest) v = joinpath(source_path(env.manifest_file, pkg), "Project.toml") if isfile(v) p = Types.read_project(v) pkg.weakdeps = p.weakdeps pkg.exts = p.exts + pkg.entryfile = p.entryfile for (name, _) in p.weakdeps if !haskey(p.deps, name) delete!(pkg.deps, name) @@ -1506,7 +1507,7 @@ function add(ctx::Context, pkgs::Vector{PackageSpec}, new_git=Set{UUID}(); man_pkgs, deps_map = _resolve(ctx.io, ctx.env, ctx.registries, pkgs, preserve, ctx.julia_version) update_manifest!(ctx.env, man_pkgs, deps_map, ctx.julia_version) new_apply = download_source(ctx) - fixup_ext!(ctx.env) + fixups_from_projectfile!(ctx.env) # After downloading resolutionary packages, search for (Julia)Artifacts.toml files # and ensure they are all downloaded and unpacked as well: @@ -1550,7 +1551,7 @@ function develop(ctx::Context, pkgs::Vector{PackageSpec}, new_git::Set{UUID}; pkgs, deps_map = _resolve(ctx.io, ctx.env, ctx.registries, pkgs, preserve, ctx.julia_version) update_manifest!(ctx.env, pkgs, deps_map, ctx.julia_version) new_apply = download_source(ctx) - fixup_ext!(ctx.env) + fixups_from_projectfile!(ctx.env) download_artifacts(ctx.env; platform=platform, julia_version=ctx.julia_version, io=ctx.io) write_env(ctx.env) # write env before building show_update(ctx.env, ctx.registries; io=ctx.io) @@ -1691,7 +1692,7 @@ function up(ctx::Context, pkgs::Vector{PackageSpec}, level::UpgradeLevel; end update_manifest!(ctx.env, pkgs, deps_map, ctx.julia_version) new_apply = download_source(ctx) - fixup_ext!(ctx.env) + fixups_from_projectfile!(ctx.env) download_artifacts(ctx.env, julia_version=ctx.julia_version, io=ctx.io) write_env(ctx.env; skip_writing_project) # write env before building show_update(ctx.env, ctx.registries; io=ctx.io, hidden_upgrades_info = true) @@ -1737,7 +1738,7 @@ function pin(ctx::Context, pkgs::Vector{PackageSpec}) update_manifest!(ctx.env, pkgs, deps_map, ctx.julia_version) new = download_source(ctx) - fixup_ext!(ctx.env) + fixups_from_projectfile!(ctx.env) download_artifacts(ctx.env; julia_version=ctx.julia_version, io=ctx.io) write_env(ctx.env) # write env before building show_update(ctx.env, ctx.registries; io=ctx.io) @@ -1785,7 +1786,7 @@ function free(ctx::Context, pkgs::Vector{PackageSpec}; err_if_free=true) update_manifest!(ctx.env, pkgs, deps_map, ctx.julia_version) new = download_source(ctx) - fixup_ext!(ctx.env) + fixups_from_projectfile!(ctx.env) download_artifacts(ctx.env, io=ctx.io) write_env(ctx.env) # write env before building show_update(ctx.env, ctx.registries; io=ctx.io) diff --git a/src/Types.jl b/src/Types.jl index d319edd0d5..6fac4b8465 100644 --- a/src/Types.jl +++ b/src/Types.jl @@ -234,7 +234,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 + entryfile::Union{String, Nothing} = nothing # Sections deps::Dict{String,UUID} = Dict{String,UUID}() # deps that are also in weakdeps for backwards compat @@ -258,6 +258,7 @@ Base.@kwdef mutable struct PackageEntry name::Union{String,Nothing} = nothing version::Union{VersionNumber,Nothing} = nothing path::Union{String,Nothing} = nothing + entryfile::Union{String,Nothing} = nothing pinned::Bool = false repo::GitRepo = GitRepo() tree_hash::Union{Nothing,SHA1} = nothing @@ -270,6 +271,7 @@ end Base.:(==)(t1::PackageEntry, t2::PackageEntry) = t1.name == t2.name && t1.version == t2.version && t1.path == t2.path && + t1.entryfile == t2.entryfile && t1.pinned == t2.pinned && t1.repo == t2.repo && t1.tree_hash == t2.tree_hash && @@ -278,7 +280,7 @@ Base.:(==)(t1::PackageEntry, t2::PackageEntry) = t1.name == t2.name && t1.exts == t2.exts && t1.uuid == t2.uuid # omits `other` -Base.hash(x::PackageEntry, h::UInt) = foldr(hash, [x.name, x.version, x.path, x.pinned, x.repo, x.tree_hash, x.deps, x.weakdeps, x.exts, x.uuid], init=h) # omits `other` +Base.hash(x::PackageEntry, h::UInt) = foldr(hash, [x.name, x.version, x.path, x.entryfile, x.pinned, x.repo, x.tree_hash, x.deps, x.weakdeps, x.exts, x.uuid], init=h) # omits `other` Base.@kwdef mutable struct Manifest julia_version::Union{Nothing,VersionNumber} = nothing # only set to VERSION when resolving @@ -629,9 +631,10 @@ function read_package(path::String) pkgerror("expected a `uuid` entry in project file at `$(abspath(path))`") end name = project.name - 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))`") + entry_point = something(project.entryfile, joinpath("src", "$(name).jl")) + pkgpath = joinpath(dirname(path), entry_point) + if !isfile(pkgpath) + pkgerror("expected the file `$pkgpath` to exist for package `$name` at `$(dirname(path))`") end return project end diff --git a/src/manifest.jl b/src/manifest.jl index 074bb73fbb..627f7e92fc 100644 --- a/src/manifest.jl +++ b/src/manifest.jl @@ -279,6 +279,7 @@ function destructure(manifest::Manifest)::Dict path = join(splitpath(path), "/") end entry!(new_entry, "path", path) + entry!(new_entry, "entryfile", entry.entryfile) repo_source = entry.repo.source if repo_source !== nothing && Sys.iswindows() && !isabspath(repo_source) && !isurl(repo_source) repo_source = join(splitpath(repo_source), "/") diff --git a/src/project.jl b/src/project.jl index 1139089a98..f7a7e83757 100644 --- a/src/project.jl +++ b/src/project.jl @@ -182,7 +182,10 @@ 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.entryfile = get(raw, "path", nothing)::Union{String, Nothing} + if project.entryfile === nothing + project.entryfile = get(raw, "entryfile", nothing)::Union{String, Nothing} + end 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") @@ -243,7 +246,7 @@ function destructure(project::Project)::Dict entry!("version", project.version) entry!("workspace", project.workspace) entry!("manifest", project.manifest) - entry!("path", project.path) + entry!("entryfile", project.entryfile) entry!("deps", merge(project.deps, project._deps_weak)) entry!("weakdeps", project.weakdeps) entry!("sources", project.sources) diff --git a/test/new.jl b/test/new.jl index 6ab8e6a6d7..1561840b34 100644 --- a/test/new.jl +++ b/test/new.jl @@ -3198,4 +3198,20 @@ if :version in fieldnames(Base.PkgOrigin) end end +temp_pkg_dir() do project_path + @testset "test entryfile entries" begin + mktempdir() do dir + path = abspath(joinpath(dirname(pathof(Pkg)), "../test", "test_packages", "ProjectPath")) + cp(path, joinpath(dir, "ProjectPath")) + cd(joinpath(dir, "ProjectPath")) do + with_current_env() do + Pkg.resolve() + @test success(run(`$(Base.julia_cmd()) --startup-file=no --project -e 'using ProjectPath'`)) + @test success(run(`$(Base.julia_cmd()) --startup-file=no --project -e 'using ProjectPathDep'`)) + end + end + end + end +end + end #module diff --git a/test/test_packages/ProjectPath/CustomPath.jl b/test/test_packages/ProjectPath/CustomPath.jl new file mode 100644 index 0000000000..ecc39cc525 --- /dev/null +++ b/test/test_packages/ProjectPath/CustomPath.jl @@ -0,0 +1,7 @@ +module ProjectPath + +using ProjectPathDep + +greet() = print("Hello World!") + +end # module ProjectPath diff --git a/test/test_packages/ProjectPath/Project.toml b/test/test_packages/ProjectPath/Project.toml new file mode 100644 index 0000000000..c7735e2deb --- /dev/null +++ b/test/test_packages/ProjectPath/Project.toml @@ -0,0 +1,10 @@ +name = "ProjectPath" +uuid = "32833bde-7fc1-4d28-8365-9d01e1bcbc1b" +entryfile = "CustomPath.jl" +version = "0.1.0" + +[deps] +ProjectPathDep = "f18633fc-8799-43ff-aa06-99ed830dc572" + +[sources] +ProjectPathDep = {path = "ProjectPathDep"} diff --git a/test/test_packages/ProjectPath/ProjectPathDep/CustomPath.jl b/test/test_packages/ProjectPath/ProjectPathDep/CustomPath.jl new file mode 100644 index 0000000000..adbe508f0c --- /dev/null +++ b/test/test_packages/ProjectPath/ProjectPathDep/CustomPath.jl @@ -0,0 +1,5 @@ +module ProjectPathDep + +greet() = print("Hello World!") + +end # module ProjectPathDep diff --git a/test/test_packages/ProjectPath/ProjectPathDep/Project.toml b/test/test_packages/ProjectPath/ProjectPathDep/Project.toml new file mode 100644 index 0000000000..c69e54e8c9 --- /dev/null +++ b/test/test_packages/ProjectPath/ProjectPathDep/Project.toml @@ -0,0 +1,4 @@ +name = "ProjectPathDep" +uuid = "f18633fc-8799-43ff-aa06-99ed830dc572" +version = "0.1.0" +entryfile = "CustomPath.jl"