From eb6ed80541187154940f393b6e2755aee8747eba Mon Sep 17 00:00:00 2001 From: Pedro Maciel Xavier Date: Wed, 25 Sep 2024 19:35:41 -0400 Subject: [PATCH] Update Requirements --- Project.toml | 4 ++-- src/ToQUBO.jl | 34 +++++++++++++++++++++++++++++++--- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/Project.toml b/Project.toml index 4daa5a7..1697c50 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ToQUBO" uuid = "9a412ddf-83fa-43b6-9748-7843c851aa65" -authors = ["pedromxavier ", "pedroripper ", "joaquimg ", "AndradeTiago ", "bernalde "] +authors = ["pedromxavier ", "pedroripper ", "joaquimg ", "AndradeTiago ", "bernalde "] version = "0.1.9" [deps] @@ -13,5 +13,5 @@ TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76" [compat] MathOptInterface = "1" PseudoBooleanOptimization = "0.2" -QUBOTools = "0.9" +QUBOTools = "0.10" julia = "1.9" diff --git a/src/ToQUBO.jl b/src/ToQUBO.jl index ba87638..1d728a2 100644 --- a/src/ToQUBO.jl +++ b/src/ToQUBO.jl @@ -7,9 +7,37 @@ import PseudoBooleanOptimization as PBO import QUBOTools # Versioning -using TOML -const __PROJECT__ = abspath(@__DIR__, "..") -const __VERSION__ = VersionNumber(getindex(TOML.parsefile(joinpath(__PROJECT__, "Project.toml")), "version")) +import TOML + +const __PROJECT__ = Ref{Union{String,Nothing}}(nothing) + +function __project__() + if isnothing(__PROJECT__[]) + proj_path = abspath(dirname(@__DIR__)) + + @assert isdir(proj_path) + + __PROJECT__[] = proj_path + end + + return __PROJECT__[]::String +end + +const __VERSION__ = Ref{Union{VersionNumber,Nothing}}(nothing) + +function __version__()::VersionNumber + if isnothing(__VERSION__[]) + proj_file_path = abspath(__project__(), "Project.toml") + + @assert isfile(proj_file_path) + + proj_file_data = TOML.parsefile(proj_file_path) + + __VERSION__[] = VersionNumber(proj_file_data["version"]) + end + + return __VERSION__[]::VersionNumber +end # MOI Aliases const MOIU = MOI.Utilities