Skip to content

Conversation

@IanButterworth
Copy link
Member

@IanButterworth IanButterworth commented Jun 14, 2025

i.e. with this it will precompile the env at the end of this, not after every step

Pkg.precompile() do
    Pkg.instantiate()
    Pkg.rm("Foo")
    Pkg.add("Bar")
    Pkg.dev("Baz")
end

Also a non-scoped version:

Pkg.autoprecompilation_enabled(false)
...
Pkg.autoprecompilation_enabled(true)

TODO:

  • Add to docs
  • Add tests

@IanButterworth
Copy link
Member Author

@KristofferC what do you think about this?

@IanButterworth IanButterworth changed the title Add more autoprecompilation controls and Pkg.precompile(f) do to delay precompilation until after operations. Add more autoprecompilation controls and Pkg.precompile() do to delay precompilation until after operations. Jun 23, 2025
@IanButterworth
Copy link
Member Author

Bump @KristofferC

@KristofferC
Copy link
Member

Probably makes sense to have, yes.

@github-project-automation github-project-automation bot moved this to New in Pkg.jl Jul 2, 2025
@IanButterworth IanButterworth moved this from New to In progress in Pkg.jl Jul 2, 2025
@IanButterworth IanButterworth force-pushed the ib/precompile_f branch 2 times, most recently from 5efee07 to 16f78d9 Compare July 4, 2025 19:54
@IanButterworth IanButterworth moved this from In progress to In review in Pkg.jl Jul 4, 2025
@IanButterworth IanButterworth requested a review from Copilot July 4, 2025 20:00
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds scoped and global controls for automatic package precompilation by introducing a Pkg.precompile() do ... end block to defer compilation and a Pkg.autoprecompilation_enabled(state::Bool) API to toggle auto-precompilation.

  • Introduce Pkg.precompile() do ... end syntax that disables auto-precompilation inside the block and runs a single compile at the end.
  • Add Pkg.autoprecompilation_enabled(state::Bool) for session-wide enable/disable of automatic precompilation.
  • Update tests, documentation, and the changelog to reflect the new features.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/api.jl Add tests covering the do-block precompile behavior and global toggle
src/Pkg.jl Implement global/scoped flags, extend should_autoprecompile, add docstrings
src/API.jl Define the precompile(f, args...; kwargs...) method for do-block syntax
docs/src/environments.md Document both environment-variable, programmatic, and scoped controls
docs/src/api.md Add Pkg.autoprecompilation_enabled to the API index
CHANGELOG.md Record the new block syntax and global toggle additions
Comments suppressed due to low confidence (2)

docs/src/environments.md:207

  • Clarify this bullet to highlight the do-block syntax users will write (e.g. Pkg.precompile() do ... end) rather than referring to the internal function signature.
- **Scoped control**: Use `Pkg.precompile(f, args...; kwargs...)` to execute a function `f` with auto-precompilation temporarily disabled, then automatically trigger precompilation afterward if any packages were modified during the execution.

src/Pkg.jl:228

  • [nitpick] This sentence is a fragment; consider rephrasing to To delay auto-precompilation until after a batch of Pkg actions, use the do-block syntax: for clarity.
To delay autoprecompilation of multiple Pkg actions until the end use.

@IanButterworth IanButterworth force-pushed the ib/precompile_f branch 2 times, most recently from 4144e09 to 92b541a Compare July 12, 2025 03:02
@IanButterworth IanButterworth merged commit 61a8447 into JuliaLang:master Jul 12, 2025
9 checks passed
@github-project-automation github-project-automation bot moved this from In review to Done in Pkg.jl Jul 12, 2025
@IanButterworth IanButterworth deleted the ib/precompile_f branch July 12, 2025 04:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants