invenia / Intervals.jl

Non-iterable ranges
MIT License
35 stars 18 forks source link

Transitive dependencies on TimeZones.jl #184

Open johnbcoughlin opened 2 years ago

johnbcoughlin commented 2 years ago

I was surprised to note that TimeZones was added as a dependency of my project after adding SpecialPolynomials. The dependency graph is through this package, Intervals.jl. The TimeZones library is rather heavy, and brings in multiple dependencies of its own.

It would be preferable if math-only libraries which have no need for date arithmetic didn't have to depend on the entire IANA TZ database. What I propose is hiding the TimeZones dependency behind a Requires.jl @requires block, like so:

function __init__()
    @require TimeZones = "f269a46b-ccf7-5d73-abea-4c690281aa53" include("timezones.jl")
end

where timezones.jl would include all of the TimeZones-specific methods (there are six such methods).

Other options:

The easiest is the Requires.jl option. I already have tests passing that way, so let me know if a PR is welcome.

Note that all of the above also goes for the dependency on Dates -- that's not so heavy because it's in the stdlib, but if I were benevolent dictator for life of this package, I would make that dependency optional as well.

Thanks!

oxinabox commented 2 years ago

Not relevent to you in this case as you have already swapped to IntervalSets.jl

We could use Requires.jl to make it an optionally loaded dependency, so that the code isn't loaded. But we can't remove it from the Project.toml as otherwise we are unable to specify what semver version is compatible with. Which is unsafe. The real resolution is https://github.com/JuliaLang/Pkg.jl/issues/1285

But we might we be to do, as you say is just remove those methods entirely. These ones: https://github.com/invenia/Intervals.jl/blob/f873f70950c14dc9da9f6e0aa8cdbc22c801400a/src/anchoredinterval.jl#L387-L393 https://github.com/invenia/Intervals.jl/blob/a785b56ce5e0091928fbb152bd2aa4834ada00d4/src/interval.jl#L483-L492 don't really seem idoiomatic julia in the first place. Since they are kind of like implict broadcasting (removed in julia 1.5) -- not exactly the same. The timezone of an interval IMO should be found out by asking about time timezone of the endpoints (or the anchor), and set similarly. I always forget you can do that. I don't think we do that anywhere in our internal codebase