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

Wrap everything in a version check #21

Merged
merged 5 commits into from
Jul 20, 2017
Merged

Wrap everything in a version check #21

merged 5 commits into from
Jul 20, 2017

Conversation

ararslan
Copy link
Member

@ararslan ararslan commented Jul 6, 2017

The diff looks a little weird, but this just wraps the contents of src/FFTW.jl with

if VERSION < v"0.7.0-DEV.602"
    import Base.FFTW
else
    # do everything that was here before
end

@ararslan ararslan requested a review from stevengj July 6, 2017 19:08
@stevengj
Copy link
Member

stevengj commented Jul 6, 2017

This still defines a module FFTW; import Base.FFTW; end in 0.6, which seems weird/wrong to me.

My thinking was that the entire FFTW.jl file should just consist of import Base.FFTW (one line ... no module or precompile directive) in 0.6 (via a versioned REQUIRE file ... I don't think it's worth worrying about older versions of 0.7-dev).

@giordano
Copy link
Member

giordano commented Jul 6, 2017

Yes, I was thinking about branching the package and keeping an (almost) empty package just for Julia 0.6.

@stevengj
Copy link
Member

stevengj commented Jul 6, 2017

I guess you could also do:

if VERSION < ....
    import Base.FFTW
else
    __precompile__(true)
    module FFTW
        ....
    end
end

if you don't want to mess with multiple branches/versions of REQUIRE.

@stevengj
Copy link
Member

stevengj commented Jul 6, 2017

Or perhaps

if VERSION < ....
    import Base.FFTW
else
    include("src.jl") # defines module FFTW
end

so that 0.6 doesn't pay the price of parsing the whole module FFTW ... end (nor does it need precompilation/caches).

(This way the diff will also be small, since you will just do git mv FFTW.jl src.jl on the old FFTW.jl file. And much easier than branching the package.)

@ararslan ararslan force-pushed the aa/ugh-oh-my-god branch 7 times, most recently from daba494 to 8ebc2a3 Compare July 6, 2017 23:23
@ararslan
Copy link
Member Author

ararslan commented Jul 6, 2017

The fact that wrapping the AbstractFFTs imports was necessary is a little concerning. Perhaps we need to do something similar there but with Base.DFT?

test/runtests.jl Outdated
importall FFTW
import AbstractFFTs: Plan, fft, ifft, bfft, fft!, ifft!, bfft!,
if VERSION >= v"0.7.0-DEV.602"
import AbstractFFTs: Plan, fft, ifft, bfft, fft!, ifft!, bfft!,
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't using AbstractFFTs be enough here?

Copy link
Member

Choose a reason for hiding this comment

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

(except for Plan)

Copy link
Member Author

Choose a reason for hiding this comment

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

No, to avoid name conflicts, AbstractFFTs only exports things if none of the functions are defined in Base. So using AbstractFFTs won't import anything into Main until after the deprecation period.

Copy link
Member

@stevengj stevengj Jul 7, 2017

Choose a reason for hiding this comment

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

That's really annoying. I feel like we should make it possible to override a deprecated binding without a warning (precisely for things like this … it's going to be a continual annoyance to move things out of Base otherwise)

cc @JeffBezanson

Copy link
Member Author

Choose a reason for hiding this comment

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

It's the same thing we did with Primes and continue to do with SpecialFunctions, QuadGK, the priority queue stuff in DataStructures, etc. It's certainly not ideal. Being able to do that would make it easier to fully support multiple versions at once.

Copy link
Member

@stevengj stevengj Jul 11, 2017

Choose a reason for hiding this comment

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

And actually, it seems that @deprecate doesn't call deprecate either.... only @deprecate_binding uses it. (This seems correct: @deprecate may not deprecate a whole function: it may only deprecate certain methods.)

Copy link
Member Author

Choose a reason for hiding this comment

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

Is it actually legit to deprecate in Main though? What happens to packages then?

Copy link
Member

Choose a reason for hiding this comment

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

Oh, sorry, the code above relied on patching Julia as well to check for the deprecation before emitting a warning message:

--- a/src/module.c
+++ b/src/module.c
@@ -190,7 +190,7 @@ static jl_binding_t *jl_get_binding_(jl_module_t *m, jl_sym_t *var, modstack_t *
                 if (tempb == NULL || tempb->owner == NULL)
                     // couldn't resolve; try next using (see issue #6105)
                     continue;
-                if (owner != NULL && tempb->owner != b->owner &&
+                if (owner != NULL && tempb->owner != b->owner && !tempb->deprecated &&
                     !(tempb->constp && tempb->value && b->constp && b->value == tempb->value)) {
                     jl_printf(JL_STDERR,
                               "WARNING: both %s and %s export \"%s\"; uses of it in module %s must be qualified\n",

Copy link
Member

Choose a reason for hiding this comment

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

Hopefully I'll have a PR for Julia shortly.

Copy link
Member Author

Choose a reason for hiding this comment

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

That would be awesome!

test/runtests.jl Outdated
fftshift, ifftshift, plan_inv
import FFTW: fftw_vendor
else
import Base.DFT: Plan, fft, ifft, bfft, fft!, ifft!, bfft!,
plan_fft, plan_ifft, plan_bfft, plan_fft!, plan_ifft!, plan_bfft!,
Copy link
Member

Choose a reason for hiding this comment

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

I'm confused, why do you need to import plan_fft in 0.6, since that is already exported? The only thing here that is not exported in 0.6 is Plan.

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 just copied and pasted, but originally I had tried with just Plan but there was something else it was getting mad about (can't recall what it was offhand, plan_ something or other)

end

# MKL provides its own FFTW
fftw_vendor() = Base.BLAS.vendor() === :mkl ? :mkl : :fftw
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this function just be called vendor(), with a qualified name of FFTW.vendor() analogous to BLAS.vendor()?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. The name is a carryover from Base.

Copy link
Member

Choose a reason for hiding this comment

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

with a @deprecate fftw_vendor definition, of course.

Copy link
Member Author

Choose a reason for hiding this comment

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

Right

@timholy
Copy link
Member

timholy commented Jul 13, 2017

I tried Pkg.checkout("FFTW", "aa/ugh-oh-my-god") (love the branch name!), but that doesn't fix FFTViews, sadly.

@timholy
Copy link
Member

timholy commented Jul 13, 2017

Can fix it by changing FFTW.fft to Main.FFTW.fft.

@ararslan
Copy link
Member Author

I think that gets back to the fact that neither this package nor AbstractFFTs exports anything when the names are defined in Base...

@ararslan ararslan force-pushed the aa/ugh-oh-my-god branch 2 times, most recently from 03c299e to bab0bd6 Compare July 17, 2017 23:02
@ararslan
Copy link
Member Author

Since this gets things working on 0.6 I think we should just go ahead and merge this and I'll continue to try to get 0.7 working in separate PRs.

@ararslan
Copy link
Member Author

ararslan commented Jul 20, 2017

(Actually let's wait until Compat is fixed) (side note, I hate that I had to add Compat)

@ararslan
Copy link
Member Author

Actually the fix was wrong in Compat so this should be fine.

@ararslan ararslan merged commit 070cd89 into master Jul 20, 2017
@ararslan ararslan deleted the aa/ugh-oh-my-god branch July 20, 2017 19:37
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.

4 participants