|
4 | 4 | # https://www.sphinx-doc.org/en/master/usage/configuration.html
|
5 | 5 |
|
6 | 6 | import os
|
| 7 | +import re |
7 | 8 | import sys
|
8 | 9 | from datetime import datetime, timezone
|
9 |
| -from importlib.metadata import version |
10 | 10 |
|
11 | 11 | # -- Path setup --------------------------------------------------------------
|
12 | 12 |
|
|
15 | 15 | # documentation root, use os.path.abspath to make it absolute, like shown here.
|
16 | 16 | #
|
17 | 17 |
|
| 18 | +docs_dir = os.path.dirname(os.path.dirname(__file__)) |
18 | 19 | sys.path.insert(0, os.path.abspath('../..'))
|
19 | 20 |
|
20 | 21 |
|
21 | 22 | # -- Project information -----------------------------------------------------
|
22 | 23 | # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
|
23 | 24 |
|
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) |
25 | 44 |
|
26 | 45 | project = 'InstaWebhooks'
|
27 | 46 | copyright = f'2024-{datetime.now(tz=timezone.utc).year}, Ryan Luu'
|
|
0 commit comments