Skip to content

Commit 5cb8252

Browse files
committed
prototype approach to default packages; installing in site/
as a demo, moves DataFmt out of Base. adds a line to default juliarc so the functions are still available by default.
1 parent b2cbf31 commit 5cb8252

File tree

15 files changed

+72
-65
lines changed

15 files changed

+72
-65
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

base/deprecated.jl

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1724,19 +1724,12 @@ import .LinAlg: diagm
17241724
@deprecate_binding φ MathConstants.φ
17251725
@deprecate_binding golden MathConstants.golden
17261726

1727-
# deprecate writecsv
1728-
@deprecate writecsv(io, a; opts...) writedlm(io, a, ','; opts...)
1729-
17301727
# PR #23271
17311728
function IOContext(io::IO; kws...)
17321729
depwarn("IOContext(io, k=v, ...) is deprecated, use IOContext(io, :k => v, ...) instead.", :IOContext)
17331730
IOContext(io, (k=>v for (k, v) in kws)...)
17341731
end
17351732

1736-
# deprecate readcsv
1737-
@deprecate readcsv(io; opts...) readdlm(io, ','; opts...)
1738-
@deprecate readcsv(io, T::Type; opts...) readdlm(io, ',', T; opts...)
1739-
17401733
@deprecate IOContext(io::IO, key, value) IOContext(io, key=>value)
17411734

17421735
# PR #23485

base/exports.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,7 +1047,6 @@ export
10471047
readbytes!,
10481048
readchomp,
10491049
readdir,
1050-
readdlm,
10511050
readline,
10521051
readlines,
10531052
readuntil,
@@ -1069,7 +1068,6 @@ export
10691068
unmark,
10701069
watch_file,
10711070
write,
1072-
writedlm,
10731071
TCPSocket,
10741072
UDPSocket,
10751073

base/io.jl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,3 +728,26 @@ function skipchars(io::IO, pred; linecomment=nothing)
728728
end
729729
return io
730730
end
731+
732+
"""
733+
countlines(io::IO, eol::Char='\\n')
734+
735+
Read `io` until the end of the stream/file and count the number of lines. To specify a file
736+
pass the filename as the first argument. EOL markers other than `'\\n'` are supported by
737+
passing them as the second argument.
738+
"""
739+
function countlines(io::IO, eol::Char='\n')
740+
isascii(eol) || throw(ArgumentError("only ASCII line terminators are supported"))
741+
aeol = UInt8(eol)
742+
a = Vector{UInt8}(8192)
743+
nl = 0
744+
while !eof(io)
745+
nb = readbytes!(io, a)
746+
@simd for i=1:nb
747+
@inbounds nl += a[i] == aeol
748+
end
749+
end
750+
nl
751+
end
752+
753+
countlines(f::AbstractString, eol::Char='\n') = open(io->countlines(io,eol), f)::Int

base/sysimg.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,6 @@ 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")

doc/src/stdlib/io-network.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Base.redirect_stdin(::Function, ::Any)
4747
Base.readchomp
4848
Base.truncate
4949
Base.skipchars
50-
Base.DataFmt.countlines
50+
Base.countlines
5151
Base.PipeBuffer
5252
Base.readavailable
5353
Base.IOContext
@@ -77,13 +77,6 @@ Base.readline
7777
Base.readuntil
7878
Base.readlines
7979
Base.eachline
80-
Base.DataFmt.readdlm(::Any, ::Char, ::Type, ::Char)
81-
Base.DataFmt.readdlm(::Any, ::Char, ::Char)
82-
Base.DataFmt.readdlm(::Any, ::Char, ::Type)
83-
Base.DataFmt.readdlm(::Any, ::Char)
84-
Base.DataFmt.readdlm(::Any, ::Type)
85-
Base.DataFmt.readdlm(::Any)
86-
Base.DataFmt.writedlm
8780
Base.Base64.Base64EncodePipe
8881
Base.Base64.Base64DecodePipe
8982
Base.Base64.base64encode

etc/juliarc.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# This file should contain site-specific commands to be executed on Julia startup
22
# Users may store their own personal commands in the user home directory `homedir()`, in a file named `.juliarc.jl`
33

4+
using DelimitedFiles

base/datafmt.jl renamed to stdlib/DelimitedFiles/src/DelimitedFiles.jl

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
# This file is a part of Julia. License is MIT: https://julialang.org/license
22

3-
## file formats ##
3+
__precompile__(true)
44

5-
module DataFmt
5+
module DelimitedFiles
66

77
import Base: _default_delims, tryparse_internal, show
88

9-
export countlines, readdlm, writedlm
9+
export readdlm, writedlm
10+
11+
Base.@deprecate readcsv(io; opts...) readdlm(io, ','; opts...)
12+
Base.@deprecate readcsv(io, T::Type; opts...) readdlm(io, ',', T; opts...)
13+
Base.@deprecate writecsv(io, a; opts...) writedlm(io, a, ','; opts...)
1014

1115
invalid_dlm(::Type{Char}) = reinterpret(Char, 0xfffffffe)
1216
invalid_dlm(::Type{UInt8}) = 0xfe
@@ -15,29 +19,6 @@ invalid_dlm(::Type{UInt32}) = 0xfffffffe
1519

1620
const offs_chunk_size = 5000
1721

18-
countlines(f::AbstractString, eol::Char='\n') = open(io->countlines(io,eol), f)::Int
19-
20-
"""
21-
countlines(io::IO, eol::Char='\\n')
22-
23-
Read `io` until the end of the stream/file and count the number of lines. To specify a file
24-
pass the filename as the first argument. EOL markers other than `'\\n'` are supported by
25-
passing them as the second argument.
26-
"""
27-
function countlines(io::IO, eol::Char='\n')
28-
isascii(eol) || throw(ArgumentError("only ASCII line terminators are supported"))
29-
aeol = UInt8(eol)
30-
a = Vector{UInt8}(8192)
31-
nl = 0
32-
while !eof(io)
33-
nb = readbytes!(io, a)
34-
@simd for i=1:nb
35-
@inbounds nl += a[i] == aeol
36-
end
37-
end
38-
nl
39-
end
40-
4122
"""
4223
readdlm(source, T::Type; options...)
4324
@@ -698,4 +679,4 @@ writedlm(io, a; opts...) = writedlm(io, a, '\t'; opts...)
698679
show(io::IO, ::MIME"text/csv", a) = writedlm(io, a, ',')
699680
show(io::IO, ::MIME"text/tab-separated-values", a) = writedlm(io, a, '\t')
700681

701-
end # module DataFmt
682+
end # module DelimitedFiles

test/datafmt.jl renamed to stdlib/DelimitedFiles/test/runtests.jl

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,7 @@
11
# This file is a part of Julia. License is MIT: https://julialang.org/license
22

3-
@testset "countlines" begin
4-
@test countlines(IOBuffer("\n")) == 1
5-
@test countlines(IOBuffer("\n"),'\r') == 0
6-
@test countlines(IOBuffer("\n\n\n\n\n\n\n\n\n\n")) == 10
7-
@test countlines(IOBuffer("\n \n \n \n \n \n \n \n \n \n")) == 10
8-
@test countlines(IOBuffer("\r\n \r\n \r\n \r\n \r\n")) == 5
9-
file = tempname()
10-
write(file,"Spiffy header\nspectacular first row\neven better 2nd row\nalmost done\n")
11-
@test countlines(file) == 4
12-
@test countlines(file,'\r') == 0
13-
@test countlines(file,'\n') == 4
14-
rm(file)
15-
end
3+
using Base.Test
4+
using DelimitedFiles
165

176
isequaldlm(m1, m2, t) = isequal(m1, m2) && (eltype(m1) == eltype(m2) == t)
187

@@ -295,3 +284,9 @@ end
295284

296285
# issue #11484: useful error message for invalid readdlm filepath arguments
297286
@test_throws ArgumentError readdlm(tempdir())
287+
288+
# displaying as text/csv
289+
let d = TextDisplay(IOBuffer())
290+
display(d, "text/csv", [3 1 4])
291+
@test String(take!(d.io)) == "3,1,4\n"
292+
end

test/choosetests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function choosetests(choices = [])
3232
"bigfloat", "sorting", "statistics", "spawn", "backtrace",
3333
"file", "read", "mmap", "version", "resolve",
3434
"pollfd", "mpfr", "broadcast", "complex", "socket",
35-
"floatapprox", "datafmt", "reflection", "regex", "float16",
35+
"floatapprox", "stdlib", "reflection", "regex", "float16",
3636
"combinatorics", "sysinfo", "env", "rounding", "ranges", "mod2pi",
3737
"euler", "show", "lineedit", "replcompletions", "repl",
3838
"replutil", "sets", "test", "goto", "llvmcall", "llvmcall2", "grisu",

0 commit comments

Comments
 (0)