Skip to content

Commit ae8bbf6

Browse files
authored
Merge pull request #23876 from JuliaLang/jb/stdlib
approach to default packages
2 parents 5a5dbed + d759779 commit ae8bbf6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+409
-327
lines changed

Makefile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ default: $(JULIA_BUILD_MODE) # contains either "debug" or "release"
1919
all: debug release
2020

2121
# sort is used to remove potential duplicates
22-
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_man1dir))
22+
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))
2323
ifneq ($(BUILDROOT),$(JULIAHOME))
2424
BUILDDIRS := $(BUILDROOT) $(addprefix $(BUILDROOT)/,base src ui doc deps test test/perf examples examples/embedding)
2525
BUILDDIRMAKE := $(addsuffix /Makefile,$(BUILDDIRS))
@@ -50,6 +50,11 @@ endif
5050

5151
$(foreach dir,$(DIRS),$(eval $(call dir_target,$(dir))))
5252
$(foreach link,base test,$(eval $(call symlink_target,$(link),$(build_datarootdir)/julia)))
53+
$(eval $(call symlink_target,stdlib,$(build_datarootdir)/julia/site))
54+
55+
build_defaultpkgdir = $(build_datarootdir)/julia/site/$(shell echo $(VERSDIR))
56+
$(build_defaultpkgdir): $(build_datarootdir)/julia/site/stdlib
57+
@mv $(build_datarootdir)/julia/site/stdlib $@
5358

5459
julia_flisp.boot.inc.phony: julia-deps
5560
@$(MAKE) $(QUIET_MAKE) -C $(BUILDROOT)/src julia_flisp.boot.inc.phony
@@ -81,7 +86,7 @@ ifndef JULIA_VAGRANT_BUILD
8186
endif
8287
endif
8388

84-
julia-deps: | $(DIRS) $(build_datarootdir)/julia/base $(build_datarootdir)/julia/test
89+
julia-deps: | $(DIRS) $(build_datarootdir)/julia/base $(build_datarootdir)/julia/test $(build_defaultpkgdir)
8590
@$(MAKE) $(QUIET_MAKE) -C $(BUILDROOT)/deps
8691

8792
julia-base: julia-deps $(build_sysconfdir)/julia/juliarc.jl $(build_man1dir)/julia.1 $(build_datarootdir)/julia/julia-config.jl

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,11 +372,12 @@ It is highly recommended to start with a fresh clone of the Julia repository.
372372

373373
The Julia source code is organized as follows:
374374

375-
base/ source code for Julia's standard library
375+
base/ source code for the Base module (part of Julia's standard library)
376+
stdlib/ source code for other standard library packages
376377
contrib/ editor support for Julia source, miscellaneous scripts
377378
deps/ external dependencies
378-
doc/manual source for the user manual
379-
doc/stdlib source for standard library function help text
379+
doc/src/manual source for the user manual
380+
doc/src/stdlib source for standard library function reference
380381
examples/ example Julia programs
381382
src/ source for Julia language core
382383
test/ test suites

base/deprecated.jl

Lines changed: 23 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -122,22 +122,26 @@ macro deprecate_binding(old, new, export_old=true, dep_message=nothing)
122122
Expr(:call, :deprecate, __module__, Expr(:quote, old)))
123123
end
124124

125-
macro deprecate_moved(old, new, export_old=true)
125+
macro deprecate_moved(old, new, export_old=true, default_package=false)
126126
eold = esc(old)
127127
return Expr(:toplevel,
128-
:(function $eold(args...; kwargs...)
129-
error($eold, " has been moved to the package ", $new, ".jl.\n",
130-
"Run `Pkg.add(\"", $new, "\")` to install it, restart Julia,\n",
131-
"and then run `using ", $new, "` to load it.")
132-
end),
128+
default_package ? :(function $eold(args...; kwargs...)
129+
error($eold, " has been moved to the standard library package ", $new, ".\n",
130+
"Restart Julia and then run `using ", $new, "` to load it.")
131+
end) :
132+
:(function $eold(args...; kwargs...)
133+
error($eold, " has been moved to the package ", $new, ".jl.\n",
134+
"Run `Pkg.add(\"", $new, "\")` to install it, restart Julia,\n",
135+
"and then run `using ", $new, "` to load it.")
136+
end),
133137
export_old ? Expr(:export, eold) : nothing,
134138
Expr(:call, :deprecate, __module__, Expr(:quote, old), 2))
135139
end
136140

137141
# BEGIN 0.6-alpha deprecations (delete when 0.6 is released)
138142

139143
@deprecate isambiguous(m1::Method, m2::Method, b::Bool) isambiguous(m1, m2, ambiguous_bottom=b) false
140-
# TODO: delete allow_bottom keyword code in Base.Test.detect_ambiguities
144+
# TODO: delete allow_bottom keyword code in Test.detect_ambiguities
141145

142146
# END 0.6-alpha deprecations
143147

@@ -999,73 +1003,6 @@ iteratoreltype(::Type{Task}) = EltypeUnknown()
9991003

10001004
isempty(::Task) = error("isempty not defined for Tasks")
10011005

1002-
@eval Base.Test begin
1003-
approx_full(x::AbstractArray) = x
1004-
approx_full(x::Number) = x
1005-
approx_full(x) = full(x)
1006-
1007-
function test_approx_eq(va, vb, Eps, astr, bstr)
1008-
va = approx_full(va)
1009-
vb = approx_full(vb)
1010-
la, lb = length(linearindices(va)), length(linearindices(vb))
1011-
if la != lb
1012-
error("lengths of ", astr, " and ", bstr, " do not match: ",
1013-
"\n ", astr, " (length $la) = ", va,
1014-
"\n ", bstr, " (length $lb) = ", vb)
1015-
end
1016-
diff = real(zero(eltype(va)))
1017-
for (xa, xb) = zip(va, vb)
1018-
if isfinite(xa) && isfinite(xb)
1019-
diff = max(diff, abs(xa-xb))
1020-
elseif !isequal(xa,xb)
1021-
error("mismatch of non-finite elements: ",
1022-
"\n ", astr, " = ", va,
1023-
"\n ", bstr, " = ", vb)
1024-
end
1025-
end
1026-
1027-
if !isnan(Eps) && !(diff <= Eps)
1028-
sdiff = string("|", astr, " - ", bstr, "| <= ", Eps)
1029-
error("assertion failed: ", sdiff,
1030-
"\n ", astr, " = ", va,
1031-
"\n ", bstr, " = ", vb,
1032-
"\n difference = ", diff, " > ", Eps)
1033-
end
1034-
end
1035-
1036-
array_eps(a::AbstractArray{Complex{T}}) where {T} = eps(float(maximum(x->(isfinite(x) ? abs(x) : T(NaN)), a)))
1037-
array_eps(a) = eps(float(maximum(x->(isfinite(x) ? abs(x) : oftype(x,NaN)), a)))
1038-
1039-
test_approx_eq(va, vb, astr, bstr) =
1040-
test_approx_eq(va, vb, 1E4*length(linearindices(va))*max(array_eps(va), array_eps(vb)), astr, bstr)
1041-
1042-
"""
1043-
@test_approx_eq_eps(a, b, tol)
1044-
1045-
Test two floating point numbers `a` and `b` for equality taking into account
1046-
a margin of tolerance given by `tol`.
1047-
"""
1048-
macro test_approx_eq_eps(a, b, c)
1049-
Base.depwarn(string("@test_approx_eq_eps is deprecated, use `@test ", a, "", b, " atol=", c, "` instead"),
1050-
Symbol("@test_approx_eq_eps"))
1051-
:(test_approx_eq($(esc(a)), $(esc(b)), $(esc(c)), $(string(a)), $(string(b))))
1052-
end
1053-
export @test_approx_eq_eps
1054-
1055-
"""
1056-
@test_approx_eq(a, b)
1057-
1058-
Deprecated. Test two floating point numbers `a` and `b` for equality taking into
1059-
account small numerical errors.
1060-
"""
1061-
macro test_approx_eq(a, b)
1062-
Base.depwarn(string("@test_approx_eq is deprecated, use `@test ", a, "", b, "` instead"),
1063-
Symbol("@test_approx_eq"))
1064-
:(test_approx_eq($(esc(a)), $(esc(b)), $(string(a)), $(string(b))))
1065-
end
1066-
export @test_approx_eq
1067-
end
1068-
10691006
# Deprecate Array(T, dims...) in favor of proper type constructors
10701007
@deprecate Array(::Type{T}, d::NTuple{N,Int}) where {T,N} Array{T}(d)
10711008
@deprecate Array(::Type{T}, d::Int...) where {T} Array{T}(d...)
@@ -1432,6 +1369,18 @@ end
14321369
using .DSP
14331370
export conv, conv2, deconv, filt, filt!, xcorr
14341371

1372+
module Test
1373+
for f in [Symbol("@inferred"), Symbol("@test"), Symbol("@test_approx_eq"),
1374+
Symbol("@test_approx_eq_eps"), Symbol("@test_broken"), Symbol("@test_nowarn"),
1375+
Symbol("@test_skip"), Symbol("@test_throws"), Symbol("@test_warn"),
1376+
Symbol("@testset"), :GenericArray, :GenericDict, :GenericSet, :GenericString,
1377+
:detect_ambiguities, :detect_unbound_args]
1378+
@eval Base.@deprecate_moved $f "Test" true true
1379+
end
1380+
end
1381+
export Test
1382+
deprecate(@__MODULE__, :Test)
1383+
14351384
# PR #21709
14361385
@deprecate cov(x::AbstractVector, corrected::Bool) cov(x, corrected=corrected)
14371386
@deprecate cov(x::AbstractMatrix, vardim::Int, corrected::Bool) cov(x, vardim, corrected=corrected)
@@ -1727,19 +1676,12 @@ import .LinAlg: diagm
17271676
@deprecate_binding φ MathConstants.φ
17281677
@deprecate_binding golden MathConstants.golden
17291678

1730-
# deprecate writecsv
1731-
@deprecate writecsv(io, a; opts...) writedlm(io, a, ','; opts...)
1732-
17331679
# PR #23271
17341680
function IOContext(io::IO; kws...)
17351681
depwarn("IOContext(io, k=v, ...) is deprecated, use IOContext(io, :k => v, ...) instead.", :IOContext)
17361682
IOContext(io, (k=>v for (k, v) in kws)...)
17371683
end
17381684

1739-
# deprecate readcsv
1740-
@deprecate readcsv(io; opts...) readdlm(io, ','; opts...)
1741-
@deprecate readcsv(io, T::Type; opts...) readdlm(io, ',', T; opts...)
1742-
17431685
@deprecate IOContext(io::IO, key, value) IOContext(io, key=>value)
17441686

17451687
# PR #23485

base/exports.jl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ export
99
Profile,
1010
Dates,
1111
Sys,
12-
Test,
1312
Libc,
1413
Libdl,
1514
Mmap,
@@ -1048,7 +1047,6 @@ export
10481047
readbytes!,
10491048
readchomp,
10501049
readdir,
1051-
readdlm,
10521050
readline,
10531051
readlines,
10541052
readuntil,
@@ -1070,7 +1068,6 @@ export
10701068
unmark,
10711069
watch_file,
10721070
write,
1073-
writedlm,
10741071
TCPSocket,
10751072
UDPSocket,
10761073

base/initdefs.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ functionality is experimental and may break or change in Julia 1.0.
6969
const LOAD_PATH = Any[]
7070
const LOAD_CACHE_PATH = String[]
7171

72-
function init_load_path()
72+
function init_load_path(JULIA_HOME = JULIA_HOME)
7373
vers = "v$(VERSION.major).$(VERSION.minor)"
7474
if haskey(ENV, "JULIA_LOAD_PATH")
7575
prepend!(LOAD_PATH, split(ENV["JULIA_LOAD_PATH"], @static Sys.iswindows() ? ';' : ':'))

base/io.jl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,3 +779,26 @@ function skipchars(io::IO, pred; linecomment=nothing)
779779
end
780780
return io
781781
end
782+
783+
"""
784+
countlines(io::IO, eol::Char='\\n')
785+
786+
Read `io` until the end of the stream/file and count the number of lines. To specify a file
787+
pass the filename as the first argument. EOL markers other than `'\\n'` are supported by
788+
passing them as the second argument.
789+
"""
790+
function countlines(io::IO, eol::Char='\n')
791+
isascii(eol) || throw(ArgumentError("only ASCII line terminators are supported"))
792+
aeol = UInt8(eol)
793+
a = Vector{UInt8}(8192)
794+
nl = 0
795+
while !eof(io)
796+
nb = readbytes!(io, a)
797+
@simd for i=1:nb
798+
@inbounds nl += a[i] == aeol
799+
end
800+
end
801+
nl
802+
end
803+
804+
countlines(f::AbstractString, eol::Char='\n') = open(io->countlines(io,eol), f)::Int

base/sysimg.jl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -360,13 +360,10 @@ include("mmap.jl")
360360
import .Mmap
361361

362362
# utilities - timing, help, edit
363-
include("datafmt.jl")
364-
using .DataFmt
365363
include("deepcopy.jl")
366364
include("interactiveutil.jl")
367365
include("summarysize.jl")
368366
include("replutil.jl")
369-
include("test.jl")
370367
include("i18n.jl")
371368
using .I18n
372369

@@ -453,4 +450,13 @@ end # baremodule Base
453450

454451
using Base
455452

453+
# set up load path to be able to find stdlib packages
454+
Base.init_load_path(ccall(:jl_get_julia_home, Any, ()))
455+
456+
# load some stdlib packages but don't put their names in Main
457+
Base.require(:DelimitedFiles)
458+
Base.require(:Test)
459+
460+
empty!(LOAD_PATH)
461+
456462
Base.isfile("userimg.jl") && Base.include(Main, "userimg.jl")

doc/make.jl

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@ end
1616

1717
# Documenter Setup.
1818

19+
# make links for stdlib package docs
20+
if Sys.iswindows()
21+
cp("../stdlib/DelimitedFiles/docs/src/index.md", "src/stdlib/delimitedfiles.md")
22+
cp("../stdlib/Test/docs/src/index.md", "src/stdlib/test.md")
23+
else
24+
symlink("../../../stdlib/DelimitedFiles/docs/src/index.md", "src/stdlib/delimitedfiles.md")
25+
symlink("../../../stdlib/Test/docs/src/index.md", "src/stdlib/test.md")
26+
end
27+
1928
const PAGES = [
2029
"Home" => "index.md",
2130
"Manual" => [
@@ -69,6 +78,7 @@ const PAGES = [
6978
"stdlib/linalg.md",
7079
"stdlib/constants.md",
7180
"stdlib/file.md",
81+
"stdlib/delimitedfiles.md",
7282
"stdlib/io-network.md",
7383
"stdlib/punctuation.md",
7484
"stdlib/sort.md",
@@ -116,9 +126,11 @@ const PAGES = [
116126
],
117127
]
118128

129+
using DelimitedFiles, Test
130+
119131
makedocs(
120132
build = joinpath(pwd(), "_build/html/en"),
121-
modules = [Base, Core, BuildSysImg],
133+
modules = [Base, Core, BuildSysImg, DelimitedFiles, Test],
122134
clean = false,
123135
doctest = "doctest" in ARGS,
124136
linkcheck = "linkcheck" in ARGS,

doc/src/stdlib/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
delimitedfiles.md
2+
test.md

doc/src/stdlib/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* [Linear Algebra](@ref)
1111
* [Constants](@ref lib-constants)
1212
* [Filesystem](@ref)
13+
* [Delimited Files](@ref)
1314
* [I/O and Network](@ref)
1415
* [Punctuation](@ref)
1516
* [Sorting and Related Functions](@ref)

0 commit comments

Comments
 (0)