Skip to content

Commit 89cd2f1

Browse files
authored
Merge pull request #4 from davidanthoff/julia-0.7
Update to julia 0.7
2 parents 7dfe449 + fc9a42c commit 89cd2f1

File tree

13 files changed

+94
-73
lines changed

13 files changed

+94
-73
lines changed

.travis.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,11 @@ os:
55
- osx
66
julia:
77
- 0.6
8+
- 0.7
89
- nightly
910
notifications:
1011
email: false
1112
matrix:
1213
fast_finish: true
13-
allow_failures:
14-
- julia: nightly
15-
script:
16-
- if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
17-
- julia -e 'Pkg.init(); Pkg.clone(pwd()); Pkg.test("FilePathsBase"; coverage=true)'
1814
after_success:
1915
- julia -e 'cd(Pkg.dir("FilePathsBase")); Pkg.add("Coverage"); using Coverage; Codecov.submit(process_folder())'

REQUIRE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
julia 0.6
2-
Compat 0.17.0
2+
Compat 1.0.0

appveyor.yml

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
11
environment:
22
matrix:
3-
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.6/julia-0.6-latest-win32.exe"
4-
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.6/julia-0.6-latest-win64.exe"
3+
- julia_version: 0.6
4+
- julia_version: 0.7
5+
- julia_version: latest
6+
7+
platform:
8+
- x86
9+
- x64
10+
11+
## uncomment the following lines to allow failures on nightly julia
12+
## (tests will run but not make your overall status red)
13+
#matrix:
14+
# allow_failures:
15+
# - julia_version: latest
516

617
branches:
718
only:
@@ -15,21 +26,12 @@ notifications:
1526
on_build_status_changed: false
1627

1728
install:
18-
- ps: "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12"
19-
# Download most recent Julia Windows binary
20-
- ps: (new-object net.webclient).DownloadFile(
21-
$env:JULIA_URL,
22-
"C:\projects\julia-binary.exe")
23-
# Run installer silently, output to C:\projects\julia
24-
- C:\projects\julia-binary.exe /S /D=C:\projects\julia
29+
- ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/JuliaCI/Appveyor.jl/master/bin/install.ps1'))
2530

2631
build_script:
27-
# Need to convert from shallow to complete for Pkg.clone to work
28-
- IF EXIST .git\shallow (git fetch --unshallow)
29-
- C:\projects\julia\bin\julia -e "Pkg.clone(pwd(), \"FilePathsBase\"); versioninfo(); Pkg.build(\"FilePathsBase\")"
32+
- echo "%JL_BUILD_SCRIPT%"
33+
- julia -e "%JL_BUILD_SCRIPT%"
3034

3135
test_script:
32-
- C:\projects\julia\bin\julia --check-bounds=yes -e "Pkg.test(\"FilePathsBase\", coverage=true)"
33-
34-
after_test:
35-
- C:\projects\julia\bin\julia -e "cd(Pkg.dir(\"FilePathsBase\")); Pkg.add(\"Coverage\"); using Coverage; Codecov.submit(Codecov.process_folder())"
36+
- echo "%JL_TEST_SCRIPT%"
37+
- julia -e "%JL_TEST_SCRIPT%"

src/FilePathsBase.jl

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ module FilePathsBase
44

55
using Compat
66

7+
using Compat.Printf, Compat.LinearAlgebra, Compat.Dates
8+
79
import Base: ==
810
export
911
# Types
@@ -60,11 +62,16 @@ else
6062
export isexecutable
6163
end
6264

63-
@compat abstract type AbstractPath <: AbstractString end
65+
abstract type AbstractPath <: AbstractString end
6466

6567
# Required methods for subtype of AbstractString
66-
Base.endof(p::AbstractPath) = endof(String(p))
67-
Base.next(p::AbstractPath, i::Int) = next(String(p), i)
68+
Compat.lastindex(p::AbstractPath) = lastindex(String(p))
69+
if VERSION >= v"0.7-"
70+
Base.iterate(p::AbstractPath) = iterate(String(p))
71+
Base.iterate(p::AbstractPath, state::Int) = iterate(String(p), state)
72+
else
73+
Base.next(p::AbstractPath, i::Int) = next(String(p), i)
74+
end
6875

6976
# The following should be implemented in the concrete types
7077
Base.String(path::AbstractPath) = error("`String not implemented")

src/libc.jl

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
@static if is_apple()
2-
immutable Cpasswd
1+
@static if Compat.Sys.isapple()
2+
struct Cpasswd
33
pw_name::Cstring
44
pw_passwd::Cstring
55
pw_uid::Cint
@@ -12,8 +12,8 @@
1212
pw_expire::Cint
1313
pw_fields::Cint
1414
end
15-
elseif is_linux()
16-
immutable Cpasswd
15+
elseif Compat.Sys.islinux()
16+
struct Cpasswd
1717
pw_name::Cstring
1818
pw_passwd::Cstring
1919
pw_uid::Cint
@@ -23,7 +23,7 @@ elseif is_linux()
2323
pw_shell::Cstring
2424
end
2525
else
26-
immutable Cpasswd
26+
struct Cpasswd
2727
pw_name::Cstring
2828
pw_uid::Cint
2929
pw_gid::Cint
@@ -34,15 +34,15 @@ else
3434
Cpasswd() = Cpasswd(pointer("NA"), 0, 0, pointer("NA"), pointer("NA"))
3535
end
3636

37-
immutable Cgroup
37+
struct Cgroup
3838
gr_name::Cstring
3939
gr_passwd::Cstring
4040
gr_gid::Cint
4141
end
4242

4343
Cgroup() = Cgroup(pointer("NA"), pointer("NA"), 0)
4444

45-
immutable User
45+
struct User
4646
name::String
4747
uid::UInt64
4848
gid::UInt64
@@ -67,8 +67,8 @@ function Base.show(io::IO, user::User)
6767
end
6868

6969
function User(name::String)
70-
ps = @static if is_unix()
71-
ccall((:getpwnam, "libc"), Ptr{Cpasswd}, (Ptr{UInt8},), name)
70+
ps = @static if Compat.Sys.isunix()
71+
ccall(:getpwnam, Ptr{Cpasswd}, (Ptr{UInt8},), name)
7272
else
7373
Cpasswd()
7474
end
@@ -77,8 +77,8 @@ function User(name::String)
7777
end
7878

7979
function User(uid::UInt)
80-
ps = @static if is_unix()
81-
ccall((:getpwuid, "libc"), Ptr{Cpasswd}, (UInt64,), uid)
80+
ps = @static if Compat.Sys.isunix()
81+
ccall(:getpwuid, Ptr{Cpasswd}, (UInt64,), uid)
8282
else
8383
Cpasswd()
8484
end
@@ -87,11 +87,11 @@ function User(uid::UInt)
8787
end
8888

8989
function User()
90-
uid = @static is_unix() ? ccall((:geteuid, "libc"), Cint, ()) : 0
90+
uid = @static Compat.Sys.isunix() ? ccall(:geteuid, Cint, ()) : 0
9191
User(UInt64(uid))
9292
end
9393

94-
immutable Group
94+
struct Group
9595
name::String
9696
gid::UInt64
9797

@@ -105,8 +105,8 @@ function Base.show(io::IO, group::Group)
105105
end
106106

107107
function Group(name::String)
108-
ps = @static if is_unix()
109-
ccall((:getgrnam, "libc"), Ptr{Cgroup}, (Ptr{UInt8},), name)
108+
ps = @static if Compat.Sys.isunix()
109+
ccall(:getgrnam, Ptr{Cgroup}, (Ptr{UInt8},), name)
110110
else
111111
Cgroup()
112112
end
@@ -115,8 +115,8 @@ function Group(name::String)
115115
end
116116

117117
function Group(gid::UInt)
118-
gr = @static if is_unix()
119-
ccall((:getgrgid, "libc"), Ptr{Cgroup}, (UInt64,), gid)
118+
gr = @static if Compat.Sys.isunix()
119+
ccall(:getgrgid, Ptr{Cgroup}, (UInt64,), gid)
120120
else
121121
Cgroup()
122122
end
@@ -125,6 +125,6 @@ function Group(gid::UInt)
125125
end
126126

127127
function Group()
128-
gid = @static is_unix() ? ccall((:getegid, "libc"), Cint, ()) : 0
128+
gid = @static Compat.Sys.isunix() ? ccall(:getegid, Cint, ()) : 0
129129
Group(UInt64(gid))
130130
end

src/mode.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ constants have been translated from cpython's Lib/stat.py file.
99
1010
https://github.com/python/cpython/blob/master/Lib/stat.py
1111
"""
12-
immutable Mode
12+
struct Mode
1313
m::UInt64
1414
end
1515

src/path.jl

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
Responsible for creating the appropriate platform specific path
88
(e.g., `PosixPath` and `WindowsPath` for Unix and Windows systems respectively)
99
"""
10-
Path() = @static is_unix() ? PosixPath() : WindowsPath()
10+
Path() = @static Compat.Sys.isunix() ? PosixPath() : WindowsPath()
1111
Path(path::AbstractPath) = path
12-
Path(pieces::Tuple) = @static is_unix() ? PosixPath(pieces) : WindowsPath(pieces)
13-
Path(str::AbstractString) = @static is_unix() ? PosixPath(str) : WindowsPath(str)
12+
Path(pieces::Tuple) = @static Compat.Sys.isunix() ? PosixPath(pieces) : WindowsPath(pieces)
13+
Path(str::AbstractString) = @static Compat.Sys.isunix() ? PosixPath(str) : WindowsPath(str)
1414

1515
"""
1616
@p_str -> Path
@@ -35,7 +35,12 @@ of the file containing the macro. Returns an empty Path if run from a REPL or
3535
if evaluated by julia -e <expr>.
3636
"""
3737
macro __PATH__()
38-
:(Path(@__DIR__()===nothing ? Path() : @__DIR__))
38+
if VERSION >= v"0.7-"
39+
p = Path(dirname(string(__source__.file)))
40+
return p===nothing ? :(Path()) : :($p)
41+
else
42+
return :(Path(@__DIR__()===nothing ? Path() : @__DIR__))
43+
end
3944
end
4045

4146
"""
@@ -46,7 +51,12 @@ containing the macro. Returns an empty Path if run from a REPL or if
4651
evaluated by julia -e <expr>.
4752
"""
4853
macro __FILEPATH__()
49-
:(Path(@__FILE__()===nothing ? Path() : @__FILE__))
54+
if VERSION >= v"0.7-"
55+
p = Path(string(__source__.file))
56+
return p===nothing ? :(Path()) : :($p)
57+
else
58+
return :(Path(@__FILE__()===nothing ? Path() : @__FILE__))
59+
end
5060
end
5161

5262
"""
@@ -56,7 +66,12 @@ Construct an absolute path to `filespec` relative to the source file
5666
containing the macro call.
5767
"""
5868
macro LOCAL(filespec)
59-
:(join(@__PATH__, Path($(esc(filespec)))))
69+
if VERSION >= v"0.7-"
70+
p = join(Path(dirname(string(__source__.file))), Path(filespec))
71+
return :($p)
72+
else
73+
return :(join(@__PATH__, Path($(esc(filespec)))))
74+
end
6075
end
6176

6277
#=
@@ -103,7 +118,7 @@ julia> parents(p"~/.julia/v0.6/REQUIRE")
103118
# Throws
104119
* `ErrorException`: if `path` doesn't have a parent
105120
"""
106-
function parents{T<:AbstractPath}(path::T)
121+
function parents(path::T) where {T <: AbstractPath}
107122
if hasparent(path)
108123
return map(1:length(parts(path))-1) do i
109124
T(parts(path)[1:i])
@@ -228,7 +243,7 @@ Base.real(path::AbstractPath) = Path(realpath(String(path)))
228243
229244
Normalizes a path by removing "." and ".." entries.
230245
"""
231-
function Base.norm{T<:AbstractPath}(path::T)
246+
function Compat.LinearAlgebra.norm(path::T) where {T <: AbstractPath}
232247
p = parts(path)
233248
result = String[]
234249
rem = length(p)
@@ -275,7 +290,7 @@ end
275290
276291
Creates a relative path from either the current directory or an arbitrary start directory.
277292
"""
278-
function relative{T<:AbstractPath}(path::T, start::T=T("."))
293+
function relative(path::T, start::T=T(".")) where {T <: AbstractPath}
279294
curdir = "."
280295
pardir = ".."
281296

@@ -287,7 +302,7 @@ function relative{T<:AbstractPath}(path::T, start::T=T("."))
287302
i = 0
288303
while i < min(length(p), length(s))
289304
i += 1
290-
@static if is_windows()
305+
@static if Compat.Sys.iswindows()
291306
if lowercase(p[i]) != lowercase(s[i])
292307
i -= 1
293308
break
@@ -450,7 +465,7 @@ function Base.mkdir(path::AbstractPath; mode=0o777, recursive=false, exist_ok=fa
450465
!exist_ok && error("$path already exists.")
451466
else
452467
if !hasparent(path) || exists(parent(path))
453-
mkdir(String(path), mode)
468+
VERSION >= v"0.7-" ? mkdir(String(path), mode=mode) : mkdir(String(path), mode)
454469
elseif hasparent(path) && !exists(parent(path)) && recursive
455470
mkdir(parent(path); mode=mode, recursive=recursive, exist_ok=exist_ok)
456471
else
@@ -522,8 +537,8 @@ function move(src::AbstractPath, dest::AbstractPath; recursive=false, exist_ok=f
522537
end
523538
end
524539

525-
function Base.cp(src::AbstractPath, dest::AbstractPath; remove_destination::Bool=false, follow_symlinks::Bool=false)
526-
cp(String(src), String(dest); remove_destination=remove_destination, follow_symlinks=follow_symlinks)
540+
function Base.cp(src::AbstractPath, dest::AbstractPath; force::Bool=false, follow_symlinks::Bool=false)
541+
Compat.cp(String(src), String(dest); force=force, follow_symlinks=follow_symlinks)
527542
end
528543

529544
remove(path::AbstractPath; recursive=false) = rm(String(path); recursive=recursive)
@@ -564,7 +579,7 @@ end
564579
Change the `user` and `group` of the `path`.
565580
"""
566581
function Base.chown(path::AbstractPath, user::AbstractString, group::AbstractString; recursive=false)
567-
@static if is_unix()
582+
@static if Compat.Sys.isunix()
568583
chown_cmd = String["chown"]
569584
if recursive
570585
push!(chown_cmd, "-R")

src/posix.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
immutable PosixPath <: AbstractPath
1+
struct PosixPath <: AbstractPath
22
parts::Tuple
33
end
44

src/status.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
using Base.Dates
1+
using Compat.Dates
22

33
import Base.Filesystem: StatStruct
44

5-
immutable Status
5+
struct Status
66
device::UInt64
77
inode::UInt64
88
mode::Mode

src/windows.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
immutable WindowsPath <: AbstractPath
1+
struct WindowsPath <: AbstractPath
22
parts::Tuple{Vararg{String}}
33
drive::String
44
root::String
@@ -14,7 +14,7 @@ WindowsPath() = WindowsPath(tuple(), "", "")
1414
function WindowsPath(parts::Tuple)
1515
if parts[1]==WIN_PATH_SEPARATOR
1616
return WindowsPath(parts, "", WIN_PATH_SEPARATOR)
17-
elseif contains(parts[1], ":")
17+
elseif occursin(":", parts[1])
1818
l_drive, l_path = _win_splitdrive(parts[1])
1919
return WindowsPath(parts, l_drive, l_path)
2020
else
@@ -31,15 +31,15 @@ function WindowsPath(str::AbstractString)
3131
error("The \\\\?\\ prefix is currently not supported.")
3232
end
3333

34-
str = replace(str, POSIX_PATH_SEPARATOR, WIN_PATH_SEPARATOR)
34+
str = replace(str, POSIX_PATH_SEPARATOR => WIN_PATH_SEPARATOR)
3535

3636
if startswith(str, "\\\\")
3737
error("UNC paths are currently not supported.")
3838
elseif startswith(str, "\\")
3939
tokenized = split(str, WIN_PATH_SEPARATOR)
4040

4141
return WindowsPath(tuple(WIN_PATH_SEPARATOR, String.(tokenized[2:end])...), "", WIN_PATH_SEPARATOR)
42-
elseif contains(str, ":")
42+
elseif occursin(":", str)
4343
l_drive, l_path = _win_splitdrive(str)
4444

4545
tokenized = split(l_path, WIN_PATH_SEPARATOR)
@@ -75,7 +75,7 @@ root(path::WindowsPath) = path.root
7575
function Base.show(io::IO, path::WindowsPath)
7676
print(io, "p\"")
7777
if isabs(path)
78-
print(io, replace(anchor(path), "\\", "/"))
78+
print(io, replace(anchor(path), "\\" => "/"))
7979
print(io, join(parts(path)[2:end], "/"))
8080
else
8181
print(io, join(parts(path), "/"))

0 commit comments

Comments
 (0)