Skip to content

Commit cbf339c

Browse files
authored
Merge pull request #59 from OceanParcels/versioning
Git archive config and version fetching
2 parents 31b05b2 + 3352b17 commit cbf339c

File tree

5 files changed

+23
-4
lines changed

5 files changed

+23
-4
lines changed

.git_archival.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node: $Format:%H$
2+
node-date: $Format:%cI$
3+
describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.git_archival.txt export-subst

codecov.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
comment:
2+
false
3+
4+
# When modifying this file, please validate using
5+
# curl -X POST --data-binary @codecov.yml https://codecov.io/validate

docs/conf.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@
8686

8787
myst_enable_extensions = ["dollarmath", "amsmath"]
8888

89+
def is_non_standard_version(version):
90+
"""
91+
Determine if the given version string has more than 3 components (e.g., from a developer version).
92+
"""
93+
94+
return len(version.split(".")) != 3
95+
8996
# based on pandas doc/source/conf.py
9097
def linkcode_resolve(domain, info):
9198
"""Determine the URL corresponding to Python object."""
@@ -136,10 +143,10 @@ def linkcode_resolve(domain, info):
136143

137144
fn = os.path.relpath(fn, start=os.path.dirname(plasticparcels.__file__))
138145

139-
if "-" in plasticparcels.__version__:
140-
return f"https://github.com/OceanParcels/plasticparcels/blob/master/plasticparcels/{fn}{linespec}"
146+
if is_non_standard_version(plasticparcels.__version__):
147+
return f"https://github.com/OceanParcels/plasticparcels/blob/main/plasticparcels/{fn}{linespec}"
141148
else:
142149
return (
143150
f"https://github.com/OceanParcels/plasticparcels/blob/"
144-
f"{plasticparcels.__version__}/plasticparcels/{fn}{linespec}"
151+
f"v{plasticparcels.__version__}/plasticparcels/{fn}{linespec}"
145152
)

plasticparcels/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@
22
from plasticparcels.particlefile import * # noqa
33
from plasticparcels.utils import * # noqa
44

5-
from plasticparcels._version_setup import __version__, __version_tuple__ # noqa
5+
try:
6+
from plasticparcels._version_setup import __version__ # noqa
7+
except ModuleNotFoundError:
8+
__version__ = "unknown"

0 commit comments

Comments
 (0)