Skip to content

Commit 0f3f45e

Browse files
committed
move to dephell for generating requirements.txt and simplify version bumping
1 parent caa1227 commit 0f3f45e

File tree

4 files changed

+43
-1
lines changed

4 files changed

+43
-1
lines changed

Makefile

+5
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,10 @@
33
#
44
# Shortcuts for various tasks.
55

6+
bump-version:
7+
dephell deps convert --from=setup.py --to=requirements.txt
8+
python tools/bump-version.py --get-current
9+
python tools/bump-version.py --set-version
10+
611
sdist:
712
python setup.py sdist

requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
lark-parser<0.8.0,>=0.7.1

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from setuptools import setup, find_packages
77

88

9-
__version__ = '.'.join(map(str, (0, 9, 0)))
9+
__version__ = '0.9.0'
1010

1111
install_requires = [
1212
'lark-parser>=0.7.1,<0.8.0'

tools/bump-version.py

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import re
2+
import sys
3+
4+
5+
VERSION_RE = r'\'(([0-9]+\.){2}[0-9])\''
6+
7+
8+
if __name__ == '__main__':
9+
cmd = sys.argv[1]
10+
11+
if cmd == '--get-current':
12+
with open('setup.py') as fp:
13+
for line in fp.readlines():
14+
if '__version__' in line:
15+
match = re.search(VERSION_RE, line)
16+
if match:
17+
print(match.groups()[0])
18+
elif cmd == '--set-version':
19+
stdin_input = input()
20+
if not len(stdin_input):
21+
print('No input provided on stdin.')
22+
sys.exit(1)
23+
24+
lines = []
25+
with open('setup.py') as fp:
26+
for line in fp.readlines():
27+
if '__version__' in line:
28+
line = re.sub(VERSION_RE, '\'%s\'' % stdin_input, line)
29+
lines.append(line)
30+
31+
with open('setup.py', 'w') as fp:
32+
fp.write(''.join(lines))
33+
34+
else:
35+
print('Invalid command')
36+
sys.exit(1)

0 commit comments

Comments
 (0)