Skip to content

Commit 65b8cdb

Browse files
Remove Pkg as a dependency (#184)
* 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 ``` * Set version to 1.4.0. --------- Co-authored-by: Thibaut Lienart <tlienart@me.com>
1 parent 9c997df commit 65b8cdb

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
lines changed

Project.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
name = "LiveServer"
22
uuid = "16fef848-5104-11e9-1b77-fb7a48bbb589"
33
authors = ["Jonas Asprion <jonas.asprion@gmx.ch", "Thibaut Lienart <tlienart@me.com>"]
4-
version = "1.3.1"
4+
version = "1.4.0"
55

66
[deps]
77
HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"
88
LoggingExtras = "e6f89c97-d47a-5376-807f-9c37f3926c36"
99
MIMEs = "6c6e2e6c-3030-632d-7369-2d6c69616d65"
10-
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
1110
Sockets = "6462fe0b-24de-5631-8697-dd941f90decc"
1211
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
1312

src/LiveServer.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module LiveServer
22

3-
import Sockets, Pkg, MIMEs
3+
import Sockets, MIMEs
44
using Base.Filesystem
55
using Base.Threads: @spawn
66

src/utils.jl

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,6 @@ subfolder `docs`.
184184
185185
* `verbose=false`: boolean switch to make the server print information about
186186
file changes and connections.
187-
* `doc_env=false`: a boolean switch to make the server start by activating the
188-
doc environment or not (i.e. the `Project.toml` in `docs/`).
189187
* `literate=nothing`: see `literate_dir`.
190188
* `literate_dir=nothing`: Path to a directory containing Literate scripts if
191189
these are not simply under `docs/src`.
@@ -271,7 +269,12 @@ function servedocs(;
271269
)
272270

273271
# activate the doc environment if required
274-
doc_env && Pkg.activate(joinpath(foldername, "Project.toml"))
272+
if doc_env
273+
msg = "The `doc_env` keyword argument is deprecated. Configure the environment " *
274+
"before calling LiveServer.servedocs instead."
275+
Base.depwarn(msg, :servedocs)
276+
prev = deprecated_activate(joinpath(foldername, "Project.toml"))
277+
end
275278

276279
# trigger a first pass of Documenter (& possibly Literate)
277280
Main.include(abspath(path2makejl))
@@ -291,10 +294,18 @@ function servedocs(;
291294
)
292295

293296
# when the serve loop is interrupted, de-activate the environment
294-
doc_env && Pkg.activate()
297+
if doc_env
298+
deprecated_activate(prev)
299+
end
295300
return
296301
end
297302

303+
function deprecated_activate(path)
304+
prev = Base.ACTIVE_PROJECT[]
305+
Base.ACTIVE_PROJECT[] = path
306+
return prev
307+
end
308+
298309

299310
#
300311
# Miscellaneous utils

test/Project.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
Crayons = "a8cc5b0e-0ffa-5ad4-8c14-923d3ee1735f"
33
HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"
44
MIMEs = "6c6e2e6c-3030-632d-7369-2d6c69616d65"
5-
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
65
Sockets = "6462fe0b-24de-5631-8697-dd941f90decc"
76
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
87

0 commit comments

Comments
 (0)