Skip to content

Commit d327ce1

Browse files
committed
Update version generation so it doesn't break dependencies
1 parent b01f41b commit d327ce1

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

setup.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,27 @@
1+
import re
2+
13
from setuptools import setup, find_packages
2-
import sys, os
34

4-
from yajl import __version__ as version
5+
6+
def get_version() -> str:
7+
"""
8+
Read the version value from the __init__ file without importing it.
9+
This fixes the missing dependencies issue when installing the package.
10+
"""
11+
file_path = "yajl/__init__.py"
12+
version_pattern = re.compile(r"__version__\s*=\s*['\"]([^'\"]+)['\"]")
13+
with open(file_path, 'r') as file:
14+
for line in file:
15+
match = version_pattern.search(line)
16+
if match:
17+
return match.group(1)
18+
19+
# If we get here, we didn't find a version - raise an exception.
20+
raise RuntimeError("Unable to find version string.")
21+
522

623
setup(name='yajl-py',
7-
version=version,
24+
version=get_version(),
825
description="Pure Python Yajl Wrapper",
926
long_description="""\
1027
Pure Python wrapper to the excellent Yajl (Yet Another Json Library) C library""",

0 commit comments

Comments
 (0)