|
8 | 8 |
|
9 | 9 | from setuptools import setup, find_packages |
10 | 10 | import re |
11 | | -import sys |
12 | 11 | import os |
13 | 12 |
|
14 | | -SRC_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)),"./src") |
15 | | -if SRC_DIR not in sys.path: |
16 | | - sys.path.insert(0,SRC_DIR) |
17 | | -from direpack import __version__, __author__, __license__ |
| 13 | + |
| 14 | +def get_version(): |
| 15 | + """Read version from __init__.py without importing the module.""" |
| 16 | + init_file = os.path.join( |
| 17 | + os.path.dirname(os.path.abspath(__file__)), |
| 18 | + "src", "direpack", "__init__.py" |
| 19 | + ) |
| 20 | + with open(init_file, "r") as f: |
| 21 | + content = f.read() |
| 22 | + version_match = re.search(r'^__version__\s*=\s*["\']([^"\']+)["\']', content, re.MULTILINE) |
| 23 | + if version_match: |
| 24 | + return version_match.group(1) |
| 25 | + raise RuntimeError("Unable to find version string.") |
| 26 | + |
| 27 | + |
| 28 | +def get_metadata(): |
| 29 | + """Read author and license from __init__.py without importing.""" |
| 30 | + init_file = os.path.join( |
| 31 | + os.path.dirname(os.path.abspath(__file__)), |
| 32 | + "src", "direpack", "__init__.py" |
| 33 | + ) |
| 34 | + with open(init_file, "r") as f: |
| 35 | + content = f.read() |
| 36 | + author_match = re.search(r'^__author__\s*=\s*["\']([^"\']+)["\']', content, re.MULTILINE) |
| 37 | + license_match = re.search(r'^__license__\s*=\s*["\']([^"\']+)["\']', content, re.MULTILINE) |
| 38 | + return ( |
| 39 | + author_match.group(1) if author_match else "Unknown", |
| 40 | + license_match.group(1) if license_match else "MIT" |
| 41 | + ) |
| 42 | + |
| 43 | + |
| 44 | +__version__ = get_version() |
| 45 | +__author__, __license__ = get_metadata() |
18 | 46 |
|
19 | 47 | readme_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'README.md') |
20 | 48 | try: |
|
0 commit comments