Skip to content

Commit b44ac23

Browse files
ppfeisterbytexenon
andcommitted
chore: move SSOT to pyproject.toml
Co-authored-by: ByteXenon <[email protected]>
1 parent 7ff3924 commit b44ac23

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ source = "init"
88

99
[tool.poetry]
1010
name = "sherlock-project"
11-
# single source of truth for version is __init__.py
12-
version = "0"
11+
version = "0.16.0"
1312
description = "Hunt down social media accounts by username across social networks"
1413
license = "MIT"
1514
authors = [
@@ -50,6 +49,7 @@ stem = "^1.8.0"
5049
torrequest = "^0.1.0"
5150
pandas = "^2.2.1"
5251
openpyxl = "^3.0.10"
52+
tomli = "^2.2.1"
5353

5454
[tool.poetry.extras]
5555
tor = ["torrequest"]

sherlock_project/__init__.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,26 @@
55
66
"""
77

8+
from importlib.metadata import version as pkg_version, PackageNotFoundError
9+
import pathlib
10+
import tomli
11+
12+
13+
def get_version() -> str:
14+
"""Fetch the version number of the installed package."""
15+
try:
16+
return pkg_version("sherlock_project")
17+
except PackageNotFoundError:
18+
pyproject_path: pathlib.Path = pathlib.Path(__file__).resolve().parent.parent / "pyproject.toml"
19+
with pyproject_path.open("rb") as f:
20+
pyproject_data = tomli.load(f)
21+
return pyproject_data["tool"]["poetry"]["version"]
22+
823
# This variable is only used to check for ImportErrors induced by users running as script rather than as module or package
924
import_error_test_var = None
1025

1126
__shortname__ = "Sherlock"
1227
__longname__ = "Sherlock: Find Usernames Across Social Networks"
13-
__version__ = "0.16.0"
28+
__version__ = get_version()
1429

1530
forge_api_latest_release = "https://api.github.com/repos/sherlock-project/sherlock/releases/latest"

0 commit comments

Comments
 (0)