Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Julia v1.0 #282

Merged
merged 8 commits into from
Sep 7, 2018
Merged

Add support for Julia v1.0 #282

merged 8 commits into from
Sep 7, 2018

Conversation

tlnagy
Copy link
Member

@tlnagy tlnagy commented Apr 4, 2018

This finishes the Nullable{T} ==> Union{T, Nothing} transition started in #279. I decided that it wasn't worth using the Nullables.jl because it's a dead-end archive package and we might as well transition to the new representation of uninitialized values.

8dd674d is a temporary hack because LOAD_CACHE_PATH was deleted in v0.7. I only did this to get tests to pass locally on both v0.6 and v0.7 and I want to make sure CI passes. I'll revert this commit once an actual solution is found (see JuliaLang/Compat.jl#527) before merging

@codecov-io
Copy link

codecov-io commented Apr 4, 2018

Codecov Report

Merging #282 into master will increase coverage by 0.03%.
The diff coverage is 45.16%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #282      +/-   ##
==========================================
+ Coverage   34.69%   34.73%   +0.03%     
==========================================
  Files          17       17              
  Lines        2908     2908              
==========================================
+ Hits         1009     1010       +1     
+ Misses       1899     1898       -1
Impacted Files Coverage Δ
src/Compose.jl 6.09% <ø> (ø) ⬆️
src/table.jl 0% <ø> (ø) ⬆️
src/cairo_backends.jl 32.36% <0%> (+0.16%) ⬆️
src/measure.jl 36.36% <0%> (ø) ⬆️
src/batch.jl 9.58% <100%> (ø) ⬆️
src/pgf_backend.jl 40.96% <58.33%> (ø) ⬆️
src/container.jl 58.22% <75%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5a65bc4...4161200. Read the comment docs.

@bjarthur
Copy link
Member

do you want to try to finish this before we tag?

@tlnagy tlnagy closed this Apr 29, 2018
@tlnagy tlnagy reopened this Apr 29, 2018
@tlnagy
Copy link
Member Author

tlnagy commented Apr 29, 2018

The primary hang up is I'm waiting for JuliaGraphics/Cairo.jl#224 to be resolved. I think we should go ahead and tag. 0.7 support can wait.

@tlnagy
Copy link
Member Author

tlnagy commented Apr 29, 2018

It looks like tests are failing partially due to isinstalled breaking on 0.7

On 0.7

julia> include("src/Compose.jl")

## omitted errors

julia> Compose.isinstalled("Fontconfig")
true

On 0.6

julia> include("src/Compose.jl")
Compose

julia> Compose.isinstalled("Fontconfig")
false

Fontconfig isn't installed in either environment so something else must've broken on 0.7

@tlnagy
Copy link
Member Author

tlnagy commented Apr 29, 2018

It looks specifically that

ver == nothing && try
# Assume the version is new enough if the package is in LOAD_PATH
ex = Expr(:import, Symbol(pkg))
@eval $ex
return true
catch
return false
end

the @eval throws an ArgumentError on v0.6 and not on v0.7 so the catch clause isn't triggered on v0.7.

EDIT: Not sure why this is happening to asked Discourse

@vtjnash
Copy link

vtjnash commented Jul 10, 2018

The isinstalled logic should be replaced by Requires.jl (#226). Would be great to have this finished!

@tlnagy
Copy link
Member Author

tlnagy commented Jul 29, 2018

On @vtjnash's suggestion I started trying to get Requires.jl working, but I ran into some problems with Pkg.resolve since Compose does not have Cairo in its REQUIRE file. See JuliaPackaging/Requires.jl#52 for details.

@tlnagy
Copy link
Member Author

tlnagy commented Aug 17, 2018

Thanks to @RalphAS's help and with another round of cleanup, all tests pass on Julia v0.7 (NOTE: This is not backwards compatible due to the iteration protocol changes!). There are a couple silent deprecations that cause the build to crash on v1.0, which I have not yet fixed. Couple things remaining:

  • Fix silent 0.7 deprecations
  • Fix documentation building on v1.0 (looks like this is still in flux ATM)
  • Tag a release prior to merging this PR

@tlnagy tlnagy changed the title [WIP] More v0.7 fixes Add support for Julia v1.0 Aug 17, 2018
@tlnagy
Copy link
Member Author

tlnagy commented Aug 17, 2018

This PR now successfully passes tests on Julia v1.0

@tlnagy
Copy link
Member Author

tlnagy commented Aug 17, 2018

@bjarthur and @Mattriks, I think this is basically ready to go. All tests are passing and docs are building. We can get started on getting Gadfly up to speed.

@@ -369,8 +372,8 @@ end
function push_vector_properties(img::Image, idx::Int)
save_property_state(img)
for (propertytype, property) in img.vector_properties
isnull(property) && continue
primitives = get(property).primitives
(property === nothing) && continue
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the parens aren't necessary here, though they don't hurt

y = Array{Float64}(1)
ccall((:cairo_get_current_point, Cairo._jl_libcairo), Void,
(Ptr{Void}, Ptr{Float64}, Ptr{Float64}), img.ctx.ptr, x, y)
x = Array{Float64}(undef, 1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you know what the thinking is behind julia 1.0 requiring undef here? is there something else that could be supplied as the first argument?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the thinking is that we should be very clear that we're allocating uninitialized memory, i.e. that x contains junk values. Here's a thorough discussion: JuliaLang/julia#24595.

.travis.yml Outdated
- |
julia -e '
using Compose, Pkg
pkg"add Colors Documenter"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should Cairo be removed from docs/REQUIRE?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot about docs/REQUIRE so I could just load everything that is there or just delete it. Thoughts?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

loading everything that is there would be one less thing to remember to change if docs/REQUIRE were to change in future. the code to do that is already in master.

src/Compose.jl Outdated
@@ -204,6 +180,7 @@ try
getfield(Compose, :Cairo) # throws if Cairo isn't being used
show(io::IO, ::MIME"image/png", ctx::Context) =
draw(PNG(io, default_graphic_width, default_graphic_height), ctx)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could these three lines be added to cairo_backends.jl? seems better to conditionally include them via Requires.jl instead of a try/catch.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I'll move it.

:CairoPDFSurface, :CairoSVGSurface, :CairoImageSurface)
val = getfield(Cairo,name)
@eval const $name = $val
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the reason for the change here? does using Cairo: ... not work with Requires?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is from @RalphAS's original approach that worked on both v0.6 and v0.7, but I think we can revert it to the simpler case since we're dropping support for v0.6 going forward.

Copy link
Member

@bjarthur bjarthur Aug 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't understand why using Cairo: ... doesn't work on both 0.6 and 0.7...

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was previously written should work exactly as intended as far back as 0.3, if not earlier.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing this back leads to warnings (maybe @RalphAS can help us understand why?)

julia> using Compose
[ Info: Loading Cairo backend into Compose.jl
┌ Warning: Package Compose does not have Cairo in its dependencies:- If you have Compose checked out for development and have
│   added Cairo as a dependency but haven't updated your primary
│   environment's manifest file, try `Pkg.resolve()`.
│ - Otherwise you may need to report an issue with Compose
└ Loading Cairo into Compose from project dependency, future warnings for Compose are suppressed.

#global PDF
PNG(::Any, args...) = error(@missing_cairo_error "PNG")
PS(::Any, args...) = error(@missing_cairo_error "PS")
PDF(::Any, args...) = error(@missing_cairo_error "PDF")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could these three lines be simplified to PNG = error... ? none of the input args are actually used.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I had tried that originally and I was getting illegal constant redefinitions.

include("svg.jl")
include("pgf_backend.jl")

# If available, pango and fontconfig are used to compute text extents and match
# fonts. Otherwise a simplistic pure-julia fallback is used.

if isinstalled("Fontconfig")
include("fontfallback.jl")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to the extent that fontfallback.jl mimics pango well, we should really hype up the fact that Gadfly can generate SVG with pure julia. maybe add a comment in the Compose README or docs.

@bjarthur
Copy link
Member

looks great! thanks for working on this.

we should probably wait to tag a final julia 0.6 release of compose until we can do so simultaneously for gadfly.

once this merges i'll run the scripts to see what other gadfly dependencies are still not working on julia 0.7.

REQUIRE Outdated
@@ -1,7 +1,7 @@
julia 0.6
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should change this to 0.7 if it's not backwards compatible due to the new iteration protocol

@bjarthur
Copy link
Member

make sure to close #226 when this is merged

@tlnagy
Copy link
Member Author

tlnagy commented Sep 5, 2018

not sure whether the problem is in compose or gadfly. hard to track down without a stack trace.

Have you tried asking over on discourse? That's basically impossible to track down with so little info.

i wouldn't be adverse to merging the three relevant PRs and then advertising a gadfly beta on discourse for field testing before tagging a release for julia 0.7.

Agreed. While the regressions are worrisome, they aren't showstoppers. We need to at least have a beta at this point. I'm in favor of merging into master and then letting people take it for a spin.

@bjarthur
Copy link
Member

bjarthur commented Sep 7, 2018

the broadcast / Ref() warning is now fixed, and i believe all the regression errors are due to the change in Random. so... let's do this!

@Mattriks
Copy link
Member

Mattriks commented Sep 7, 2018

Note that there is a more general solution than wrapping things in Ref(). e.g. in Julia 0.7, the following results in the same error above:

using Measures
a = [1mm,2mm,4mm]
a .+ 1mm

but this will work after implementing:

Broadcast.broadcastable(x::T) where T<:Measure = Ref(x)

which makes things easier for general use.

tlnagy and others added 5 commits September 7, 2018 10:02
this is a follow up to #279

temp hack for missing load_cache_path on 0.7

See JuliaLang/Compat.jl#527 for details

replace more voids that slipped past the first round

more deprecation fixes

prelim work on adding optional runtime backend loading

use Compat's @info so we don't break v0.6
This version works if callers of PNG etc. import Cairo themselves.
update ci and doc gen; drop support for julia v0.6

allow failures on nightly
drop Compat.jl and vestigial compat layers

fixes for doc building and coverage

using is required to load pkg_str macro

fix for silly parenthesis error

drop 0.6 support and simplify travis config
@tlnagy
Copy link
Member Author

tlnagy commented Sep 7, 2018

I just squashed and rebased. This ready to merge.

We definitely need to resolve #282 (comment) soon, but I'm okay with this getting merged and the fix for that being a separate PR.

@simonschoelly identified this problem in
#282 (comment)
where calling show would lead to a stackoverflow error due to infinite
recursion. The solution is to explicitly invoke Base's abstract show
function when the non-compact form is requested to prevent the runaway
recursion.
@tlnagy
Copy link
Member Author

tlnagy commented Sep 7, 2018

b731974 fixes the problem identified by @simonschoelly so now printing works as expected in the noncompact/default case too.

@bjarthur
Copy link
Member

bjarthur commented Sep 7, 2018

@Mattriks care to submit a PR to Measures.jl with your solution? much better than mine!

@tlnagy
Copy link
Member Author

tlnagy commented Sep 7, 2018

AFAIK, this PR is ready to be merged. I've tried to address all points raised in the review.

@tlnagy
Copy link
Member Author

tlnagy commented Sep 7, 2018

Looks like there are no major objections so I'm going to go ahead and pull the trigger.

We should let 1.0 support stew on master for a week give or take and then tag a new release. This'll give people time to put it through its paces and make sure that everything is working well.

@tlnagy tlnagy merged commit 69be7b7 into master Sep 7, 2018
tlnagy added a commit to JuliaGraphics/Measures.jl that referenced this pull request Sep 7, 2018
tlnagy added a commit to JuliaGraphics/Measures.jl that referenced this pull request Sep 7, 2018
@tlnagy tlnagy deleted the tn/more-v07-fixes branch September 7, 2018 23:24
@tlnagy tlnagy mentioned this pull request Sep 8, 2018
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants