Commit d9f06713 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Merge branch '57-build-version-plugin' into 'master'

57 build version plugin

* Add the command to install plugin in `build_version`.
* Add the file `VERSION`
* close #57 

See merge request !61
parents 9f00b990 ab0b56f7
0.9.5.2
\ No newline at end of file
......@@ -29,6 +29,7 @@ import sys
import tempfile
from glob import glob
from os.path import join as opj
from subprocess import call
......@@ -52,6 +53,7 @@ PDF = "pdf"
PDFDOC = opj(DOCS, PDF)
REFERENCE = 'reference'
USER = 'user'
VERSION = 'VERSION'
MSG_RELEASE = 'Enter the new release: '
......@@ -224,19 +226,14 @@ def compile_js():
def get_version():
"""Get the current version identifier in the CHANGELOG
"""Get the current version identifier in VERSION
Returns:
str: the version number
"""
log = open(CHANGELOG).read()
match = re.search(r"(\d+\.\d+(\.\d+)*)", log)
if match:
return match.group(1)
return ""
with open(VERSION, "rb") as fi:
return fi.read()
def git(*args, **kwargs):
......@@ -268,6 +265,125 @@ def git(*args, **kwargs):
call(cmd, **kwargs)
def install_plugins(args):
"""Install or update plugins.
Args:
args (argparse.Namespace): command arguments
"""
if args.plugins_tar:
install_plugins_tar(args.plugins_tar, args.plugins)
elif args.plugins_git:
for plugin in args.plugins:
install_plugin_git(args.plugins_git, plugin, args.plugins_release)
else:
print "Path to the plugins can be either a git repository",
print "or a tar file. One of them has to be defined !"
sys.exit(1)
def install_plugin_git(repository, plugin, release):
"""Install plugin from git repository
Args:
repository (str): path of the git repository.
plugin (str): name of the plugin to be installed.
release (str): release number for plugins.
"""
print "\nInstall plugin", plugin
# delete existing version
for path in glob("./*/plugin_%s*" % plugin):
print "Remove", path
call(["rm", "-rf", path])
# select the release
app_dir = os.getcwd()
os.chdir(repository)
git_dir = os.getcwd()
tag = ("master" if release == "latest" else release)
git("checkout", tag)
pattern = os.path.join(git_dir, "web2py.plugin.%s.*.w2p" % plugin)
paths = glob(pattern)
# select the compact version when possible
if len(paths) == 0:
print "No plugin", plugin
sys.exit(1)
elif len(paths) == 2:
for el in paths:
if el.endswith("min.w2p"):
path = el
break
else:
path = paths[0]
# install
print "tar", "-xf", path, "-C", app_dir
call(["tar", "-xf", path, "-C", app_dir])
# restore the git repository
git("checkout", "master")
os.chdir(app_dir)
def install_plugins_tar(path, plugins):
"""Install plugin from tar file
Args:
path (str): path of the tar file.
plugins (list): list of plugin to be installed.
"""
app_dir = os.getcwd()
# untar in /tmp
tar_dir = '/tmp/w2p_plugins'
if not os.path.exists(tar_dir):
os.mkdir(tar_dir)
call(["tar", "-xf", path, "-C", tar_dir])
# untar individual files
for plugin in plugins:
# delete existing version
for path in glob("./*/plugin_%s*" % plugin):
print "Remove", path
call(["rm", "-rf", path])
# get the plugin path
pattern = os.path.join(tar_dir, "web2py.plugin.%s.*.w2p" % plugin)
paths = glob(pattern)
# select the compact version when possible
if len(paths) == 0:
print "No plugin", plugin
sys.exit(1)
elif len(paths) == 2:
for el in paths:
if el.endswith("min.w2p"):
path = el
break
else:
path = paths[0]
# install
print "tar", "-xf", path, "-C", app_dir
call(["tar", "-xf", path, "-C", app_dir])
# cleam
call("cd /tmp && rm -rf w2p_plugins", shell=True)
def jsduck():
"""Generate the JavaScript documentation.
The HTML files are located in static/plugin_dbui/docs/jsduck
......@@ -292,9 +408,9 @@ def jsduck():
call(cmd)
# run JsDuck
cmd = ["jsduck", EXTJSSRC, JSLIBSRC, \
"--output", JSDOC, \
"--title", "plugin_dbui %s" % get_version(), \
cmd = ["jsduck", EXTJSSRC, JSLIBSRC,
"--output", JSDOC,
"--title", "plugin_dbui %s" % get_version(),
"--warnings=-all:" + EXTJSSRC]
call(cmd)
......@@ -303,7 +419,7 @@ def jsduck():
def set_version(version):
"""Set release identifier in CHANGELOG.
"""Set release identifier in CHANGELOG and VERSION.
Args:
version (str): release identifier
......@@ -327,7 +443,7 @@ def set_version(version):
match = re.match("(.+HEAD\n)(.*)", txt, re.DOTALL)
if match == None:
if match is None:
print '\n\tNo HEAD tag in the CHANGELOG!\n'
rep = raw_input('\tDo you want to continue [n]?')
if rep not in ('y', 'yes'):
......@@ -346,6 +462,11 @@ def set_version(version):
if os.path.exists(filename):
os.remove(filename)
# update VERSION
os.remove(VERSION)
with open(VERSION, 'wb') as fichier:
fichier.write(version)
def sphinx(*args, **kwargs):
"""run the sphinx-build:
......@@ -435,7 +556,7 @@ if __name__ == '__main__':
APS.add_argument("-b", "--build",
action="store_true",
help="build the javascript library and the documentation.")
help="build the js library and the documentation.")
APS.add_argument("-c", "--compile",
action="store_true",
......@@ -481,10 +602,32 @@ if __name__ == '__main__':
APS.add_argument("-w", "--write-release",
action="store_true",
help="write the release number in CHANGELOG. "
help="write the release number in CHANGELOG and VERSION. "
"To be used with --commit-changelog. "
"Recommend to use --start-release.")
APS.add_argument("--plugins",
nargs="+",
help="plugins to be installed. To be used with "
"--plugin-release and --plugin-git or --plugin-tar."
" Possible values are ace, dbui, extjs and mathjax.",
metavar="<plugin>")
APS.add_argument("--plugins-release",
default="latest",
help="release number for plugin [%(default)s]. "
"To be used with --plugin-git.",
metavar="<release>")
APS.add_argument("--plugins-git",
default="../plugin_dbui_build",
help="git repository containing plugins [%(default)s].",
metavar="<path>")
APS.add_argument("--plugins-tar",
help="tar file containing the plugins",
metavar="<path>")
ARGS = APS.parse_args()
if ARGS.api_doc:
......@@ -505,6 +648,9 @@ if __name__ == '__main__':
if ARGS.jsduck:
jsduck()
if ARGS.plugins:
install_plugins(ARGS)
if ARGS.write_release:
set_version(raw_input(MSG_RELEASE))
......
......@@ -12,11 +12,11 @@
# serve to show the default.
import os
import re
import sys
from datetime import datetime
def get_version():
"""Get the current version identifier.
......@@ -24,13 +24,8 @@ def get_version():
str: the version number
"""
log = open('../../static/CHANGELOG').read()
match = re.search(r"(\d+\.\d+(\.\d+)*)", log)
if match:
return match.group(1)
return ""
with open('../../VERSION') as fi:
return fi.read()
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
......
......@@ -12,13 +12,6 @@
# All configuration values have a default; values that are commented out
# serve to show the default.
import sys
import os
import re
import shlex
import tempfile
from datetime import datetime
from subprocess import call
......@@ -30,13 +23,8 @@ def get_version():
str: the version number
"""
log = open('../../static/CHANGELOG').read()
match = re.search(r"(\d+\.\d+(\.\d+)*)", log)
if match:
return match.group(1)
return ""
with open('../../VERSION') as fi:
return fi.read()
def git(*args, **kwargs):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment