File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change 66import sys
77
88
9- sys .path .insert (0 , os .path .abspath (".." ))
9+ from pathlib import Path
10+ import re
1011
11- from sqlite3_to_mysql import __version__
12+ ROOT = Path (__file__ ).resolve ().parents [1 ]
13+ SRC = ROOT / "src"
14+ sys .path .insert (0 , str (SRC ))
15+
16+ from importlib .metadata import PackageNotFoundError , version as pkg_version
17+
18+
19+ def _version_from_source () -> str :
20+ init_py = SRC / "sqlite3_to_mysql" / "__init__.py"
21+ m = re .search (r'^__version__\s*=\s*[\'"]([^\'"]+)[\'"]' , init_py .read_text (encoding = "utf-8" ), re .M )
22+ return m .group (1 ) if m else "0+unknown"
23+
24+
25+ try :
26+ __version__ = pkg_version ("sqlite3-to-mysql" )
27+ except PackageNotFoundError :
28+ __version__ = _version_from_source ()
1229
1330
1431# -- Project information -----------------------------------------------------
You can’t perform that action at this time.
0 commit comments