Add a package-level variable __gmt_version__ for development use#2366
Merged
Add a package-level variable __gmt_version__ for development use#2366
Conversation
ef57ac5 to
727376f
Compare
seisman
commented
Feb 15, 2023
pygmt/__init__.py
Outdated
| _atexit.register(_end) | ||
|
|
||
|
|
||
| def _get_gmt_version(): |
Member
Author
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.
Member
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
seisman
commented
Feb 15, 2023
Comment on lines
+24
to
+30
| 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"] |
Member
Author
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).
michaelgrund
approved these changes
Feb 15, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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