forked from analogdevicesinc/genalyzer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tasks.py
47 lines (39 loc) · 1.3 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
# 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.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 = "build/bindings/python/setup.py"
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()[:-2].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}")