Repository navigation
Add a package-level variable __gmt_version__ for development use - #2366
Conversation
ef57ac5 to
727376f
Compare
| _atexit.register(_end) | ||
|
|
||
|
|
||
| def _get_gmt_version(): |
There was a problem hiding this comment.
I've added a utility function _get_gmt_version in the pygmt/__init__.py file. I wonder if it's better to define a package-level variable __gmt_version__ instead.
There was a problem hiding this comment.
Sounds good. This would be similar to __gdal_version__ in rasterio, see https://github.com/rasterio/rasterio/blob/6bf045cc5e02c9f28e78d48b97b308490207d27d/rasterio/__init__.py#L84-L86
| from pygmt import clib | ||
|
|
||
| # Get semantic version through setuptools-scm | ||
| __version__ = f'v{version("pygmt")}' # e.g. v0.1.2.dev3+g0ab3cd78 | ||
| __commit__ = __version__.split("+g")[-1] if "+g" in __version__ else "" # 0ab3cd78 | ||
| with clib.Session() as lib: | ||
| __gmt_version__ = lib.info["version"] |
There was a problem hiding this comment.
The package-level variable __gmt_version__ is defined here.
I have to put the definition of __gmt_version__ at the top otherwise there will be circular import errors (see https://github.com/GenericMappingTools/pygmt/actions/runs/4179854302/jobs/7240260379).
Description of proposed changes
Fixes #2362
Reminders
make formatandmake checkto make sure the code follows the style guide.doc/api/index.rst.Slash Commands
You can write slash commands (
/command) in the first line of a comment to performspecific operations. Supported slash commands are:
/format: automatically format and lint the code/test-gmt-dev: run full tests on the latest GMT development version