Skip to content

Commit 8fc41dd

Browse files
authored
Use dynamic version
Signed-off-by: GitHub <[email protected]>
1 parent 81b534d commit 8fc41dd

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

docs/source/conf.py

+21-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
# https://www.sphinx-doc.org/en/master/usage/configuration.html
55

66
import os
7+
import re
78
import sys
89
from datetime import datetime, timezone
9-
from importlib.metadata import version
1010

1111
# -- Path setup --------------------------------------------------------------
1212

@@ -15,13 +15,32 @@
1515
# documentation root, use os.path.abspath to make it absolute, like shown here.
1616
#
1717

18+
docs_dir = os.path.dirname(os.path.dirname(__file__))
1819
sys.path.insert(0, os.path.abspath('../..'))
1920

2021

2122
# -- Project information -----------------------------------------------------
2223
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
2324

24-
__version__ = version("instawebhooks")
25+
# Find the version and release information.
26+
# We have a single source of truth for our version number: the __init__.py file.
27+
# This next bit of code reads from it.
28+
file_with_version = os.path.join(docs_dir, "..", "src", "instawebhooks", "__init__.py")
29+
with open(file_with_version) as f:
30+
for line in f:
31+
m = re.match(r'__version__ = "(.*)"', line)
32+
if m:
33+
__version__ = m.group(1)
34+
# The short X.Y version.
35+
version = ".".join(__version__.split(".")[:2])
36+
# The full version, including alpha/beta/rc tags.
37+
release = __version__
38+
break
39+
else: # AKA no-break
40+
version = release = "dev"
41+
42+
print("version:", version)
43+
print("release:", release)
2544

2645
project = 'InstaWebhooks'
2746
copyright = f'2024-{datetime.now(tz=timezone.utc).year}, Ryan Luu'

pyproject.toml

+5-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "instawebhooks"
7-
version = "0.1.3"
87
description = "Discord webhooks for new Instagram posts from any profile"
9-
readme = "README.md"
8+
readme = "README.rst"
109
requires-python = ">=3.8"
1110
keywords = ["webhooks", "feed", "embed", "Instagram", "Discord", "CLI"]
1211
authors = [
@@ -34,6 +33,7 @@ dependencies = [
3433
"requests",
3534
"instaloader",
3635
]
36+
dynamic = ["version"]
3737

3838
[project.urls]
3939
Homepage = "https://github.com/RyanLua/InstaWebhooks"
@@ -46,6 +46,9 @@ Sponsor = "https://github.com/sponsors/RyanLua"
4646
[project.scripts]
4747
instawebhooks = "instawebhooks.__main__:main"
4848

49+
[tool.setuptools.dynamic]
50+
version = {attr = "instawebhooks.__version__"}
51+
4952
[tool.isort]
5053
profile = "black"
5154

src/instawebhooks/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
import sys
44

5+
__version__ = "0.1.3"
6+
7+
58
if __name__ == "__main__":
69
from instawebhooks.__main__ import main
710

0 commit comments

Comments
 (0)