Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Git archive config and version fetching #59

Merged
merged 5 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .git_archival.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node: $Format:%H$
node-date: $Format:%cI$
describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.git_archival.txt export-subst
5 changes: 5 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
comment:
false

# When modifying this file, please validate using
# curl -X POST --data-binary @codecov.yml https://codecov.io/validate
13 changes: 10 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@

myst_enable_extensions = ["dollarmath", "amsmath"]

def is_non_standard_version(version):
"""
Determine if the given version string has more than 3 components (e.g., from a developer version).
"""

return len(version.split(".")) != 3

# based on pandas doc/source/conf.py
def linkcode_resolve(domain, info):
"""Determine the URL corresponding to Python object."""
Expand Down Expand Up @@ -136,10 +143,10 @@ def linkcode_resolve(domain, info):

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

if "-" in plasticparcels.__version__:
return f"https://github.com/OceanParcels/plasticparcels/blob/master/plasticparcels/{fn}{linespec}"
if is_non_standard_version(plasticparcels.__version__):
return f"https://github.com/OceanParcels/plasticparcels/blob/main/plasticparcels/{fn}{linespec}"
else:
return (
f"https://github.com/OceanParcels/plasticparcels/blob/"
f"{plasticparcels.__version__}/plasticparcels/{fn}{linespec}"
f"v{plasticparcels.__version__}/plasticparcels/{fn}{linespec}"
)
5 changes: 4 additions & 1 deletion plasticparcels/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
from plasticparcels.particlefile import * # noqa
from plasticparcels.utils import * # noqa

from plasticparcels._version_setup import __version__, __version_tuple__ # noqa
try:
from plasticparcels._version_setup import __version__ # noqa
except ModuleNotFoundError:
__version__ = "unknown"
Loading