Skip to content

Commit

Permalink
Remove dependency on Pkg (#1964)
Browse files Browse the repository at this point in the history
- `versioninfo` was just broken, so remove it
- parse `Project.toml` to get package version
- replace heuristic for detecting dev versions by a new one which
  checks for the presence of a `.git` dir -- this catches a few more
  cases than what we have right now
- move banner printing code into a new helper `show_banner` which
  makes it easier to test changes to it
  • Loading branch information
fingolfin authored Dec 7, 2024
1 parent 35cb6fa commit 7833f8d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 40 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ AbstractAlgebra = "c3fe647b-3220-5bb0-a1ea-a7954cac585d"
FLINT_jll = "e134572f-a0d5-539d-bddf-3cad8db41a82"
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
RandomExtensions = "fb686558-2515-59ef-acaa-46db3789a887"
SHA = "ea8e919c-243c-51af-8825-aaa63cd721ce"
TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76"

[compat]
AbstractAlgebra = "0.43.10"
FLINT_jll = "^300.100.100"
Libdl = "1.6"
LinearAlgebra = "1.6"
Pkg = "1.6"
Random = "1.6"
RandomExtensions = "0.4.2"
SHA = "~1.6, ~1.7, 0.7"
TOML = "<0.0.1, 1"
julia = "1.6"
54 changes: 16 additions & 38 deletions src/Nemo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import Random: rand!

using RandomExtensions: RandomExtensions, make, Make2, Make3

import Pkg
import TOML

import SHA

Expand Down Expand Up @@ -333,6 +333,19 @@ end

const __isthreaded = Ref(false)

function show_banner()
PROJECT_TOML = TOML.parsefile(joinpath(@__DIR__, "..", "Project.toml"))
VERSION_NUMBER = PROJECT_TOML["version"]
if isdir(joinpath(@__DIR__, "..", ".git"))
VERSION_NUMBER *= "-dev"
end
println("")
println("Welcome to Nemo version $VERSION_NUMBER")
println("")
println("Nemo comes with absolutely no warranty whatsoever")
end


function __init__()
# In case libgmp picks up the wrong libgmp later on, we "unset" the jl_*
# functions from the julia :libgmp.
Expand All @@ -346,10 +359,7 @@ function __init__()
@ccall libflint.flint_set_abort(@cfunction(flint_abort, Nothing, ())::Ptr{Nothing})::Nothing

if AbstractAlgebra.should_show_banner() && get(ENV, "NEMO_PRINT_BANNER", "true") != "false"
println("")
println("Welcome to Nemo version $(version())")
println("")
println("Nemo comes with absolutely no warranty whatsoever")
show_banner()
end

# Initialize the thread local random state
Expand Down Expand Up @@ -377,42 +387,10 @@ end

###############################################################################
#
# Version information
# Hack helper
#
################################################################################

const deps = Pkg.dependencies()
if !haskey(deps, Base.UUID("2edaba10-b0f1-5616-af89-8c11ac63239a"))
version() = "building"
else
ver = deps[Base.UUID("2edaba10-b0f1-5616-af89-8c11ac63239a")]
if occursin("/dev/", ver.source)
version() = VersionNumber("$(ver.version)-dev")
else
version() = VersionNumber("$(ver.version)")
end
end

function versioninfo()
print("Nemo version $(version())\n")
nemorepo = dirname(dirname(@__FILE__))

print("Nemo: ")
prepo = Base.LibGit2.GitRepo(nemorepo)
Base.LibGit2.with(Base.LibGit2.head(prepo)) do phead
print("commit: ")
print(string(Base.LibGit2.Oid(phead))[1:8])
print(" date: ")
commit = Base.LibGit2.get(Base.LibGit2.GitCommit, prepo, Base.LibGit2.Oid(phead))
print(Base.Dates.unix2datetime(Base.LibGit2.author(commit).time))
print(")\n")
end

finalize(prepo)

return nothing
end

macro new_struct(T, args...)
return esc(Expr(:new, T, args...))
end
Expand Down

0 comments on commit 7833f8d

Please sign in to comment.