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

WIP: Support for weak dependencies #3216

Closed
wants to merge 9 commits into from
Closed

WIP: Support for weak dependencies #3216

wants to merge 9 commits into from

Conversation

KristofferC
Copy link
Member

@KristofferC KristofferC commented Oct 4, 2022

@KristofferC KristofferC changed the title Support for weak dependencies WIP: Support for weak dependencies Oct 4, 2022
It is sometimes desirable to be able to extend some functionality of a package without having to
unconditionally take on the cost (in terms of e.g. load time) of adding an extra dependency.
A *weak* dependency is a package that is only available to load if some other package in the
current environment have that package as a normal (or strong) dependency.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
current environment have that package as a normal (or strong) dependency.
current environment has that package as a normal (or strong) dependency.


Weak dependencies are listed in a `Project.toml` file under the `[weakdeps]` section which can be compared to a
(strong) dependency which is under the `[deps]` section.
Compatibility on weak dependencies are specified like a normal dependeny unde the ´[compat]` section.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Compatibility on weak dependencies are specified like a normal dependeny unde the ´[compat]` section.
Compatibility on weak dependencies are specified like a normal dependency under the `[compat]` section.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, the current docs are still very WIP.


if Base.@hasdep Contour
using Contour
function plot(c::Contour.ContourCollection
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
function plot(c::Contour.ContourCollection
function plot(c::Contour.ContourCollection)

## Compatibility with older Julia versions.

It is possible to have a dependency be a weak version in Julia versions that support it and be a strong dependency in earlier
Julia versions. This is done by having the dependency as *both* a strong and weak dependency. Older Julia version will ignore
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Julia versions. This is done by having the dependency as *both* a strong and weak dependency. Older Julia version will ignore
Julia versions. This is done by having the dependency as *both* a strong and weak dependency. Older Julia versions will ignore


It is possible to have a dependency be a weak version in Julia versions that support it and be a strong dependency in earlier
Julia versions. This is done by having the dependency as *both* a strong and weak dependency. Older Julia version will ignore
the specificaton of the depenency as weak while new Julia versions will tag it as a weak dependency.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
the specificaton of the depenency as weak while new Julia versions will tag it as a weak dependency.
the specification of the dependency as weak while new Julia versions will tag it as a weak dependency.


if !isdefined(Base, :hasdep) || Base.hasdep(@__MODULE__, :Contour)
using Contour
function plot(c::Contour.ContourCollection
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
function plot(c::Contour.ContourCollection
function plot(c::Contour.ContourCollection)

old_num_promoted = count(in(old_uuids), weak_uuids)
new_num_promoted = count(in(new_uuids), weak_uuids)

# @show pkgentry pkgentry.weakdeps old_uuids new_uuids new_num_promoted old_num_promoted
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# @show pkgentry pkgentry.weakdeps old_uuids new_uuids new_num_promoted old_num_promoted

@KristofferC KristofferC force-pushed the kc/weak_deps branch 2 times, most recently from 6b6d479 to 9d7a180 Compare October 4, 2022 12:30
@IanButterworth
Copy link
Member

Closing because package extensions won #3264

@IanButterworth IanButterworth deleted the kc/weak_deps branch January 2, 2023 23:15
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.

3 participants