From d5d177964701901b3ece1361c073130f7f2aadac Mon Sep 17 00:00:00 2001 From: Fredrik Ekre Date: Wed, 4 Sep 2024 13:33:43 +0200 Subject: [PATCH 1/2] Remove Pkg as a dependency In recent Julia versions Pkg is not in the sysimage and therefore it can not be loaded "for free". Pkg was only used to conditionally activate the documentation environment in `LiveServer.servedocs` so the loss of functionality is basically non-existent -- it is easy enough to configure the package environment before calling `LiveServer.servedocs`. Timings for loading LiveServer on Julia 1.12: ``` julia> @time using LiveServer # this PR 0.448249 seconds julia> @time using LiveServer # master 0.743163 seconds ``` --- Project.toml | 1 - src/LiveServer.jl | 2 +- src/utils.jl | 19 +++++++++++++++---- test/Project.toml | 1 - 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/Project.toml b/Project.toml index dbaee7b..2f5ab40 100644 --- a/Project.toml +++ b/Project.toml @@ -7,7 +7,6 @@ version = "1.3.1" HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3" LoggingExtras = "e6f89c97-d47a-5376-807f-9c37f3926c36" MIMEs = "6c6e2e6c-3030-632d-7369-2d6c69616d65" -Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" Sockets = "6462fe0b-24de-5631-8697-dd941f90decc" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" diff --git a/src/LiveServer.jl b/src/LiveServer.jl index e4ac569..bb49ad3 100644 --- a/src/LiveServer.jl +++ b/src/LiveServer.jl @@ -1,6 +1,6 @@ module LiveServer -import Sockets, Pkg, MIMEs +import Sockets, MIMEs using Base.Filesystem using Base.Threads: @spawn diff --git a/src/utils.jl b/src/utils.jl index 27031fe..1e3aefc 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -184,8 +184,6 @@ subfolder `docs`. * `verbose=false`: boolean switch to make the server print information about file changes and connections. -* `doc_env=false`: a boolean switch to make the server start by activating the -doc environment or not (i.e. the `Project.toml` in `docs/`). * `literate=nothing`: see `literate_dir`. * `literate_dir=nothing`: Path to a directory containing Literate scripts if these are not simply under `docs/src`. @@ -271,7 +269,12 @@ function servedocs(; ) # activate the doc environment if required - doc_env && Pkg.activate(joinpath(foldername, "Project.toml")) + if doc_env + msg = "The `doc_env` keyword argument is deprecated. Configure the environment " * + "before calling LiveServer.servedocs instead." + Base.depwarn(msg, :servedocs) + prev = deprecated_activate(joinpath(foldername, "Project.toml")) + end # trigger a first pass of Documenter (& possibly Literate) Main.include(abspath(path2makejl)) @@ -291,10 +294,18 @@ function servedocs(; ) # when the serve loop is interrupted, de-activate the environment - doc_env && Pkg.activate() + if doc_env + deprecated_activate(prev) + end return end +function deprecated_activate(path) + prev = Base.ACTIVE_PROJECT[] + Base.ACTIVE_PROJECT[] = path + return prev +end + # # Miscellaneous utils diff --git a/test/Project.toml b/test/Project.toml index c48b09a..c8bafe7 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -2,7 +2,6 @@ Crayons = "a8cc5b0e-0ffa-5ad4-8c14-923d3ee1735f" HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3" MIMEs = "6c6e2e6c-3030-632d-7369-2d6c69616d65" -Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" Sockets = "6462fe0b-24de-5631-8697-dd941f90decc" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" From d7175ac19dd79cd00d9863db753fdb8b27d59a61 Mon Sep 17 00:00:00 2001 From: Fredrik Ekre Date: Wed, 4 Sep 2024 13:43:32 +0200 Subject: [PATCH 2/2] Set version to 1.4.0. --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 2f5ab40..ca6829f 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "LiveServer" uuid = "16fef848-5104-11e9-1b77-fb7a48bbb589" authors = ["Jonas Asprion "] -version = "1.3.1" +version = "1.4.0" [deps] HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"