Skip to content

Commit

Permalink
Merge pull request #175 from freemansw1/add-version-number
Browse files Browse the repository at this point in the history
Adding version numbers
  • Loading branch information
freemansw1 authored Oct 11, 2022
2 parents 19d2114 + 3b3362e commit b910b18
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 3 deletions.
32 changes: 29 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,34 @@
from setuptools import setup


"""
This code is from the python documentation and is
designed to read in the version number.
See: https://packaging.python.org/en/latest/guides/single-sourcing-package-version/
"""
from pathlib import Path


def read(pkg_name):
init_fname = Path(__file__).parent / pkg_name / "__init__.py"
with open(init_fname, "r") as fp:
return fp.read()


def get_version(pkg_name):
for line in read(pkg_name).splitlines():
if line.startswith("__version__"):
delim = '"' if '"' in line else "'"
return line.split(delim)[1]
else:
raise RuntimeError("Unable to find version string.")


PACKAGE_NAME = "tobac"

setup(
name="tobac",
version="1.3.3",
name=PACKAGE_NAME,
version=get_version(PACKAGE_NAME),
description="Tracking and object-based analysis of clouds",
url="http://github.com/tobac-project/tobac",
author=[
Expand All @@ -22,7 +48,7 @@
"[email protected]",
],
license="BSD-3-Clause License",
packages=["tobac"],
packages=[PACKAGE_NAME],
install_requires=[],
zip_safe=False,
)
3 changes: 3 additions & 0 deletions tobac/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,6 @@
from .tracking import linking_trackpy
from .wrapper import maketrack
from .wrapper import tracking_wrapper

# Set version number
__version__ = "1.4.0"
15 changes: 15 additions & 0 deletions tobac/tests/test_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,18 @@

def test_dummy_function():
assert 1 == 1


def test_version():
"""Test to make sure that we have a version number included.
Also test to make sure that the version number complies with
semantic versioning guidelines.
If it's not, this should result in an error.
"""
import re

assert type(tobac.__version__) is str
# Make sure that we are following semantic versioning
# i.e., our version is of form x.x.x, where x are all
# integer numbers.
assert re.match(r"[0-9]+\.[0-9]+\.[0-9]+", tobac.__version__) is not None

0 comments on commit b910b18

Please sign in to comment.