PackageExtensionCompat.jl

Makes Julia's package extensions backwards compatible
Author cjdoris
Popularity
50 Stars
Updated Last
9 Months Ago
Started In
January 2023

PackageExtensionCompat

Tests

Julia introduced package extensions in v1.9. This package makes these extensions backwards-compatible to earlier Julia versions, with zero overhead on new versions.

Internally, this uses Requires.jl on earlier versions, automating this strategy in the Pkg.jl docs.

Supports all versions of Julia from 1.0 upwards.

Usage

Supposing you have a package called Foo:

  1. Set up package extensions for Foo as usual. This means adding [weakdeps] and [extensions] to Project.toml and adding extension code to ext/.

  2. Add PackageExtensionCompat as a dependency to Foo.

  3. Add the following code to src/Foo.jl:

    using PackageExtensionCompat
    function __init__()
        @require_extensions
    end

That's it! Your package extensions will now be loaded as expected on any Julia version!

Example

See the example folder for an example package using this functionality.

Required Packages