Skip to content

Commit eac0cad

Browse files
authored
Merge pull request #464 from freemansw1/add_pyproj_toml
Add pyproject.toml
2 parents f0240d4 + b270b29 commit eac0cad

File tree

4 files changed

+73
-24
lines changed

4 files changed

+73
-24
lines changed

pyproject.toml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
[build-system]
2+
requires = ["setuptools"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "tobac"
7+
version = "1.6.1"
8+
authors = [
9+
{ name="Max Heikenfeld", email="max.heikenfeld@physics.ox.ac.uk" },
10+
{ name="William Jones", email="william.jones@physics.ox.ac.uk" },
11+
{ name="Fabian Senf", email="senf@tropos.de" },
12+
{ name="Sean Freeman", email="sean.freeman@uah.edu" },
13+
{ name="Julia Kukulies", email="kukulies@ucar.edu" },
14+
{ name="Kelcy Brunner", email="Kelcy.Brunner@ttu.edu" },
15+
]
16+
description = "A package for identifying and tracking atmospheric phenomena"
17+
readme = "README.md"
18+
requires-python = ">=3.7"
19+
classifiers = [
20+
"Development Status :: 5 - Production/Stable",
21+
"Environment :: Console",
22+
"Intended Audience :: Education",
23+
"Intended Audience :: Science/Research",
24+
"Intended Audience :: Developers",
25+
"License :: OSI Approved :: BSD License",
26+
"Operating System :: POSIX :: Linux",
27+
"Operating System :: MacOS :: MacOS X",
28+
"Operating System :: Microsoft :: Windows",
29+
"Programming Language :: Python",
30+
"Programming Language :: Python :: 3",
31+
"Programming Language :: Python :: 3 :: Only",
32+
"Programming Language :: Python :: 3.7",
33+
"Programming Language :: Python :: 3.8",
34+
"Programming Language :: Python :: 3.9",
35+
"Programming Language :: Python :: 3.10",
36+
"Programming Language :: Python :: 3.11",
37+
"Programming Language :: Python :: 3.12",
38+
"Topic :: Scientific/Engineering",
39+
"Topic :: Scientific/Engineering :: Atmospheric Science",
40+
]
41+
42+
[project.urls]
43+
Homepage = "http://github.com/tobac-project/tobac"
44+
Documentation = "http://tobac.io"
45+
Issues = "http://github.com/tobac-project/tobac/issues"

setup.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -72,28 +72,6 @@ def get_packages(package_name):
7272

7373

7474
setup(
75-
name=PACKAGE_NAME,
76-
version=get_version(PACKAGE_NAME),
77-
description="Tracking and object-based analysis of clouds",
78-
url="http://github.com/tobac-project/tobac",
79-
classifiers=CLASSIFIERS,
80-
author=[
81-
"Max Heikenfeld",
82-
"William Jones",
83-
"Fabian Senf",
84-
"Sean Freeman",
85-
"Julia Kukulies",
86-
"Peter Marinescu",
87-
],
88-
author_email=[
89-
"max.heikenfeld@physics.ox.ac.uk",
90-
"william.jones@physics.ox.ac.uk",
91-
"senf@tropos.de",
92-
"sean.freeman@uah.edu",
93-
"julia.kukulies@gu.se",
94-
"peter.marinescu@colostate.edu",
95-
],
96-
license="BSD-3-Clause License",
9775
packages=get_packages(PACKAGE_NAME),
9876
install_requires=get_requirements("requirements.txt"),
9977
test_requires=["pytest"],

tobac/__init__.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,29 @@
8181
from .wrapper import maketrack
8282
from .wrapper import tracking_wrapper
8383
from . import merge_split
84+
import importlib.metadata
85+
import pathlib
86+
87+
# default version number
88+
__version__ = "unknown_dev_version"
8489

8590
# Set version number
86-
__version__ = "1.6.1"
91+
# This version should work without needing the package installed
92+
try:
93+
__version__ = importlib.metadata.version(__package__ or __name__)
94+
except importlib.metadata.PackageNotFoundError:
95+
# need to get version directly from text file
96+
try:
97+
import tomllib
98+
99+
pyproject_toml_file_name = pathlib.Path(__file__).parent / "pyproject.toml"
100+
if pyproject_toml_file_name.exists() and pyproject_toml_file_name.is_file():
101+
toml_data = tomllib.load(pyproject_toml_file_name)
102+
if "project" in toml_data and "version" in toml_data["project"]:
103+
version = toml_data["project"]["version"]
104+
105+
except ImportError:
106+
# on python <3.11 but not installing tobac.
107+
# don't bother giving precise version number.
108+
__version__ = "unknown_dev_version"
109+
pass

tobac/tests/test_import.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,7 @@ def test_version():
1818
# Make sure that we are following semantic versioning
1919
# i.e., our version is of form x.x.x, where x are all
2020
# integer numbers.
21-
assert re.match(r"[0-9]+\.[0-9]+\.[0-9]+", tobac.__version__) is not None
21+
assert (
22+
re.match(r"[0-9]+\.[0-9]+\.[0-9]+", tobac.__version__) is not None
23+
or tobac.__version__ == "unknown_dev_version"
24+
)

0 commit comments

Comments
 (0)