Skip to content

Commit 457b2ea

Browse files
committed
scripts/release.py: port to poetry
1 parent 7edad8f commit 457b2ea

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

scripts/release.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
#!/usr/bin/env python3
22

33
import argparse
4-
import re
54
import subprocess
65
import sys
76
from pathlib import Path
87
from typing import Iterable
8+
from shutil import which
99

1010

1111
class UsageError(Exception):
1212
pass
1313

1414

15-
def parse_version():
16-
with Path("setup.py").open() as infile:
17-
for line in infile:
18-
if m := re.match(r"VERSION\s*=\s*\"(.*)\"$", line):
19-
return m.groups()[0]
15+
def parse_version() -> str:
16+
output = subprocess.check_output(["poetry", "version", "--short"], encoding="utf-8")
17+
version = output.strip()
18+
19+
return version
2020

2121

2222
def bump_version(path: Path, prefix_list: Iterable[str], current_version: str, new_version: str):
@@ -46,6 +46,12 @@ def check_changelog():
4646
raise UsageError("No new changelog entries")
4747

4848

49+
def check_environment():
50+
for binary in ("git", "make", "poetry"):
51+
if not which(binary):
52+
raise UsageError("No such binary: {}".format(binary))
53+
54+
4955
def main():
5056
parser = argparse.ArgumentParser()
5157
parser.add_argument("new_version", help="Version to release")
@@ -64,10 +70,10 @@ def main():
6470

6571
check_changelog()
6672

67-
bump_version(Path("setup.py"), ["VERSION"], current_version, new_version)
6873
bump_version(Path("doc/conf.py"), ["version"], current_version, new_version)
74+
subprocess.check_call(["poetry", "version", new_version])
6975

70-
git("add", "setup.py", "doc/conf.py")
76+
git("add", "pyproject.toml", "doc/conf.py")
7177
git("commit", "-m", "Version bump to {}".format(new_version))
7278
git("tag", new_version)
7379
make("changes")

0 commit comments

Comments
 (0)