Skip to content

Commit

Permalink
load path: change default LOAD_PATH (#25709)
Browse files Browse the repository at this point in the history
also:

- rename "site" directory to "stdlib" since that's what it is now

- use JULIA_LOAD_PATH as-is instead unconditionally appending the
  system package and stdlib directories to it

- change default DEPOT_PATH to include system paths: one for
  arch-specific and one for arch-independent packages

- delete comment about bundled code going in a versioned directory
  as it no longer applies since installed packages can and should
  be shared across different Julia versions
  • Loading branch information
StefanKarpinski committed Apr 13, 2018
1 parent 2233ec4 commit 1d3c400
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 29 deletions.
15 changes: 4 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
JULIAHOME := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
include $(JULIAHOME)/Make.inc

# TODO: Code bundled with Julia should be installed into a versioned directory,
# prefix/share/julia/VERSDIR, so that in the future one can have multiple
# major versions of Julia installed concurrently. Third-party code that
# is not controlled by Pkg should be installed into
# prefix/share/julia/site/VERSDIR (not prefix/share/julia/VERSDIR/site ...
# so that prefix/share/julia/VERSDIR can be overwritten without touching
# third-party code).
VERSDIR := v`cut -d. -f1-2 < $(JULIAHOME)/VERSION`

default: $(JULIA_BUILD_MODE) # contains either "debug" or "release"
all: debug release

# sort is used to remove potential duplicates
DIRS := $(sort $(build_bindir) $(build_depsbindir) $(build_libdir) $(build_private_libdir) $(build_libexecdir) $(build_includedir) $(build_includedir)/julia $(build_sysconfdir)/julia $(build_datarootdir)/julia $(build_datarootdir)/julia/site $(build_man1dir))
DIRS := $(sort $(build_bindir) $(build_depsbindir) $(build_libdir) $(build_private_libdir) $(build_libexecdir) $(build_includedir) $(build_includedir)/julia $(build_sysconfdir)/julia $(build_datarootdir)/julia $(build_datarootdir)/julia/stdlib $(build_man1dir))
ifneq ($(BUILDROOT),$(JULIAHOME))
BUILDDIRS := $(BUILDROOT) $(addprefix $(BUILDROOT)/,base src ui doc deps test test/embedding)
BUILDDIRMAKE := $(addsuffix /Makefile,$(BUILDDIRS))
Expand Down Expand Up @@ -46,8 +39,8 @@ endif
$(foreach dir,$(DIRS),$(eval $(call dir_target,$(dir))))
$(foreach link,base $(JULIAHOME)/test,$(eval $(call symlink_target,$(link),$(build_datarootdir)/julia,$(notdir $(link)))))

build_defaultpkgdir = $(build_datarootdir)/julia/site/$(shell echo $(VERSDIR))
$(eval $(call symlink_target,$(JULIAHOME)/stdlib,$(build_datarootdir)/julia/site,$(shell echo $(VERSDIR))))
build_defaultpkgdir = $(build_datarootdir)/julia/stdlib/$(shell echo $(VERSDIR))
$(eval $(call symlink_target,$(JULIAHOME)/stdlib,$(build_datarootdir)/julia/stdlib,$(shell echo $(VERSDIR))))

julia_flisp.boot.inc.phony: julia-deps
@$(MAKE) $(QUIET_MAKE) -C $(BUILDROOT)/src julia_flisp.boot.inc.phony
Expand Down Expand Up @@ -284,7 +277,7 @@ endef

install: $(build_depsbindir)/stringreplace $(BUILDROOT)/doc/_build/html/en/index.html
@$(MAKE) $(QUIET_MAKE) all
@for subdir in $(bindir) $(datarootdir)/julia/site/$(VERSDIR) $(docdir) $(man1dir) $(includedir)/julia $(libdir) $(private_libdir) $(sysconfdir); do \
@for subdir in $(bindir) $(datarootdir)/julia/stdlib/$(VERSDIR) $(docdir) $(man1dir) $(includedir)/julia $(libdir) $(private_libdir) $(sysconfdir); do \
mkdir -p $(DESTDIR)$$subdir; \
done

Expand Down
17 changes: 10 additions & 7 deletions base/initdefs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ function init_depot_path(BINDIR = Sys.BINDIR)
depots = split(ENV["JULIA_DEPOT_PATH"], Sys.iswindows() ? ';' : ':')
append!(empty!(DEPOT_PATH), map(expanduser, depots))
else
push!(DEPOT_PATH, joinpath(homedir(), ".julia"))
push!(empty!(DEPOT_PATH), joinpath(homedir(), ".julia"))
push!(DEPOT_PATH, abspath(BINDIR, "..", "local", "share", "julia"))
push!(DEPOT_PATH, abspath(BINDIR, "..", "share", "julia"))
end
end

Expand Down Expand Up @@ -115,14 +117,15 @@ function parse_load_path(str::String)
return envs
end

const default_named = parse_load_path("@v#.#.#|@v#.#|@v#|@default|@!v#.#")

function init_load_path(BINDIR = Sys.BINDIR)
if !Base.creating_sysimg
load_path = get(ENV, "JULIA_LOAD_PATH", "@|@v#.#.#|@v#.#|@v#|@default|@!v#.#")
append!(empty!(LOAD_PATH), parse_load_path(load_path))
end
vers = "v$(VERSION.major).$(VERSION.minor)"
push!(LOAD_PATH, abspath(BINDIR, "..", "local", "share", "julia", "site", vers))
push!(LOAD_PATH, abspath(BINDIR, "..", "share", "julia", "site", vers))
stdlib = abspath(BINDIR, "..", "share", "julia", "stdlib", vers)
load_path = Base.creating_sysimg ? Any[stdlib] :
haskey(ENV, "JULIA_LOAD_PATH") ? parse_load_path(ENV["JULIA_LOAD_PATH"]) :
Any[CurrentEnv(); default_named; stdlib]
append!(empty!(LOAD_PATH), load_path)
end

const atexit_hooks = []
Expand Down
10 changes: 5 additions & 5 deletions doc/src/manual/environment-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,16 @@ systems, the path separator is `;`.) The `LOAD_PATH` variable is where
paths

```
$JULIA_HOME/../local/share/julia/site/v$(VERSION.major).$(VERSION.minor)
$JULIA_HOME/../share/julia/site/v$(VERSION.major).$(VERSION.minor)
$JULIA_HOME/../local/share/julia/stdlib/v$(VERSION.major).$(VERSION.minor)
$JULIA_HOME/../share/julia/stdlib/v$(VERSION.major).$(VERSION.minor)
```

so that, e.g., version 0.6 of Julia on a Linux system with a Julia executable at
so that, e.g., version 0.7 of Julia on a Linux system with a Julia executable at
`/bin/julia` will have a default `LOAD_PATH` of

```
/local/share/julia/site/v0.6
/share/julia/site/v0.6
/local/share/julia/stdlib/v0.7
/share/julia/stdlib/v0.7
```

### `JULIA_PKGDIR`
Expand Down
1 change: 0 additions & 1 deletion src/common_symbols2.inc
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ jl_symbol("pipe_writer"),
jl_symbol("idxfloor"),
jl_symbol("id"),
jl_symbol("ComplexF32"),
jl_symbol("/home/jeff/src/julia/usr/share/julia/site/v0.7/Pkg/src/resolve/versionweight.jl"),
jl_symbol("Int32"),
jl_symbol("indices.jl"),
jl_symbol("iobuffer.jl"),
Expand Down
2 changes: 1 addition & 1 deletion stdlib/Pkg3/bin/genstdlib.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ prefix = joinpath(homedir(), ".julia", "registries", "Stdlib")

# TODO: use Sys.STDLIBDIR instead once implemented
let vers = "v$(VERSION.major).$(VERSION.minor)"
global stdlibdir = realpath(abspath(Sys.BINDIR, "..", "share", "julia", "site", vers))
global stdlibdir = realpath(abspath(Sys.BINDIR, "..", "share", "julia", "stdlib", vers))
isdir(stdlibdir) || error("stdlib directory does not exist: $stdlibdir")
end
juliadir = dirname(stdlibdir)
Expand Down
2 changes: 1 addition & 1 deletion stdlib/Pkg3/src/Types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ is_project_uuid(env::EnvCache, uuid::UUID) =
###########
# Context #
###########
stdlib_dir() = joinpath(Sys.BINDIR, "..", "share", "julia", "site", "v$(VERSION.major).$(VERSION.minor)")
stdlib_dir() = joinpath(Sys.BINDIR, "..", "share", "julia", "stdlib", "v$(VERSION.major).$(VERSION.minor)")
stdlib_path(stdlib::String) = joinpath(stdlib_dir(), stdlib)
function gather_stdlib_uuids()
stdlibs = Dict{UUID,String}()
Expand Down
4 changes: 2 additions & 2 deletions stdlib/Pkg3/test/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ function temp_pkg_dir(fn::Function)
pushfirst!(DEPOT_PATH, depot_dir)
# Add the standard library paths back
vers = "v$(VERSION.major).$(VERSION.minor)"
push!(LOAD_PATH, abspath(Sys.BINDIR, "..", "local", "share", "julia", "site", vers))
push!(LOAD_PATH, abspath(Sys.BINDIR, "..", "share", "julia", "site", vers))
push!(LOAD_PATH, abspath(Sys.BINDIR, "..", "local", "share", "julia", "stdlib", vers))
push!(LOAD_PATH, abspath(Sys.BINDIR, "..", "share", "julia", "stdlib", vers))
fn(env_dir)
end
end
Expand Down
2 changes: 1 addition & 1 deletion test/choosetests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

using Random, Sockets

const STDLIB_DIR = joinpath(Sys.BINDIR, "..", "share", "julia", "site", "v$(VERSION.major).$(VERSION.minor)")
const STDLIB_DIR = joinpath(Sys.BINDIR, "..", "share", "julia", "stdlib", "v$(VERSION.major).$(VERSION.minor)")
const STDLIBS = readdir(STDLIB_DIR)

"""
Expand Down

0 comments on commit 1d3c400

Please sign in to comment.