Skip to content

Commit

Permalink
disable Pkg3 precompile unless opted into
Browse files Browse the repository at this point in the history
  • Loading branch information
KristofferC committed Feb 23, 2018
1 parent 2f0db6d commit 11fa379
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 deletions.
12 changes: 11 additions & 1 deletion stdlib/Pkg3/src/API.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Dates
import LibGit2

import Pkg3
import Pkg3: depots, logdir, devdir
import Pkg3: depots, logdir, devdir, print_first_command_header
using Pkg3.Types
using Pkg3.TOML

Expand All @@ -19,6 +19,7 @@ add(pkgs::Vector{String}; kwargs...) = add([PackageSpec(pkg) for pkg in pkg
add(pkgs::Vector{PackageSpec}; kwargs...) = add(Context(), pkgs; kwargs...)

function add(ctx::Context, pkgs::Vector{PackageSpec}; kwargs...)
print_first_command_header()
Context!(ctx; kwargs...)
ctx.preview && preview_info()
project_resolve!(ctx.env, pkgs)
Expand All @@ -33,6 +34,7 @@ rm(pkgs::Vector{String}; kwargs...) = rm([PackageSpec(pkg) for pkg in pkgs]
rm(pkgs::Vector{PackageSpec}; kwargs...) = rm(Context(), pkgs; kwargs...)

function rm(ctx::Context, pkgs::Vector{PackageSpec}; kwargs...)
print_first_command_header()
Context!(ctx; kwargs...)
ctx.preview && preview_info()
project_resolve!(ctx.env, pkgs)
Expand All @@ -48,6 +50,7 @@ up(pkgs::Vector{PackageSpec}; kwargs...) = up(Context(), pkgs; kwargs...)

function up(ctx::Context, pkgs::Vector{PackageSpec};
level::UpgradeLevel=UPLEVEL_MAJOR, mode::PackageMode=PKGMODE_PROJECT, kwargs...)
print_first_command_header()
Context!(ctx; kwargs...)
ctx.preview && preview_info()

Expand Down Expand Up @@ -126,6 +129,7 @@ pin(pkgs::Vector{String}; kwargs...) = pin([PackageSpec(pkg) for pkg
pin(pkgs::Vector{PackageSpec}; kwargs...) = pin(Context(), pkgs; kwargs...)

function pin(ctx::Context, pkgs::Vector{PackageSpec}; kwargs...)
print_first_command_header()
Context!(ctx; kwargs...)
ctx.preview && preview_info()
project_resolve!(ctx.env, pkgs)
Expand All @@ -139,6 +143,7 @@ free(pkgs::Vector{String}; kwargs...) = free([PackageSpec(pkg) for pk
free(pkgs::Vector{PackageSpec}; kwargs...) = free(Context(), pkgs; kwargs...)

function free(ctx::Context, pkgs::Vector{PackageSpec}; kwargs...)
print_first_command_header()
Context!(ctx; kwargs...)
ctx.preview && preview_info()
project_resolve!(ctx.env, pkgs)
Expand All @@ -155,6 +160,7 @@ checkout(pkgs::Vector{PackageSpec}; kwargs...) = checkout([(pkg, nothing)
checkout(pkgs_branches::Vector; kwargs...) = checkout(Context(), pkgs_branches; kwargs...)

function checkout(ctx::Context, pkgs_branches::Vector; path = devdir(), kwargs...)
print_first_command_header()
Context!(ctx; kwargs...)
ctx.preview && preview_info()
pkgs = [p[1] for p in pkgs_branches]
Expand All @@ -171,6 +177,7 @@ test(pkgs::Vector{String}; kwargs...) = test([PackageSpec(pkg) for p
test(pkgs::Vector{PackageSpec}; kwargs...) = test(Context(), pkgs; kwargs...)

function test(ctx::Context, pkgs::Vector{PackageSpec}; coverage=false, kwargs...)
print_first_command_header()
Context!(ctx; kwargs...)
ctx.preview && preview_info()
project_resolve!(ctx.env, pkgs)
Expand All @@ -192,6 +199,7 @@ end


function gc(ctx::Context=Context(); period = Dates.Week(6), kwargs...)
print_first_command_header()
function recursive_dir_size(path)
sz = 0
for (root, dirs, files) in walkdir(path)
Expand Down Expand Up @@ -310,6 +318,7 @@ build(pkg::PackageSpec) = build([pkg])
build(pkgs::Vector{PackageSpec}) = build(Context(), pkgs)

function build(ctx::Context, pkgs::Vector{PackageSpec}; kwargs...)
print_first_command_header()
Context!(ctx; kwargs...)
if isempty(pkgs)
for (name, infos) in ctx.env.manifest, info in infos
Expand All @@ -329,6 +338,7 @@ function build(ctx::Context, pkgs::Vector{PackageSpec}; kwargs...)
end

function init(path::String)
print_first_command_header()
ctx = Context(env = EnvCache(joinpath(path, "Project.toml")))
Pkg3.Operations.init(ctx)
end
Expand Down
26 changes: 25 additions & 1 deletion stdlib/Pkg3/src/Pkg3.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,23 @@ depots() = Base.DEPOT_PATH
logdir() = joinpath(depots()[1], "logs")
devdir() = get(ENV, "JULIA_PKG_DEVDIR", joinpath(homedir(), ".julia", "dev"))

have_warned_session = false
function print_first_command_header()
global have_warned_session
have_warned_session && return
@info """
Pkg3 is still under development, please file issues at `https://github.com/JuliaLang/Pkg3.jl`.
"""
if !PKG3_IS_PRECOMPILED && !haskey(ENV, "JULIA_PKG3_DISABLE_PRECOMPILE_WARNING")
@info """
Pkg3 is running without precompile statements, first action will be slow.
Rebuild julia with the environment variable `JULIA_PKG3_PRECOMPILE` set to enable precompilation of PKG3.
This message can be disabled by setting the env variable `JULIA_PKG3_DISABLE_PRECOMPILE_WARNING`.
"""
end
have_warned_session = true
end

# load snapshotted dependencies
include("../ext/TOML/src/TOML.jl")

Expand Down Expand Up @@ -41,6 +58,13 @@ end
using Pkg3.Types
using UUIDs
import LibGit2
include("precompile.jl")
# This crashes low memory systems and some of Julia's CI
# so keep it disabled by default for now.
if haskey(ENV, "JULIA_PKG3_PRECOMPILE")
const PKG3_IS_PRECOMPILED = true
include("precompile.jl")
else
const PKG3_IS_PRECOMPILED = false
end

end # module
3 changes: 2 additions & 1 deletion stdlib/Pkg3/src/REPLMode.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import REPL
import REPL: LineEdit, REPLCompletions

import Pkg3
import Pkg3: devdir
import Pkg3: devdir, print_first_command_header
using Pkg3.Types
using Pkg3.Display
using Pkg3.Operations
Expand Down Expand Up @@ -151,6 +151,7 @@ const lex_re = r"^[\?\./\+\-](?!\-) | [^@\s]+\s*=\s*[^@\s]+ | @\s*[^@\s]* | [^@\
const Token = Union{Command, Option, VersionRange, String}

function tokenize(cmd::String)::Vector{Token}
print_first_command_header()
tokens = Token[]
words = map(m->m.match, eachmatch(lex_re, cmd))
help_mode = false
Expand Down

0 comments on commit 11fa379

Please sign in to comment.