Skip to content

Add a package-level variable __gmt_version__ for development use #2362

@seisman

Description

@seisman

Description of the desired feature

As we're supporting multiple GMT versions, sometimes we need to check the current GMT version and see if it has a specific bug or provides a new feature.

To check the GMT version, we need to write codes like:

from packaging.version import Version
from pygmt import clib

with clib.Session() as _lib:                                                    
	gmt_version = Version(_lib.info["version"])

if gmt_version >= Version("6.4.0"):
    ...

The same code is being used in many places, so it's better to write a function for it. The function will be like this:

from packaging.version import Version
from pygmt import clib

def get_gmt_version():
	with clib.Session() as _lib:                                                    
	    return Version(_lib.info["version"])

Are you willing to help implement and maintain this feature?

Yes, but the details need more discussions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions