Skip to content

Commit

Permalink
prototype approach to default packages; installing in site/
Browse files Browse the repository at this point in the history
as a demo, moves DataFmt out of Base. adds a line to default juliarc
so the functions are still available by default.
  • Loading branch information
JeffBezanson committed Sep 25, 2017
1 parent b2cbf31 commit 2581508
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 49 deletions.
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ 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_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/site $(build_man1dir))
ifneq ($(BUILDROOT),$(JULIAHOME))
BUILDDIRS := $(BUILDROOT) $(addprefix $(BUILDROOT)/,base src ui doc deps test test/perf examples examples/embedding)
BUILDDIRMAKE := $(addsuffix /Makefile,$(BUILDDIRS))
Expand Down Expand Up @@ -50,6 +50,11 @@ endif

$(foreach dir,$(DIRS),$(eval $(call dir_target,$(dir))))
$(foreach link,base test,$(eval $(call symlink_target,$(link),$(build_datarootdir)/julia)))
$(eval $(call symlink_target,stdlib,$(build_datarootdir)/julia/site))

build_defaultpkgdir = $(build_datarootdir)/julia/site/$(shell echo $(VERSDIR))
$(build_defaultpkgdir): $(build_datarootdir)/julia/site/stdlib
mv $(build_datarootdir)/julia/site/stdlib $@

julia_flisp.boot.inc.phony: julia-deps
@$(MAKE) $(QUIET_MAKE) -C $(BUILDROOT)/src julia_flisp.boot.inc.phony
Expand Down Expand Up @@ -81,7 +86,7 @@ ifndef JULIA_VAGRANT_BUILD
endif
endif

julia-deps: | $(DIRS) $(build_datarootdir)/julia/base $(build_datarootdir)/julia/test
julia-deps: | $(DIRS) $(build_datarootdir)/julia/base $(build_datarootdir)/julia/test $(build_defaultpkgdir)
@$(MAKE) $(QUIET_MAKE) -C $(BUILDROOT)/deps

julia-base: julia-deps $(build_sysconfdir)/julia/juliarc.jl $(build_man1dir)/julia.1 $(build_datarootdir)/julia/julia-config.jl
Expand Down
7 changes: 0 additions & 7 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1724,19 +1724,12 @@ import .LinAlg: diagm
@deprecate_binding φ MathConstants.φ
@deprecate_binding golden MathConstants.golden

# deprecate writecsv
@deprecate writecsv(io, a; opts...) writedlm(io, a, ','; opts...)

# PR #23271
function IOContext(io::IO; kws...)
depwarn("IOContext(io, k=v, ...) is deprecated, use IOContext(io, :k => v, ...) instead.", :IOContext)
IOContext(io, (k=>v for (k, v) in kws)...)
end

# deprecate readcsv
@deprecate readcsv(io; opts...) readdlm(io, ','; opts...)
@deprecate readcsv(io, T::Type; opts...) readdlm(io, ',', T; opts...)

@deprecate IOContext(io::IO, key, value) IOContext(io, key=>value)

# PR #23485
Expand Down
2 changes: 0 additions & 2 deletions base/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1047,7 +1047,6 @@ export
readbytes!,
readchomp,
readdir,
readdlm,
readline,
readlines,
readuntil,
Expand All @@ -1069,7 +1068,6 @@ export
unmark,
watch_file,
write,
writedlm,
TCPSocket,
UDPSocket,

Expand Down
23 changes: 23 additions & 0 deletions base/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -728,3 +728,26 @@ function skipchars(io::IO, pred; linecomment=nothing)
end
return io
end

"""
countlines(io::IO, eol::Char='\\n')
Read `io` until the end of the stream/file and count the number of lines. To specify a file
pass the filename as the first argument. EOL markers other than `'\\n'` are supported by
passing them as the second argument.
"""
function countlines(io::IO, eol::Char='\n')
isascii(eol) || throw(ArgumentError("only ASCII line terminators are supported"))
aeol = UInt8(eol)
a = Vector{UInt8}(8192)
nl = 0
while !eof(io)
nb = readbytes!(io, a)
@simd for i=1:nb
@inbounds nl += a[i] == aeol
end
end
nl
end

countlines(f::AbstractString, eol::Char='\n') = open(io->countlines(io,eol), f)::Int
2 changes: 0 additions & 2 deletions base/sysimg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,6 @@ include("mmap.jl")
import .Mmap

# utilities - timing, help, edit
include("datafmt.jl")
using .DataFmt
include("deepcopy.jl")
include("interactiveutil.jl")
include("summarysize.jl")
Expand Down
9 changes: 1 addition & 8 deletions doc/src/stdlib/io-network.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Base.redirect_stdin(::Function, ::Any)
Base.readchomp
Base.truncate
Base.skipchars
Base.DataFmt.countlines
Base.countlines
Base.PipeBuffer
Base.readavailable
Base.IOContext
Expand Down Expand Up @@ -77,13 +77,6 @@ Base.readline
Base.readuntil
Base.readlines
Base.eachline
Base.DataFmt.readdlm(::Any, ::Char, ::Type, ::Char)
Base.DataFmt.readdlm(::Any, ::Char, ::Char)
Base.DataFmt.readdlm(::Any, ::Char, ::Type)
Base.DataFmt.readdlm(::Any, ::Char)
Base.DataFmt.readdlm(::Any, ::Type)
Base.DataFmt.readdlm(::Any)
Base.DataFmt.writedlm
Base.Base64.Base64EncodePipe
Base.Base64.Base64DecodePipe
Base.Base64.base64encode
Expand Down
1 change: 1 addition & 0 deletions etc/juliarc.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# This file should contain site-specific commands to be executed on Julia startup
# Users may store their own personal commands in the user home directory `homedir()`, in a file named `.juliarc.jl`

using DelimitedFiles
35 changes: 8 additions & 27 deletions base/datafmt.jl → stdlib/DelimitedFiles/src/DelimitedFiles.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

## file formats ##
__precompile__(true)

module DataFmt
module DelimitedFiles

import Base: _default_delims, tryparse_internal, show

export countlines, readdlm, writedlm
export readdlm, writedlm

Base.@deprecate readcsv(io; opts...) readdlm(io, ','; opts...)
Base.@deprecate readcsv(io, T::Type; opts...) readdlm(io, ',', T; opts...)
Base.@deprecate writecsv(io, a; opts...) writedlm(io, a, ','; opts...)

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

const offs_chunk_size = 5000

countlines(f::AbstractString, eol::Char='\n') = open(io->countlines(io,eol), f)::Int

"""
countlines(io::IO, eol::Char='\\n')
Read `io` until the end of the stream/file and count the number of lines. To specify a file
pass the filename as the first argument. EOL markers other than `'\\n'` are supported by
passing them as the second argument.
"""
function countlines(io::IO, eol::Char='\n')
isascii(eol) || throw(ArgumentError("only ASCII line terminators are supported"))
aeol = UInt8(eol)
a = Vector{UInt8}(8192)
nl = 0
while !eof(io)
nb = readbytes!(io, a)
@simd for i=1:nb
@inbounds nl += a[i] == aeol
end
end
nl
end

"""
readdlm(source, T::Type; options...)
Expand Down Expand Up @@ -698,4 +679,4 @@ writedlm(io, a; opts...) = writedlm(io, a, '\t'; opts...)
show(io::IO, ::MIME"text/csv", a) = writedlm(io, a, ',')
show(io::IO, ::MIME"text/tab-separated-values", a) = writedlm(io, a, '\t')

end # module DataFmt
end # module DelimitedFiles
File renamed without changes.
2 changes: 1 addition & 1 deletion test/choosetests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function choosetests(choices = [])
"bigfloat", "sorting", "statistics", "spawn", "backtrace",
"file", "read", "mmap", "version", "resolve",
"pollfd", "mpfr", "broadcast", "complex", "socket",
"floatapprox", "datafmt", "reflection", "regex", "float16",
"floatapprox", "reflection", "regex", "float16",
"combinatorics", "sysinfo", "env", "rounding", "ranges", "mod2pi",
"euler", "show", "lineedit", "replcompletions", "repl",
"replutil", "sets", "test", "goto", "llvmcall", "llvmcall2", "grisu",
Expand Down

0 comments on commit 2581508

Please sign in to comment.