#!/usr/bin/env python3
import sys
import re
import os

VERSION_PATTERN = r'\d+\.\d+(?:\.\d+)?'
FILES_PATTERNS = [ ('bin/fypp', 
                    r'^VERSION\s*=\s*([\'"]){}\1'.format(VERSION_PATTERN), 
                    "VERSION = '{}'"),
                   ('docs/fypp.rst',
                    r'Fypp Version[ ]*{}.'.format(VERSION_PATTERN),
                    'Fypp Version {}.'),
                   ('setup.py',
                    r'version\s*=\s*([\'"]){}\1'.format(VERSION_PATTERN),
                    "version='{}'"),
]

if len(sys.argv) < 2:
    print("Missing version string")
    sys.exit(1)
version = sys.argv[1]
match = re.match(VERSION_PATTERN, version)
if match is None:
    print("Invalid version string")
    sys.exit(1)

rootdir = os.path.join(os.path.dirname(sys.argv[0]), '..')
for fname, regexp, repl in FILES_PATTERNS:
    fname = os.path.join(rootdir, fname)
    print("Replacments in '{}': ".format(fname), end='')
    fp = open(fname, 'r')
    txt = fp.read()
    fp.close()
    newtxt, nsub = re.subn(regexp, repl.format(version), txt, 
                           flags=re.MULTILINE)
    print(nsub)
    fp = open(fname, 'w')
    fp.write(newtxt)
    fp.close()

@@ -230,22 +230,29 @@
 ION = '%7B
+version
 %7D'%22),%0A
-
         
@@ -383,16 +383,28 @@
 ersion %7B
+shortversion
 %7D.'),%0A  
@@ -538,16 +538,340 @@
 rsion='%7B
+version%7D'%22),%0A                   ('docs/conf.py',%0A                    r'version%5Cs*=%5Cs*(%5B%5C'%22%5D)%7B%7D%5C1'.format(VERSION_PATTERN),%0A                    %22version = '%7Bshortversion%7D'%22),%0A                   ('docs/conf.py',%0A                    r'release%5Cs*=%5Cs*(%5B%5C'%22%5D)%7B%7D%5C1'.format(VERSION_PATTERN),%0A                    %22release = '%7Bversion
 %7D'%22),%0A%5D%0A
@@ -945,16 +945,18 @@
 exit(1)%0A
+%0A%0A
 version 
@@ -969,16 +969,66 @@
 argv%5B1%5D%0A
+shortversion = '.'.join(version.split('.')%5B0:2%5D)%0A%0A
 match = 
@@ -1402,93 +1402,130 @@
     
-newtxt, nsub = re.subn(regexp, repl.format(version), txt, %0A                          
+replacement = repl.format(version=version, shortversion=shortversion)%0A    newtxt, nsub = re.subn(regexp, replacement, txt,
  fla

Extend version bumping to docs/conf.py.