File tree Expand file tree Collapse file tree 1 file changed +20
-3
lines changed Expand file tree Collapse file tree 1 file changed +20
-3
lines changed Original file line number Diff line number Diff line change
1
+ import re
2
+
1
3
from setuptools import setup , find_packages
2
- import sys , os
3
4
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
+
5
22
6
23
setup (name = 'yajl-py' ,
7
- version = version ,
24
+ version = get_version () ,
8
25
description = "Pure Python Yajl Wrapper" ,
9
26
long_description = """\
10
27
Pure Python wrapper to the excellent Yajl (Yet Another Json Library) C library""" ,
You can’t perform that action at this time.
0 commit comments