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

More embedded Pkg API #2868

Merged
merged 8 commits into from
Nov 12, 2024
Merged

More embedded Pkg API #2868

merged 8 commits into from
Nov 12, 2024

Conversation

fonsp
Copy link
Owner

@fonsp fonsp commented Mar 29, 2024

Lots of new Pluto API to work with Pkg environments embedded in notebooks

activate_notebook_environment

New method activate_notebook_environment(fun::Function, notebook_path::String) with a function argument that you can use inside scripts instead of REPL use. Example:

Pluto.activate_notebook_environment("notebook.jl") do
    Pkg.add("Example")
end

# Now the file "notebook.jl" was updated!

The method activate_notebook_environment(path::String) has a new show_help::Bool kwarg to disable the help banner.

will_use_pluto_pkg

New function will_use_pluto_pkg(path::String) or will_use_pluto_pkg(notebook::Notebook) to check if a notebook will use Pluto's package manager. false means that the notebook contains Pkg.activate or another deactivator.

More

Added tests for all public API

Fixed testnb (not public)

Copy link
Contributor

Try this Pull Request!

Open Julia and type:

julia> import Pkg
julia> Pkg.activate(temp=true)
julia> Pkg.add(url="https://github.com/fonsp/Pluto.jl", rev="more-notebook-pkg-api")
julia> using Pluto

@fonsp fonsp added backend Concerning the julia server and runtime package manager Pluto's built-in package manager labels Nov 11, 2024
@fonsp
Copy link
Owner Author

fonsp commented Nov 11, 2024

@j-fu This should help with your update scripts!

@j-fu
Copy link
Contributor

j-fu commented Nov 11, 2024

Cool! Once you are at this - do you see a possibility for #1788 ?

Something like Pluto.run(notebook="notebook.jl", pkgactivate=pwd())

@fonsp fonsp merged commit 4b741b9 into main Nov 12, 2024
10 of 11 checks passed
@fonsp fonsp deleted the more-notebook-pkg-api branch November 12, 2024 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Concerning the julia server and runtime package manager Pluto's built-in package manager
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants