-
Notifications
You must be signed in to change notification settings - Fork 5
/
tasks.py
49 lines (41 loc) · 1.37 KB
/
tasks.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# type:ignore
# flake8: noqa
import os
import sys
import glob
from invoke import task
@task
def lint(c):
"""run linting"""
files = glob.glob("./**/CMakeLists.txt") + ["CMakeLists.txt"]
cmd = ["cmake-format -i"] + files
c.run(" ".join(cmd))
c.run("clang-format -style=file -i bindings/c/include/cgenalyzer_simplified_beta.h")
c.run("black bindings/python")
@task
def bumpversion_test(c, filename=None):
"""Bump version to {current-version}.dev.{date}
Used for marking development releases for test-pypi
"""
import fileinput
import time
if filename is None:
filename = "bindings/python/pyproject.toml"
if not os.path.isfile(filename):
raise FileNotFoundError(filename)
for line in fileinput.input(filename, inplace=True):
if line.find("version = ") > -1:
s = line.find("version = ")
l = line[s+len("version = ") + 1 :].strip()
l = l.replace('"', "")
l = l.split(".")
major = int(l[0])
minor = int(l[1])
rev = int(l[2])
seconds = int(time.time())
line = ' '*s+'version = "{}.{}.{}.dev.{}"\n'.format(
major, minor, rev, seconds
)
ver_string = "{}.{}.{}.dev.{}".format(major, minor, rev, seconds)
print(line, end="")
print(f"Version bumped to {ver_string}")