build: parse version from pyproject.toml when building release
This commit is contained in:
parent
b642f8d479
commit
5204e81c00
13
tasks.py
13
tasks.py
|
@ -4,13 +4,24 @@ Tasks for WuttJamaican
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
from invoke import task
|
from invoke import task
|
||||||
|
|
||||||
|
|
||||||
here = os.path.abspath(os.path.dirname(__file__))
|
here = os.path.abspath(os.path.dirname(__file__))
|
||||||
exec(open(os.path.join(here, 'src', 'wuttjamaican', '_version.py')).read())
|
__version__ = None
|
||||||
|
pattern = re.compile(r'^version = "(\d+\.\d+\.\d+)"$')
|
||||||
|
with open(os.path.join(here, 'pyproject.toml'), 'rt') as f:
|
||||||
|
for line in f:
|
||||||
|
line = line.rstrip('\n')
|
||||||
|
match = pattern.match(line)
|
||||||
|
if match:
|
||||||
|
__version__ = match.group(1)
|
||||||
|
break
|
||||||
|
if not __version__:
|
||||||
|
raise RuntimeError("could not parse version!")
|
||||||
|
|
||||||
|
|
||||||
@task
|
@task
|
||||||
|
|
Loading…
Reference in a new issue