From b0c22411762afeba965c70b3a6ad75c9b6cd8055 Mon Sep 17 00:00:00 2001 From: David Varela <00.varela.david@gmail.com> Date: Sat, 29 Dec 2018 15:32:00 -0800 Subject: [PATCH 01/16] `registered_name` should return `nothing` when UUID is not registered (cherry picked from commit 117b33567444aa171badd02d631792d8e7d599fe, PR #978) --- src/Operations.jl | 2 +- src/Types.jl | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Operations.jl b/src/Operations.jl index f27d86f013..74d7ec5a3e 100644 --- a/src/Operations.jl +++ b/src/Operations.jl @@ -380,7 +380,7 @@ function resolve_versions!( for (uuid, ver) in vers uuid in uuids && continue name = registered_name(ctx.env, uuid) - push!(pkgs, PackageSpec(name, uuid, ver)) + push!(pkgs, PackageSpec(;name=name, uuid=uuid, version=ver)) end return vers end diff --git a/src/Types.jl b/src/Types.jl index 4b699fe361..7ef141fb9b 100644 --- a/src/Types.jl +++ b/src/Types.jl @@ -1384,9 +1384,9 @@ function registered_uuid(env::EnvCache, name::String)::Union{Nothing,UUID} end # Determine current name for a given package UUID -function registered_name(env::EnvCache, uuid::UUID)::String +function registered_name(env::EnvCache, uuid::UUID)::Union{Nothing,String} names = registered_names(env, uuid) - length(names) == 0 && return "" + length(names) == 0 && return nothing length(names) == 1 && return names[1] values = registered_info(env, uuid, "name") name = nothing From b13b47327660e194a2c4372b110d2980f748d917 Mon Sep 17 00:00:00 2001 From: David Varela <00.varela.david@gmail.com> Date: Wed, 9 Jan 2019 12:02:41 -0800 Subject: [PATCH 02/16] fix rm: `project.extras` also contain dependency names (cherry picked from commit 27d452d73ed33ac368b3cbf6675a2eaca1ff39a9, PR #985) --- src/Operations.jl | 3 ++- test/pkg.jl | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Operations.jl b/src/Operations.jl index 74d7ec5a3e..e4e584a23a 100644 --- a/src/Operations.jl +++ b/src/Operations.jl @@ -1139,7 +1139,8 @@ function rm(ctx::Context, pkgs::Vector{PackageSpec}) @info "No changes" return end - deps_names = collect(keys(ctx.env.project.deps)) + deps_names = append!(collect(keys(ctx.env.project.deps)), + collect(keys(ctx.env.project.extras))) filter!(ctx.env.project.targets) do (target, deps) !isempty(filter!(in(deps_names), deps)) end diff --git a/test/pkg.jl b/test/pkg.jl index 3482191d01..38e3e0ca4d 100644 --- a/test/pkg.jl +++ b/test/pkg.jl @@ -612,6 +612,18 @@ end end end +#issue #876 +@testset "targets should survive add/rm" begin + temp_pkg_dir() do project_path; cd_tempdir() do tmpdir + cp(joinpath(@__DIR__, "project", "good", "pkg.toml"), "Project.toml") + targets = deepcopy(Pkg.Types.read_project("Project.toml").targets) + Pkg.activate(".") + Pkg.add("Example") + Pkg.rm("Example") + @test targets == Pkg.Types.read_project("Project.toml").targets + end end +end + include("repl.jl") include("api.jl") include("registry.jl") From 09647501a9d99bac509bce3f78ff7346c53be486 Mon Sep 17 00:00:00 2001 From: Florian Heiderich Date: Fri, 11 Jan 2019 13:08:58 +0100 Subject: [PATCH 03/16] add missing parenthesis in docstring (cherry picked from commit 8e7f6daac36a392260e4309394df24ee6ba3fbb6, PR #987) --- src/Pkg.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Pkg.jl b/src/Pkg.jl index e5a3fdcd22..277b143810 100644 --- a/src/Pkg.jl +++ b/src/Pkg.jl @@ -229,7 +229,7 @@ Pkg.develop("Example") Pkg.develop(PackageSpec(url="https://github.com/JuliaLang/Compat.jl")) # By path -Pkg.develop(PackageSpec(path="MyJuliaPackages/Package.jl") +Pkg.develop(PackageSpec(path="MyJuliaPackages/Package.jl")) ``` See also [`PackageSpec`](@ref) From a71e66a1f661fc72cdd2ebde523660e5c3bd78a5 Mon Sep 17 00:00:00 2001 From: Fredrik Ekre Date: Mon, 14 Jan 2019 14:46:27 +0100 Subject: [PATCH 04/16] doc: fix numbering of chapters, fix #944. (cherry picked from commit 73d2ebccc54c3359ebe9150c0b4edf525d9c9cb6, PR #991) --- docs/src/api.md | 2 +- docs/src/glossary.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/src/api.md b/docs/src/api.md index 9a9c39f559..386891ec6a 100644 --- a/docs/src/api.md +++ b/docs/src/api.md @@ -1,4 +1,4 @@ -# [**10.** API Reference](@id API-Reference) +# [**9.** API Reference](@id API-Reference) This section describes the function interface, or "API mode" for interacting with Pkg.jl. The function API is recommended diff --git a/docs/src/glossary.md b/docs/src/glossary.md index 157a743b46..92d8bbcafb 100644 --- a/docs/src/glossary.md +++ b/docs/src/glossary.md @@ -1,4 +1,4 @@ -# **9.** Glossary +# **8.** Glossary **Project:** a source tree with a standard layout, including a `src` directory for the main body of Julia code, a `test` directory for testing the project, From e0096d6055729d8db6add07a4dc7f451e2d046d2 Mon Sep 17 00:00:00 2001 From: Fredrik Ekre Date: Mon, 14 Jan 2019 16:04:13 +0100 Subject: [PATCH 05/16] doc: move misplaced versions kwarg from makedocs to deploydocs. (cherry picked from commit 8af8b983dc69ee917be630858543596cdcdec644, PR #992) --- docs/make.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/make.jl b/docs/make.jl index b80466b96f..72617b3a82 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -18,10 +18,10 @@ makedocs( "glossary.md", "api.md" ], - versions = ["v#.#", "dev" => "dev"], assets = ["assets/custom.css"], ) deploydocs( repo = "github.com/JuliaLang/Pkg.jl", + versions = ["v#.#", "dev" => "dev"], ) From ffd674365cd1e7ff399cb4f1857e682859734833 Mon Sep 17 00:00:00 2001 From: Fredrik Ekre Date: Thu, 17 Jan 2019 09:06:39 +0100 Subject: [PATCH 06/16] doc: include docstrings for Pkg REPL commands in the manual. (cherry picked from commit 1524988b262e8893609b6771fe5a11a9f350dd78, PR #998) --- .gitignore | 1 + docs/generate.jl | 49 ++++++++++++++++++++++++++++++++++++++++++++++++ docs/make.jl | 3 +++ docs/src/api.md | 2 +- 4 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 docs/generate.jl diff --git a/.gitignore b/.gitignore index 723069de6c..56eead5f18 100644 --- a/.gitignore +++ b/.gitignore @@ -5,5 +5,6 @@ docs/build /Manifest.toml /docs/Manifest.toml +/docs/src/repl.md .DS_Store /test/registries/* diff --git a/docs/generate.jl b/docs/generate.jl new file mode 100644 index 0000000000..bad46076f8 --- /dev/null +++ b/docs/generate.jl @@ -0,0 +1,49 @@ +# This file is a part of Julia. License is MIT: https://julialang.org/license + +## generate repl-docs ## + +function generate(io, command) + println(io, """ + ```@raw html +
+
+ + $(command) + + — + REPL command + . +
+ ``` + ```@eval + using Pkg + Pkg.REPLMode.CommandSpec("$(command)").help + ``` + ```@raw html +
+ ``` + """) +end +function generate() + io = IOBuffer() + println(io, """ + # [**9.** REPL Mode Reference](@id REPL-Mode-Reference) + + This section describes available commands in the Pkg REPL. + The REPL mode is mostly meant for interactive use, + and for non-interactive use it is recommended to use the + "API mode", see [API Reference](@ref API-Reference). + """) + # list commands + println(io, "## `package` commands") + foreach(command -> generate(io, command), ["add", "build", "develop", "free", "generate", "pin", "remove", "test", "update"]) + println(io, "## `registry` commands") + foreach(command -> generate(io, command), ["registry-add", "registry-remove", "registry-status", "registry-update"]) + println(io, "## Other commands") + foreach(command -> generate(io, command), ["activate", "gc", "help", "instantiate", "precompile", "resolve", "status"]) + # write to file + write(joinpath(@__DIR__, "src", "repl.md"), seekstart(io)) + return +end + +generate() diff --git a/docs/make.jl b/docs/make.jl index 72617b3a82..26f34dcb48 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -3,6 +3,8 @@ using Documenter using Pkg +include("generate.jl") + makedocs( modules = [Pkg], sitename = "Pkg.jl", @@ -16,6 +18,7 @@ makedocs( "registries.md", # "faq.md", "glossary.md", + "repl.md", "api.md" ], assets = ["assets/custom.css"], diff --git a/docs/src/api.md b/docs/src/api.md index 386891ec6a..9a9c39f559 100644 --- a/docs/src/api.md +++ b/docs/src/api.md @@ -1,4 +1,4 @@ -# [**9.** API Reference](@id API-Reference) +# [**10.** API Reference](@id API-Reference) This section describes the function interface, or "API mode" for interacting with Pkg.jl. The function API is recommended From f2220fbd561463fd82fa8b09aeb2fa04ee44b3da Mon Sep 17 00:00:00 2001 From: Fredrik Ekre Date: Thu, 17 Jan 2019 16:36:53 +0100 Subject: [PATCH 07/16] doc: "registry-add" to "registry add" in documentation, see issue #988. (cherry picked from commit d47994572044e55ca8971d26b7b108a30a718517, PR #999) --- docs/generate.jl | 2 +- src/REPLMode.jl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/generate.jl b/docs/generate.jl index bad46076f8..c34a8f3968 100644 --- a/docs/generate.jl +++ b/docs/generate.jl @@ -8,7 +8,7 @@ function generate(io, command)
- $(command) + $(replace(command, "-" => " ")) REPL command diff --git a/src/REPLMode.jl b/src/REPLMode.jl index 59f0a0ab0e..7dd7e2a7d4 100644 --- a/src/REPLMode.jl +++ b/src/REPLMode.jl @@ -1467,7 +1467,7 @@ Multiple commands can be given on the same line by interleaving a `;` between th for command in canonical_names() spec = CommandSpec(command) - push!(help.content, Markdown.parse("`$command`: $(spec.description)")) + push!(help.content, Markdown.parse("`$(replace(command, "-" => " "))`: $(spec.description)")) end end #module From bcb2787fec1b97c32b8190fad96b4807dc48b67c Mon Sep 17 00:00:00 2001 From: Curtis Vogt Date: Tue, 22 Jan 2019 08:43:29 -0600 Subject: [PATCH 08/16] Escape non-code dateformat characters (cherry picked from commit b17f1200fa44fa5e18aa3347048bcf6c2fdfd12a, PR #1004) --- ext/TOML/src/print.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/TOML/src/print.jl b/ext/TOML/src/print.jl index a5438f8bca..49e8bf29e2 100644 --- a/ext/TOML/src/print.jl +++ b/ext/TOML/src/print.jl @@ -35,7 +35,7 @@ end printvalue(io::IO, value::AbstractDict; sorted=false) = _print(io, value, sorted=sorted) printvalue(io::IO, value::DateTime; sorted=false) = - Base.print(io, Dates.format(value, "YYYY-mm-ddTHH:MM:SS.sssZ")) + Base.print(io, Dates.format(value, dateformat"YYYY-mm-dd\THH:MM:SS.sss\Z")) printvalue(io::IO, value::Bool; sorted=false) = Base.print(io, value ? "true" : "false") printvalue(io::IO, value; sorted=false) = From f7b6eb66c1322d1fd8c7a0cd1964dc37a2fd2b96 Mon Sep 17 00:00:00 2001 From: Nicholas Bauer Date: Wed, 30 Jan 2019 11:53:46 +0100 Subject: [PATCH 09/16] Fix display bug of PackageSpec without a name. (cherry picked from commit a1bd8cf550ba043a1f67cb0375c9d77557690731, PR #1006) --- src/Types.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Types.jl b/src/Types.jl index 7ef141fb9b..3d4f0b0192 100644 --- a/src/Types.jl +++ b/src/Types.jl @@ -160,7 +160,7 @@ has_uuid(pkg::PackageSpec) = pkg.uuid !== nothing function Base.show(io::IO, pkg::PackageSpec) vstr = repr(pkg.version) - f = ["name" => pkg.name, "uuid" => has_uuid(pkg) ? pkg.uuid : "", "v" => (vstr == "VersionSpec(\"*\")" ? "" : vstr)] + f = ["name" => has_name(pkg) ? pkg.name : "", "uuid" => has_uuid(pkg) ? pkg.uuid : "", "v" => (vstr == "VersionSpec(\"*\")" ? "" : vstr)] if pkg.repo !== nothing if pkg.repo.url !== nothing push!(f, "url/path" => string("\"", pkg.repo.url, "\"")) From 8dcc0d0e9014b677ed4580779fbc89e43f03c383 Mon Sep 17 00:00:00 2001 From: "Tamas K. Papp" Date: Thu, 24 Jan 2019 18:48:42 +0100 Subject: [PATCH 10/16] trivial docs correction (cherry picked from commit e520b77ba5925e5942bea5d7d21505d6ce38fb38, PR #1014) --- docs/src/creating-packages.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/creating-packages.md b/docs/src/creating-packages.md index b7a646fc0d..150deaabca 100644 --- a/docs/src/creating-packages.md +++ b/docs/src/creating-packages.md @@ -1,6 +1,6 @@ # **5.** Creating Packages -A package is a project with a `name`, `uuid` and `version` entry in the `Project.toml` file `src/PackageName.jl` file that defines the module `PackageName`. +A package is a project with a `name`, `uuid` and `version` entry in the `Project.toml` file, and a `src/PackageName.jl` file that defines the module `PackageName`. This file is executed when the package is loaded. ### Generating files for a package From 4a22dfb4faef8b66ab70fe5fe1f769beb980732a Mon Sep 17 00:00:00 2001 From: Fredrik Ekre Date: Fri, 25 Jan 2019 16:27:09 +0100 Subject: [PATCH 11/16] Don't throw for missing Versions.toml in the registry, instead consider that the same as no versions, i.e. an empty existing file. (cherry picked from commit 5e05aaf447535486028ba4e1e1bf44a8811174d8, PR #1016) --- src/Operations.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Operations.jl b/src/Operations.jl index e4e584a23a..0358c2e459 100644 --- a/src/Operations.jl +++ b/src/Operations.jl @@ -24,7 +24,7 @@ function find_installed(name::String, uuid::UUID, sha1::SHA1) end function load_versions(path::String; include_yanked = false) - toml = parse_toml(path, "Versions.toml") + toml = parse_toml(path, "Versions.toml"; fakeit=true) d = Dict{VersionNumber, SHA1}( VersionNumber(ver) => SHA1(info["git-tree-sha1"]) for (ver, info) in toml if !get(info, "yanked", false) || include_yanked) From 1604b3c2f55c369bbc9d73bfc8354fe0a3a134bf Mon Sep 17 00:00:00 2001 From: David Varela <00.varela.david@gmail.com> Date: Sat, 26 Jan 2019 21:59:51 -0800 Subject: [PATCH 12/16] Provide more intuitive help interface (cherry picked from commit 7ea26df17eeec705a2bc518ca79337c2197fd49e, PR #1018) --- src/REPLMode.jl | 52 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/src/REPLMode.jl b/src/REPLMode.jl index 7dd7e2a7d4..e274a1b35e 100644 --- a/src/REPLMode.jl +++ b/src/REPLMode.jl @@ -246,7 +246,7 @@ end is_opt(word::AbstractString) = first(word) == '-' -function core_parse(words) +function core_parse(words; only_cmd=false) # prelude statement = Statement() word = nothing @@ -280,6 +280,8 @@ function core_parse(words) end statement.spec = command + only_cmd && return statement, word # hack to hook in `help` command + next_word!() || return statement, word while is_opt(word) @@ -578,6 +580,14 @@ function CommandSpec(command_name::String)::Union{Nothing,CommandSpec} return get(super, m.captures[2], nothing) end +function parse_command(words::Vector{String}) + statement, word = core_parse(words; only_cmd=true) + if statement.super === nothing && statement.spec === nothing + pkgerror("invalid input: `$word` is not a command") + end + return statement.spec === nothing ? statement.super : statement.spec +end + function do_help!(command::PkgCommand, repl::REPL.AbstractREPL) disp = REPL.REPLDisplay(repl) if isempty(command.arguments) @@ -585,17 +595,20 @@ function do_help!(command::PkgCommand, repl::REPL.AbstractREPL) return end help_md = md"" - for arg in command.arguments - spec = CommandSpec(arg) - if spec === nothing - pkgerror("'$arg' does not name a command") + + cmd = parse_command(command.arguments) + if cmd isa String + # gather all helps for super spec `cmd` + all_specs = sort!(unique(values(super_specs[cmd])); + by=(spec->spec.canonical_name)) + for spec in all_specs + isempty(help_md.content) || push!(help_md.content, md"---") + push!(help_md.content, spec.help) end - spec.help === nothing && - pkgerror("Sorry, I don't have any help for the `$arg` command.") - isempty(help_md.content) || - push!(help_md.content, md"---") - push!(help_md.content, spec.help) + elseif cmd isa CommandSpec + push!(help_md.content, cmd.help) end + !isempty(command.arguments) && @warn "More than one command specified, only rendering help for first" Base.display(disp, help_md) end @@ -791,6 +804,14 @@ function canonical_names() return sort!(names) end +function complete_help(options, partial) + names = String[] + for cmds in values(super_specs) + append!(names, [spec.canonical_name for spec in values(cmds)]) + end + return sort!(unique!(append!(names, collect(keys(super_specs))))) +end + function complete_installed_packages(options, partial) env = try EnvCache() catch err @@ -1051,19 +1072,18 @@ julia is started with `--startup-file=yes`. :name => "help", :short_name => "?", :arg_count => 0 => Inf, - :completions => ((opt, partial) -> canonical_names()), + :completions => complete_help, :description => "show this message", :help => md""" help -Display this message. - - help cmd ... +List available commands along with short descriptions. -Display usage information for commands listed. + help cmd -Available commands: `help`, `status`, `add`, `rm`, `up`, `preview`, `gc`, `test`, `build`, `free`, `pin`, `develop`. +If `cmd` is a partial command, display help for all subcommands. +If `cmd` is a full command, display help for `cmd`. """, ],[ :kind => CMD_INSTANTIATE, :name => "instantiate", From ef736186f8f2a10544536f48f1ca593c1657f35d Mon Sep 17 00:00:00 2001 From: Nicholas Bauer Date: Wed, 30 Jan 2019 00:36:05 +0100 Subject: [PATCH 13/16] Better error message for Pkg.add(url) and Pkg.add(path). (cherry picked from commit 3ac39e8872e48d9d2ff7bae790e50a91e93c7727, PR #1021) --- src/API.jl | 13 +++++++++---- src/Pkg.jl | 4 ++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/API.jl b/src/API.jl index e51886260e..c9f65451a4 100644 --- a/src/API.jl +++ b/src/API.jl @@ -18,16 +18,21 @@ preview_info() = printstyled("───── Preview mode ─────\n"; c include("generate.jl") -function check_package_name(x::AbstractString) +function check_package_name(x::AbstractString, mode=nothing) if !(occursin(Pkg.REPLMode.name_re, x)) - pkgerror("$x is not a valid packagename") + message = "$x is not a valid packagename." + if mode !== nothing && any(occursin.(['\\','/'], x)) # maybe a url or a path + message *= "\nThe argument appears to be a URL or path, perhaps you meant " * + "`Pkg.$mode(PackageSpec(url=\"...\"))` or `Pkg.$mode(PackageSpec(path=\"...\"))`." + end + pkgerror(message) end return PackageSpec(x) end add_or_develop(pkg::Union{AbstractString, PackageSpec}; kwargs...) = add_or_develop([pkg]; kwargs...) -add_or_develop(pkgs::Vector{<:AbstractString}; kwargs...) = - add_or_develop([check_package_name(pkg) for pkg in pkgs]; kwargs...) +add_or_develop(pkgs::Vector{<:AbstractString}; mode::Symbol, kwargs...) = + add_or_develop([check_package_name(pkg, mode) for pkg in pkgs]; mode = mode, kwargs...) add_or_develop(pkgs::Vector{PackageSpec}; kwargs...) = add_or_develop(Context(), pkgs; kwargs...) function add_or_develop(ctx::Context, pkgs::Vector{PackageSpec}; mode::Symbol, shared::Bool=true, kwargs...) diff --git a/src/Pkg.jl b/src/Pkg.jl index 277b143810..0663c67556 100644 --- a/src/Pkg.jl +++ b/src/Pkg.jl @@ -88,8 +88,8 @@ a package, also inside that package. ```julia Pkg.add("Example") # Add a package from registry Pkg.add(PackageSpec(name="Example", version="0.3")) # Specify version -Pkg.add(PackageSpec(url="https://github.com/JuliaLang/Example.jl", rev="master")) # From url -Pkg.add(PackageSpec(url="/remote/mycompany/juliapackages/OurPackage"))` # From path (has to be a gitrepo) +Pkg.add(PackageSpec(url="https://github.com/JuliaLang/Example.jl", rev="master")) # From url to remote gitrepo +Pkg.add(PackageSpec(url="/remote/mycompany/juliapackages/OurPackage"))` # From path to local gitrepo ``` See also [`PackageSpec`](@ref). From 12858498487b3e8fdc4662435e81463b815d5e9b Mon Sep 17 00:00:00 2001 From: David Varela <00.varela.david@gmail.com> Date: Sun, 3 Feb 2019 11:17:59 -0800 Subject: [PATCH 14/16] Simplify `destructure` (cherry picked from commit 5efe5feaca599f54308f317c2f016bbb886fad49, PR #1036) --- src/Types.jl | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/src/Types.jl b/src/Types.jl index 3d4f0b0192..dea5de0389 100644 --- a/src/Types.jl +++ b/src/Types.jl @@ -1450,27 +1450,21 @@ function project_key_order(key::String) return 8 end -string(x::Vector{String}) = x - function destructure(project::Project)::Dict - raw = project.other - function entry!(key::String, src::Dict) - if isempty(src) - delete!(raw, key) - else - raw[key] = Dict(string(name) => string(uuid) for (name,uuid) in src) - end - end - entry!(key::String, src) = src === nothing ? delete!(raw, key) : (raw[key] = string(src)) + raw = deepcopy(project.other) + + should_delete(x::Dict) = isempty(x) + should_delete(x) = x === nothing + entry!(key::String, src) = should_delete(src) ? delete!(raw, key) : (raw[key] = src) - entry!("name", project.name) - entry!("uuid", project.uuid) - entry!("version", project.version) + entry!("name", project.name) + entry!("uuid", project.uuid) + entry!("version", project.version) entry!("manifest", project.manifest) - entry!("deps", project.deps) - entry!("extras", project.extras) - entry!("compat", project.compat) - entry!("targets", project.targets) + entry!("deps", project.deps) + entry!("extras", project.extras) + entry!("compat", project.compat) + entry!("targets", project.targets) return raw end From 6134e57d149de00c4701f9dab259be533ee4a871 Mon Sep 17 00:00:00 2001 From: Kristoffer Carlsson Date: Wed, 13 Feb 2019 15:27:36 +0100 Subject: [PATCH 15/16] fix "locking" dependencies when building / testing current project (cherry picked from commit b48c53fb81244d0d3297614e94eea6914a4ca4f9, PR #1058) --- src/Operations.jl | 6 +- test/pkg.jl | 9 ++ .../BuildProjectFixedDeps/.gitignore | 2 + .../BuildProjectFixedDeps/Manifest.toml | 92 +++++++++++++++++++ .../BuildProjectFixedDeps/Project.toml | 7 ++ .../BuildProjectFixedDeps/deps/build.jl | 5 + .../src/BuildProjectFixedDeps.jl | 5 + 7 files changed, 123 insertions(+), 3 deletions(-) create mode 100644 test/test_packages/BuildProjectFixedDeps/.gitignore create mode 100644 test/test_packages/BuildProjectFixedDeps/Manifest.toml create mode 100644 test/test_packages/BuildProjectFixedDeps/Project.toml create mode 100644 test/test_packages/BuildProjectFixedDeps/deps/build.jl create mode 100644 test/test_packages/BuildProjectFixedDeps/src/BuildProjectFixedDeps.jl diff --git a/src/Operations.jl b/src/Operations.jl index 0358c2e459..24a39ccbbb 100644 --- a/src/Operations.jl +++ b/src/Operations.jl @@ -835,10 +835,10 @@ function with_dependencies_loadable_at_toplevel(f, mainctx::Context, pkg::Packag # Only put `pkg` and its deps (recursively) in the temp project empty!(localctx.env.project.deps) localctx.env.project.deps[pkg.name] = pkg.uuid - seen_uuids = Set{UUID}() - # Only put `pkg` and its deps (recursively) in the temp project - collect_deps!(seen_uuids, pkg) end + # Only put `pkg` and its deps (recursively) in the temp project + seen_uuids = Set{UUID}() + collect_deps!(seen_uuids, pkg) pkgs = PackageSpec[] if target !== nothing diff --git a/test/pkg.jl b/test/pkg.jl index 38e3e0ca4d..54d393085b 100644 --- a/test/pkg.jl +++ b/test/pkg.jl @@ -624,6 +624,15 @@ end end end end +@testset "building project should fix version of deps" begin + temp_pkg_dir() do project_path + dep_pkg = joinpath(@__DIR__, "test_packages", "BuildProjectFixedDeps") + Pkg.activate(dep_pkg) + Pkg.build() + @test isfile(joinpath(dep_pkg, "deps", "artifact")) + end +end + include("repl.jl") include("api.jl") include("registry.jl") diff --git a/test/test_packages/BuildProjectFixedDeps/.gitignore b/test/test_packages/BuildProjectFixedDeps/.gitignore new file mode 100644 index 0000000000..387750f19f --- /dev/null +++ b/test/test_packages/BuildProjectFixedDeps/.gitignore @@ -0,0 +1,2 @@ +deps/artifact +deps/build.log \ No newline at end of file diff --git a/test/test_packages/BuildProjectFixedDeps/Manifest.toml b/test/test_packages/BuildProjectFixedDeps/Manifest.toml new file mode 100644 index 0000000000..4a1babbc46 --- /dev/null +++ b/test/test_packages/BuildProjectFixedDeps/Manifest.toml @@ -0,0 +1,92 @@ +# This file is machine-generated - editing it directly is not advised + +[[Base64]] +uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" + +[[BenchmarkTools]] +deps = ["JSON", "Printf", "Statistics", "Test"] +git-tree-sha1 = "5d1dd8577643ba9014574cd40d9c028cd5e4b85a" +uuid = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" +version = "0.4.2" + +[[Dates]] +deps = ["Printf"] +uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" + +[[Distributed]] +deps = ["Random", "Serialization", "Sockets"] +uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b" + +[[InteractiveUtils]] +deps = ["Markdown"] +uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" + +[[JSON]] +deps = ["Dates", "Distributed", "Mmap", "Sockets", "Test", "Unicode"] +git-tree-sha1 = "fec8e4d433072731466d37ed0061b3ba7f70eeb9" +uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" +version = "0.19.0" + +[[LibGit2]] +uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" + +[[Libdl]] +uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" + +[[LinearAlgebra]] +deps = ["Libdl"] +uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" + +[[Logging]] +uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" + +[[Markdown]] +deps = ["Base64"] +uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" + +[[Mmap]] +uuid = "a63ad114-7e13-5084-954f-fe012c677804" + +[[Pkg]] +deps = ["Dates", "LibGit2", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"] +uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" + +[[Printf]] +deps = ["Unicode"] +uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" + +[[REPL]] +deps = ["InteractiveUtils", "Markdown", "Sockets"] +uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" + +[[Random]] +deps = ["Serialization"] +uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" + +[[SHA]] +uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" + +[[Serialization]] +uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" + +[[Sockets]] +uuid = "6462fe0b-24de-5631-8697-dd941f90decc" + +[[SparseArrays]] +deps = ["LinearAlgebra", "Random"] +uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" + +[[Statistics]] +deps = ["LinearAlgebra", "SparseArrays"] +uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" + +[[Test]] +deps = ["Distributed", "InteractiveUtils", "Logging", "Random"] +uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" + +[[UUIDs]] +deps = ["Random", "SHA"] +uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" + +[[Unicode]] +uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" diff --git a/test/test_packages/BuildProjectFixedDeps/Project.toml b/test/test_packages/BuildProjectFixedDeps/Project.toml new file mode 100644 index 0000000000..93f9a83e41 --- /dev/null +++ b/test/test_packages/BuildProjectFixedDeps/Project.toml @@ -0,0 +1,7 @@ +name = "BuildProjectFixedDeps" +uuid = "a9d53770-2f9b-11e9-234d-75f2cd7ebf28" +version = "0.1.0" + +[deps] +BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" +Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" diff --git a/test/test_packages/BuildProjectFixedDeps/deps/build.jl b/test/test_packages/BuildProjectFixedDeps/deps/build.jl new file mode 100644 index 0000000000..d3120707ef --- /dev/null +++ b/test/test_packages/BuildProjectFixedDeps/deps/build.jl @@ -0,0 +1,5 @@ +import Pkg +build_artifact = joinpath(@__DIR__, "artifact") +isfile(build_artifact) && rm(build_artifact) +@assert Pkg.installed()["JSON"] == v"0.19.0" +touch(build_artifact) \ No newline at end of file diff --git a/test/test_packages/BuildProjectFixedDeps/src/BuildProjectFixedDeps.jl b/test/test_packages/BuildProjectFixedDeps/src/BuildProjectFixedDeps.jl new file mode 100644 index 0000000000..17987d4cbf --- /dev/null +++ b/test/test_packages/BuildProjectFixedDeps/src/BuildProjectFixedDeps.jl @@ -0,0 +1,5 @@ +module BuildProjectFixedDeps + +greet() = print("Hello World!") + +end # module From c784ab497cbfd31861d7155a50aa7548b73df2e9 Mon Sep 17 00:00:00 2001 From: Fredrik Ekre Date: Wed, 27 Feb 2019 00:10:19 +0100 Subject: [PATCH 16/16] Set version to 1.1.3. --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index c4793ef282..c03db0d34e 100644 --- a/Project.toml +++ b/Project.toml @@ -2,7 +2,7 @@ desc = "The next-generation Julia package manager." keywords = ["package", "management"] license = "MIT" name = "Pkg" -version = "1.1.2" +version = "1.1.3" uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" [deps]