Skip to content

Commit

Permalink
Remove Pkg as a dependency (#184)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
fredrikekre and tlienart authored Oct 22, 2024
1 parent 9c997df commit 65b8cdb
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
3 changes: 1 addition & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
name = "LiveServer"
uuid = "16fef848-5104-11e9-1b77-fb7a48bbb589"
authors = ["Jonas Asprion <[email protected]", "Thibaut Lienart <[email protected]>"]
version = "1.3.1"
version = "1.4.0"

[deps]
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"

Expand Down
2 changes: 1 addition & 1 deletion src/LiveServer.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module LiveServer

import Sockets, Pkg, MIMEs
import Sockets, MIMEs
using Base.Filesystem
using Base.Threads: @spawn

Expand Down
19 changes: 15 additions & 4 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down Expand Up @@ -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))
Expand All @@ -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
Expand Down
1 change: 0 additions & 1 deletion test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down

2 comments on commit 65b8cdb

@tlienart
Copy link
Collaborator

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/117848

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.4.0 -m "<description of version>" 65b8cdb1947d29ba517b1306a577bbaf0618d314
git push origin v1.4.0

Please sign in to comment.