|
16 | 16 | # import sys
|
17 | 17 | # sys.path.insert(0, os.path.abspath('.'))
|
18 | 18 |
|
| 19 | +import subprocess |
| 20 | +import os |
| 21 | +import re |
| 22 | + |
| 23 | +# -- Functions --------------------------------------------------------------- |
| 24 | + |
| 25 | +def get_version(): |
| 26 | + """Get version from git describe or fallback file.""" |
| 27 | + # Get the repository root (two levels up from docs/source/) |
| 28 | + repo_root = os.path.join(os.path.dirname(__file__), '..', '..') |
| 29 | + repo_root = os.path.abspath(repo_root) |
| 30 | + |
| 31 | + try: |
| 32 | + # Try to get version from git |
| 33 | + if os.path.exists(os.path.join(repo_root, '.git')) or os.environ.get('GITHUB_ACTIONS'): |
| 34 | + result = subprocess.run( |
| 35 | + ['git', 'describe', '--tags', '--dirty', '--always'], |
| 36 | + cwd=repo_root, # Run git command from repository root |
| 37 | + capture_output=True, |
| 38 | + text=True, |
| 39 | + check=True |
| 40 | + ) |
| 41 | + full_version = result.stdout.strip() |
| 42 | + |
| 43 | + # Remove 'v' prefix if present |
| 44 | + if full_version.startswith('v'): |
| 45 | + full_version = full_version[1:] |
| 46 | + |
| 47 | + # Extract short version (X.Y) from full version |
| 48 | + version_match = re.match(r'(\d+\.\d+)', full_version) |
| 49 | + short_version = version_match.group(1) if version_match else '1.0' |
| 50 | + |
| 51 | + return short_version, full_version |
| 52 | + |
| 53 | + except (subprocess.CalledProcessError, FileNotFoundError): |
| 54 | + pass |
| 55 | + |
| 56 | + # Fallback: try to read from tarball version file |
| 57 | + try: |
| 58 | + tarball_version_path = os.path.join(repo_root, '.tarball-version') |
| 59 | + if os.path.exists(tarball_version_path): |
| 60 | + with open(tarball_version_path, 'r') as f: |
| 61 | + full_version = f.read().strip() |
| 62 | + if full_version.startswith('v'): |
| 63 | + full_version = full_version[1:] |
| 64 | + |
| 65 | + version_match = re.match(r'(\d+\.\d+)', full_version) |
| 66 | + short_version = version_match.group(1) if version_match else '1.0' |
| 67 | + |
| 68 | + return short_version, full_version |
| 69 | + except (IOError, OSError): |
| 70 | + pass |
| 71 | + |
| 72 | + # Final fallback |
| 73 | + return '1.0', '1.0.0-unknown' |
19 | 74 |
|
20 | 75 | # -- Project information -----------------------------------------------------
|
21 | 76 |
|
22 | 77 | project = 'Directory File Show (DF-SHOW)'
|
23 |
| -copyright = '2024, Robert Ian Hawdon' |
| 78 | +copyright = '2025, Robert Ian Hawdon' |
24 | 79 | author = 'Robert Ian Hawdon'
|
25 | 80 |
|
26 | 81 | # The short X.Y version
|
27 |
| -version = '0.10' |
| 82 | +# version = '1.0' |
28 | 83 | # The full version, including alpha/beta/rc tags
|
29 |
| -release = '0.10.3-beta' |
| 84 | +# release = '1.0.0-b.1' |
30 | 85 |
|
| 86 | +version, release = get_version() |
31 | 87 |
|
32 | 88 | # -- General configuration ---------------------------------------------------
|
33 | 89 |
|
|
0 commit comments