Skip to content

Commit

Permalink
fix version parsing issue that only happens when code is run using se…
Browse files Browse the repository at this point in the history
…tup.py; not sure why this works for dbt-snowflake
  • Loading branch information
codeforkjeff committed Dec 9, 2021
1 parent 17df33b commit e36a1db
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,15 @@ def _get_plugin_version_dict():
this_directory, 'dbt', 'adapters', 'sqlite', '__version__.py'
)
_semver = r'''(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)'''
_pre = r'''((?P<prekind>a|b|rc)(?P<pre>\d+))?'''
_version_pattern = fr'''version\s*=\s*["']{_semver}{_pre}["']'''

# not sure why this works in dbt-snowflake:
# it causes setuptools to populate prekind and pre with 'None' strings
# so we just don't parse it

#_pre = r'''((?P<prekind>a|b|rc)(?P<pre>\d+))?'''
#_version_pattern = fr'''version\s*=\s*["']{_semver}{_pre}["']'''

_version_pattern = fr'''version\s*=\s*["']{_semver}["']'''
with open(_version_path) as f:
match = re.search(_version_pattern, f.read().strip())
if match is None:
Expand All @@ -25,7 +32,8 @@ def _get_plugin_version_dict():

def _get_plugin_version():
parts = _get_plugin_version_dict()
return "{major}.{minor}.{patch}{prekind}{pre}".format(**parts)
#return "{major}.{minor}.{patch}{prekind}{pre}".format(**parts)
return "{major}.{minor}.{patch}".format(**parts)


package_name = "dbt-sqlite"
Expand Down

0 comments on commit e36a1db

Please sign in to comment.