Skip to content

Commit

Permalink
Merge pull request #28309 from JuliaLang/kc/bump_pkg
Browse files Browse the repository at this point in the history
Bump Pkg
  • Loading branch information
KristofferC authored Jul 28, 2018
2 parents 31bf0b8 + b6dc9bf commit 2fb2028
Show file tree
Hide file tree
Showing 46 changed files with 1,214 additions and 404 deletions.
7 changes: 7 additions & 0 deletions stdlib/Base64/Project.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
name = "Base64"
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

[targets]
test = ["Test", "Random"]
7 changes: 7 additions & 0 deletions stdlib/CRC32c/Project.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
name = "CRC32c"
uuid = "8bf52ea8-c179-5cab-976a-9e18b702a9bc"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

[targets]
test = ["Test", "Random"]
7 changes: 7 additions & 0 deletions stdlib/Dates/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,10 @@ uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"

[deps]
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"

[targets]
test = ["Test", "InteractiveUtils"]
7 changes: 7 additions & 0 deletions stdlib/DelimitedFiles/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,10 @@ uuid = "8bb1440f-4735-579b-a4ab-409b98df4dab"

[deps]
Mmap = "a63ad114-7e13-5084-954f-fe012c677804"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

[targets]
test = ["Test", "Random"]
6 changes: 6 additions & 0 deletions stdlib/Distributed/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Sockets = "6462fe0b-24de-5631-8697-dd941f90decc"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test"]
6 changes: 6 additions & 0 deletions stdlib/FileWatching/Project.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
name = "FileWatching"
uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test"]
7 changes: 7 additions & 0 deletions stdlib/Future/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,10 @@ uuid = "9fa8497b-333b-5362-9e8d-4d0656e87820"

[deps]
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"

[targets]
test = ["Test", "SparseArrays"]
7 changes: 7 additions & 0 deletions stdlib/InteractiveUtils/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,10 @@ uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
[deps]
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

[targets]
test = ["Test", "Random"]
9 changes: 9 additions & 0 deletions stdlib/LibGit2/Project.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
name = "LibGit2"
uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
Sockets = "6462fe0b-24de-5631-8697-dd941f90decc"

[targets]
test = ["Test", "Random", "Serialization", "Sockets"]
6 changes: 6 additions & 0 deletions stdlib/Libdl/Project.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
name = "Libdl"
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test"]
8 changes: 8 additions & 0 deletions stdlib/LinearAlgebra/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,11 @@ uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

[deps]
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"

[targets]
test = ["Test", "Random", "SparseArrays"]
6 changes: 6 additions & 0 deletions stdlib/Logging/Project.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
name = "Logging"
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test"]
6 changes: 6 additions & 0 deletions stdlib/Markdown/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@ uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"

[deps]
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test"]
7 changes: 7 additions & 0 deletions stdlib/Mmap/Project.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
name = "Mmap"
uuid = "a63ad114-7e13-5084-954f-fe012c677804"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

[targets]
test = ["Test", "Random"]
7 changes: 7 additions & 0 deletions stdlib/OldPkg/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,10 @@ uuid = "fe1c5a76-5840-53d2-82f9-288dd83ce2ce"

[deps]
LibGit2 = "76f85450-5226-5b5a-8eaa-529ad045b433"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

[targets]
test = ["Test", "Random"]
6 changes: 6 additions & 0 deletions stdlib/Pkg/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@ REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
SHA = "ea8e919c-243c-51af-8825-aaa63cd721ce"
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test"]
4 changes: 3 additions & 1 deletion stdlib/Pkg/docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

using Documenter, Pkg
Base.ACTIVE_PROJECT[] = joinpath(@__DIR__, "..")
using Documenter
using Pkg

makedocs(
modules = [Pkg],
Expand Down
44 changes: 40 additions & 4 deletions stdlib/Pkg/docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ Since we haven't created our own project yet, we are in the default project, loc

To return to the `julia>` prompt, either press backspace when the input line is empty or press Ctrl+C.
Help is available by calling `pkg> help`.
If you are in an environment that does not have access to a REPL you can still use the REPL mode commands using
the string macro `pkg` available after `using Pkg`. The command `pkg"cmd"` would be equivalent to executing `cmd`
in the REPL mode.

The documentation here describes using Pkg from the REPL mode. Documentation of using
the Pkg API (by calling `Pkg.` functions) is in progress of being written.
Expand Down Expand Up @@ -356,6 +359,7 @@ Note the info message saying that it is using the existing path. This means that
an already developed package.

If `dev` is used on a local path, that path to that package is recorded and used when loading that package.
The path will be recorded relative to the project file, unless it is given as an absolute path.

To stop tracking a path and use the registered version again, use `free`

Expand Down Expand Up @@ -689,13 +693,18 @@ Testing...

#### Test-specific dependencies

Sometimes one might want to use some packages only at testing time but not enforce a dependency on them when the package is used.
This is possible by adding dependencies to a "test target" to the Project file. Here we add the `Test` standard library as a
test-only dependency by adding the following to the Project file:
Sometimes one might want to use some packages only at testing time but not
enforce a dependency on them when the package is used. This is possible by
adding `[extra]` dependencies and adding a a "test target" to the Project file.
Here we add the `Test` standard library as a test-only dependency by adding the
following to the Project file:

```
[targets.test.deps]
[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
[targets]
test = ["Test"]
```

We can now use `Test` in the test script and we can see that it gets installed on testing:
Expand Down Expand Up @@ -826,3 +835,30 @@ Simply clone their project using e.g. `git clone`, `cd` to the project directory

If the project contains a manifest, this will install the packages in the same state that is given by that manifest.
Otherwise, it will resolve the latest versions of the dependencies compatible with the project.

## References

This section describes the "API mode" of interacting with Pkg.jl which is recommended for non-interactive usage,
in i.e. scripts. In the REPL mode packages (with associated version, UUID, URL etc) are parsed from strings,
for example, `"Package#master"`,`"[email protected]"`, `"www.mypkg.com/MyPkg#my/feature"`.
It is possible to use strings as arguments for simple commands in the API mode (like `Pkg.add(["PackageA", "PackageB"])`,
more complicated commands, that e.g. specify URLs or version range, uses a more structured format over strings.
This is done by creating an instance of a [`PackageSpec`](@ref) which are passed in to functions.

```@docs
PackageSpec
PackageMode
UpgradeLevel
Pkg.add
Pkg.develop
Pkg.activate
Pkg.rm
Pkg.update
Pkg.test
Pkg.build
Pkg.pin
Pkg.free
Pkg.instantiate
Pkg.resolve
Pkg.setprotocol!
```
60 changes: 35 additions & 25 deletions stdlib/Pkg/src/API.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,33 @@ preview_info() = printstyled("───── Preview mode ─────\n"; c

include("generate.jl")

parse_package(pkg) = Pkg.REPLMode.parse_package(pkg; add_or_develop=true)
function check_package_name(x::String)
if !(occursin(Pkg.REPLMode.name_re, x))
cmderror("$x is not a valid packagename")
end
return PackageSpec(x)
end

add_or_develop(pkg::Union{String, PackageSpec}; kwargs...) = add_or_develop([pkg]; kwargs...)
add_or_develop(pkgs::Vector{String}; kwargs...) = add_or_develop([parse_package(pkg) for pkg in pkgs]; kwargs...)
add_or_develop(pkgs::Vector{String}; kwargs...) = add_or_develop([check_package_name(pkg) for pkg in pkgs]; 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, kwargs...)
function add_or_develop(ctx::Context, pkgs::Vector{PackageSpec}; mode::Symbol, devdir::Union{String,Nothing}=nothing, kwargs...)
Context!(ctx; kwargs...)

# All developed packages should go through handle_repos_develop so just give them an empty repo
for pkg in pkgs
mode == :develop && pkg.repo == nothing && (pkg.repo = Types.GitRepo())
end

# if julia is passed as a package the solver gets tricked;
# this catches the error early on
any(pkg->(pkg.name == "julia"), pkgs) &&
cmderror("Trying to $mode julia as a package")

ctx.preview && preview_info()
if !UPDATED_REGISTRY_THIS_SESSION[]
update_registry(ctx)
end
if mode == :develop
new_git = handle_repos_develop!(ctx, pkgs)
new_git = handle_repos_develop!(ctx, pkgs, something(devdir, Pkg.devdir()))
else
new_git = handle_repos_add!(ctx, pkgs; upgrade_or_add=true)
end
Expand All @@ -55,12 +62,10 @@ end

add(args...; kwargs...) = add_or_develop(args...; mode = :add, kwargs...)
develop(args...; kwargs...) = add_or_develop(args...; mode = :develop, kwargs...)
@deprecate checkout develop


rm(pkg::Union{String, PackageSpec}; kwargs...) = rm([pkg]; kwargs...)
rm(pkgs::Vector{String}; kwargs...) = rm([PackageSpec(pkg) for pkg in pkgs]; kwargs...)
rm(pkgs::Vector{PackageSpec}; kwargs...) = rm(Context(), pkgs; kwargs...)
rm(pkg::Union{String, PackageSpec}; kwargs...) = rm([pkg]; kwargs...)
rm(pkgs::Vector{String}; kwargs...) = rm([PackageSpec(pkg) for pkg in pkgs]; kwargs...)
rm(pkgs::Vector{PackageSpec}; kwargs...) = rm(Context(), pkgs; kwargs...)

function rm(ctx::Context, pkgs::Vector{PackageSpec}; kwargs...)
Context!(ctx; kwargs...)
Expand Down Expand Up @@ -96,7 +101,7 @@ function update_registry(ctx)
try
GitTools.fetch(repo; refspecs=["+refs/heads/$branch:refs/remotes/origin/$branch"])
catch e
e isa LibGit2.GitError || rethrow(e)
e isa CommandError || rethrow(e)
push!(errors, (reg, "failed to fetch from repo"))
return
end
Expand Down Expand Up @@ -280,22 +285,20 @@ function gc(ctx::Context=Context(); kwargs...)
for (manifestfile, date) in manifest_date
!isfile(manifestfile) && continue
println(" `$manifestfile`")
infos = try
manifest = try
read_manifest(manifestfile)
catch e
@warn "Reading manifest file at $manifestfile failed with error" exception = e
nothing
end
infos == nothing && continue
manifest == nothing && continue
new_usage[manifestfile] = [Dict("time" => date)]
for entry in infos
entry isa Pair || continue
name, _stanzas = entry
@assert length(_stanzas) == 1
stanzas = _stanzas[1]
if stanzas isa Dict && haskey(stanzas, "uuid") && haskey(stanzas, "git-tree-sha1")
push!(paths_to_keep,
Operations.find_installed(name, UUID(stanzas["uuid"]), SHA1(stanzas["git-tree-sha1"])))
for (name, infos) in manifest
for info in infos
if haskey(info, "uuid") && haskey(info, "git-tree-sha1")
push!(paths_to_keep,
Operations.find_installed(name, UUID(info["uuid"]), SHA1(info["git-tree-sha1"])))
end
end
end
end
Expand Down Expand Up @@ -381,11 +384,11 @@ function _get_deps!(ctx::Context, pkgs::Vector{PackageSpec}, uuids::Vector{UUID}
return
end


build(pkgs...) = build([PackageSpec(pkg) for pkg in pkgs])
build(pkg::Array{Union{}, 1}) = build(PackageSpec[])
build(pkg::PackageSpec) = build([pkg])
build(pkgs::Vector{PackageSpec}) = build(Context(), pkgs)

function build(ctx::Context, pkgs::Vector{PackageSpec}; kwargs...)
Context!(ctx; kwargs...)

Expand Down Expand Up @@ -426,7 +429,7 @@ function clone(url::String, name::String = "")
if !isempty(name)
ctx.old_pkg2_clone_name = name
end
develop(ctx, [parse_package(url)])
develop(ctx, [Pkg.REPLMode.parse_package(url; add_or_develop=true)])
end

function dir(pkg::String, paths::String...)
Expand Down Expand Up @@ -543,6 +546,13 @@ function instantiate(ctx::Context; manifest::Union{Bool, Nothing}=nothing, kwarg
Operations.build_versions(ctx, union(new_apply, new_git))
end


status(mode=PKGMODE_PROJECT) = status(Context(), mode)
function status(ctx::Context, mode=PKGMODE_PROJECT)
Pkg.Display.status(ctx, mode)
return
end

function activate(path::Union{String,Nothing}=nothing)
Base.ACTIVE_PROJECT[] = Base.load_path_expand(path)
end
Expand Down
2 changes: 2 additions & 0 deletions stdlib/Pkg/src/Display.jl
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ function print_diff(io::IO, ctx::Context, diff::Vector{DiffEntry}, status=false)
pkgid = Base.PkgId(x.uuid, x.name)
package_downloaded = pkgid in keys(Base.loaded_modules) ||
Base.locate_package(pkgid) !== nothing
# Package download detection doesnt work properly when runn running targets
ctx.currently_running_target && (package_downloaded = true)
if x.old != nothing && x.new != nothing
if x.old x.new
verb = ' '
Expand Down
Loading

0 comments on commit 2fb2028

Please sign in to comment.