Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for MOI.SolverVersion #71

Closed
chriscoey opened this issue Sep 19, 2023 · 7 comments
Closed

Add support for MOI.SolverVersion #71

chriscoey opened this issue Sep 19, 2023 · 7 comments

Comments

@chriscoey
Copy link
Contributor

@odow do you know how to get the version of the active package, so we can return it as a string?

@odow
Copy link
Member

odow commented Sep 19, 2023

I never liked this though
https://github.com/jump-dev/JuMP.jl/blob/6bde748268c579a635c81ccd8c0afe50d9cce0b5/docs/make.jl#L451-L452

You could also parse the TOML file

@chriscoey
Copy link
Contributor Author

Hmm there is PkgVersion.jl - see https://github.com/KlausC/PkgVersion.jl/blob/main/src/PkgVersion.jl

@chriscoey
Copy link
Contributor Author

@chriscoey
Copy link
Contributor Author

@odow could we use some combination of

using TOML

const PACKAGE_VERSION = let
    project = TOML.parsefile(joinpath(pkgdir(@__MODULE__), "Project.toml"))
    VersionNumber(project["version"])
end

if the julia version < 1.9, and pkgversion(@__MODULE__) for 1.9+? These are taken from that discourse link above.

@odow
Copy link
Member

odow commented Sep 20, 2023

Is it really necessary? This was mainly intended for solvers which have upstream versions that are unrelated their Julia package version.

But presumably something like

@static if VERSION < v"1.9"
    import TOML
    function MOI.get(model::Optimizer, ::MOI.SolverVersion)
        project = TOML.parsefile(joinpath(pkgdir(@__MODULE__), "Project.toml"))
        return VersionNumber(project["version"])
    end
else
    MOI.get(model::Optimizer, ::MOI.SolverVersion) = pkgversion(@__MODULE__)
end

@chriscoey
Copy link
Contributor Author

If the standard procedure is not to support MOI.SolverVersion in cases like this (pure Julia solvers), then it's OK to close this issue without a fix. I can just use pkgversion as a fallback in my own code if I can't get MOI.SolverVersion.

@chriscoey
Copy link
Contributor Author

The above worked for my use case so I'll close

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants