Skip to content

Commit cfab529

Browse files
authored
Switch from versioneer to setuptools-scm (#695)
Replace versioneer added in 3683f37 with the more modern [setuptools-scm](https://github.com/pypa/setuptools_scm). * Get 8 char short hash to store in __commit__ * Just use pkg_resources.get_distribution to obtain version string * Just put setup_requires in setup.py * Let workflows be based on setuptools-scm instead of versioneer * Don't write to _version.py file
1 parent 2ee9b34 commit cfab529

File tree

14 files changed

+22
-2421
lines changed

14 files changed

+22
-2421
lines changed

.codeclimate.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ plugins:
2929
enabled: false
3030

3131
exclude_paths:
32-
- "versioneer.py"
33-
- "pygmt/_version.py"
3432
- "doc/**/*"
3533
- "pygmt/tests/baseline/*"
3634
- "pygmt/tests/data/*"

.gitattributes

Lines changed: 0 additions & 1 deletion
This file was deleted.

.github/workflows/ci_tests.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ jobs:
6464

6565
# Checkout current git repository
6666
- name: Checkout
67-
uses: actions/[email protected].1
67+
uses: actions/[email protected].4
6868
with:
69-
# fecth all history so that versioneer works
69+
# fecth all history so that setuptools-scm works
7070
fetch-depth: 0
7171

7272
# Setup Miniconda

.github/workflows/ci_tests_dev.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ jobs:
3939

4040
# Checkout current git repository
4141
- name: Checkout
42-
uses: actions/[email protected].1
42+
uses: actions/[email protected].4
4343
with:
44-
# fecth all history so that versioneer works
44+
# fecth all history so that setuptools-scm works
4545
fetch-depth: 0
4646

4747
# Setup Miniconda

.github/workflows/publish-to-pypi.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- name: Checkout
2525
uses: actions/[email protected]
2626
with:
27-
# fecth all history so that versioneer works
27+
# fecth all history so that setuptools-scm works
2828
fetch-depth: 0
2929

3030
- name: Set up Python
@@ -37,13 +37,12 @@ jobs:
3737

3838
- name: Fix up version string
3939
run: |
40-
# Change the versioneer format to "pre" so that the commit hash isn't
41-
# included (PyPI doesn't allow it). Can't do this permanently because
42-
# we rely on the hash to tell the tests that this is a local version
43-
# instead of a published version.
40+
# Change setuptools-scm local_scheme to "no-local-version" so the
41+
# local part of the version isn't included, making the version string
42+
# compatible with PyPI.
4443
#
4544
# The step is only necessary for testing purpose
46-
sed --in-place "s/pep440/pep440-pre/g" setup.cfg
45+
sed --in-place "s/node-and-date/no-local-version/g" setup.py
4746
4847
- name: Build source and wheel distributions
4948
run: |

MAINTENANCE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ see https://zeit.co/docs/v2/build-step/?query=package.json#defining-a-build-scri
103103

104104
We try to automate the release process as much as possible.
105105
Travis handles publishing new releases to PyPI and updating the documentation.
106-
The version number is set automatically using versioneer based information it gets from
107-
git.
106+
The version number is set automatically using setuptools_scm based information
107+
obtained from git.
108108
There are a few steps that still must be done manually, though.
109109

110110
### Updating the changelog

MANIFEST.in

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,5 @@ include LICENSE.txt
33
include CODE_OF_CONDUCT.md
44
include CONTRIBUTING.md
55
include AUTHORS.md
6-
include versioneer.py
7-
include pygmt/_version.py
86
recursive-include pygmt/tests/data *
97
recursive-include pygmt/tests/baseline *

doc/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@
132132
html_theme_options = {}
133133
repository = "GenericMappingTools/pygmt"
134134
repository_url = "https://github.com/GenericMappingTools/pygmt"
135-
commit_link = f'<a href="{repository_url}/commit/{ __commit__ }">{ __commit__[:7] }</a>'
135+
commit_link = f'<a href="{repository_url}/commit/{ __commit__ }">{ __commit__[:8] }</a>'
136136
html_context = {
137137
"menu_links": [
138138
(

pygmt/__init__.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
import atexit as _atexit
1111

12-
from ._version import get_versions as _get_versions
12+
from pkg_resources import get_distribution
1313

1414
# Import modules to make the high-level GMT Python API
1515
from .session_management import begin as _begin, end as _end
@@ -23,10 +23,9 @@
2323
from .x2sys import x2sys_init, x2sys_cross
2424
from . import datasets
2525

26-
27-
# Get the version number through versioneer
28-
__version__ = _get_versions()["version"]
29-
__commit__ = _get_versions()["full-revisionid"]
26+
# Get semantic version through setuptools-scm
27+
__version__ = f'v{get_distribution("pygmt").version}' # e.g. v0.1.2.dev3+g0ab3cd78
28+
__commit__ = __version__.split("+g")[-1] # 0ab3cd78
3029

3130
# Start our global modern mode session
3231
_begin()

0 commit comments

Comments
 (0)