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

[backports-release-1.11] Allow ext → ext dependency if triggers are a strict superset #56368

Merged

Conversation

topolarity
Copy link
Member

This is an effort at a proper workaround (feature?) to resolve #56204.

For example:

[extensions]
PlottingExt = "Plots"
StatisticsPlottingExt = ["Plots", "Statistics"]

Here StatisticsPlottingExt is allowed to depend on PlottingExt This provides a way to declare ext → ext dependencies while still avoiding any extension cycles. The same trick can also be used to make an extension in one package depend on an extension provided in another.

We'll also need to land #49891, so that we guarantee these load in the right order.

@penelopeysm
Copy link

penelopeysm commented Oct 28, 2024

Hello! Having this feature would be really great, I just wanted to add though that for our usecase Bijectors.jl would have one of its strong deps as an extension trigger, and (as I understand it) the following Pkg.jl issue needs to be resolved so that we can get it to work on 1.10 as well (this issue doesn't happen on 1.11, I haven't yet looked into why):

JuliaLang/Pkg.jl#4018

(Re. our usecase: there's more context here, but TLDR we want EnzymeChainRulesCoreExt to load before BijectorsEnzymeExt. The former depends on Enzyme and ChainRulesCore, so with your PR we would be able to get that to load first by declaring the latter's triggers to be ["Enzyme", "ChainRulesCore"]but ChainRulesCore is itself a strong dep of Bijectors.)

@topolarity
Copy link
Member Author

Thanks for the heads up! Yeah, you're right - this does mean that we need triggers from [deps] working properly..

That sounds like #54009, which wasn't backported to 1.10 (yet). I'm curious how @KristofferC would feel about a potential backport.

@KristofferC
Copy link
Member

I think it is fine to backport since it is arguably a bugfix.

keep_loaded_modules = false
if haskey(exts, pkg)
# any extension in our direct dependencies is one we have a right to load
loadable_exts = filter((dep)->haskey(exts, dep), depsmap[pkg])
Copy link
Member

@KristofferC KristofferC Oct 29, 2024

Choose a reason for hiding this comment

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

The set of loadable_exts has to be computed from the loading code, no? There is no guarantee that it is the parallel precompile code that precompiles the extension?

Copy link
Member Author

@topolarity topolarity Oct 29, 2024

Choose a reason for hiding this comment

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

Hmm, I think you're right.

In fact, it looks like it should have been computing isext already to avoid cycles but I think we missed that

base/precompilation.jl Outdated Show resolved Hide resolved
@topolarity
Copy link
Member Author

kron failure is due to a bad test on the 1.11 backports branch (#56388)

otherwise CI is looking green

@KristofferC
Copy link
Member

This adds no test, is the new behavior not observable or not worth testing? It seems to me that a setup like in #56204 (comment) which then checks that a get_extension calls succeeds could be useful?

@topolarity
Copy link
Member Author

Yeah, I've been waiting to add a test until #49891 lands - will follow up with that soon

@topolarity topolarity force-pushed the ct/ext-to-ext-dep branch 3 times, most recently from 1646cb3 to efbbab5 Compare October 30, 2024 16:34
This allows for one extension to depend on another if its triggers are
a strict superset of the other's. For example, in a Project.toml:

```toml
[extensions]
PlottingExt = "Plots"
StatisticsPlottingExt = ["Plots", "Statistics"]
```

Here `StatisticsPlottingExt` is allowed to depend on `PlottingExt`
This provides a way to declare `ext → ext` dependencies while still
avoiding any extension cycles. The same trick can also be used to make
an extension in one package depend on an extension provided in another.

Also requires something like JuliaLang#49891, so that we guarantee these load in
the right order.
@topolarity topolarity force-pushed the ct/ext-to-ext-dep branch 2 times, most recently from 243d783 to d358d6b Compare October 30, 2024 18:22
@KristofferC KristofferC merged commit bf5675b into JuliaLang:backports-release-1.11 Oct 31, 2024
6 checks passed
topolarity added a commit to topolarity/julia that referenced this pull request Oct 31, 2024
…ng#56368)

This is an effort at a proper workaround (feature?) to resolve
JuliaLang#56204.

For example:
```toml
[extensions]
PlottingExt = "Plots"
StatisticsPlottingExt = ["Plots", "Statistics"]
```

Here `StatisticsPlottingExt` is allowed to depend on `PlottingExt` This
provides a way to declare `ext → ext` dependencies while still avoiding
any extension cycles. The same trick can also be used to make an
extension in one package depend on an extension provided in another.

We'll also need to land JuliaLang#49891, so that we guarantee these load in the
right order.
@topolarity topolarity deleted the ct/ext-to-ext-dep branch October 31, 2024 13:30
topolarity added a commit that referenced this pull request Nov 1, 2024
…#56402)

Forward port of #56368 - this was a pretty clean port, so it should be
good to go once tests pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants