Commit 1ddd62f7 authored by Owen Arnold's avatar Owen Arnold
Browse files
parent 3ff5e0df
......@@ -3,78 +3,43 @@
Can either be used to install a specific wfm-stitching package version, or without modification,
will install the latest version.
You MUST run this script inside MantidPlot from the script window,
or by invoking mantidplot with the -xq option. You need to do this after installing Mantid.
You should run this script inside MantidPlot from the script window, to ensure that you are using
the same python interpreter that Mantid uses. The installation must use the same python interpreter
that mantid uses.
You can install from the command line using the lauch_mantid_plot executable with the xq (execute and quit)
option set, you can also pass a version to installation script, if not provided it will fetch
the latest wfm_stitching package.
C:\\MantidInstall\\bin\\launch_mantidplot -x
C:\\MantidInstall\\bin\\launch_mantidplot -x --version 0.1.0
import subprocess
import sys
import re
import argparse
import os
from distutils.version import LooseVersion
import sys
def extract_wfm_version(python):
""" Extract and return the version of any installed wfm-stitching package currently installed.
If the package is not present throws RuntimeError
out = subprocess.Popen([python, '-m' 'pip', 'show', 'wfm-stitching'], stdin=subprocess.PIPE, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
package_details = out.communicate()[0]
if not package_details:
raise RuntimeError('No wfm-stitching pip package installed')
# Take the version from the pip information of the package
actual_version ='Version:\s+((\d+\.)(\d+\.)(\*|\d+))', package_details).group(1)
return LooseVersion(actual_version)
def extract_upload_url(python, required_version=None):
""" From gitlab project releases fetch the download url for the release matching the tag
import gitlab
except ImportError:
subprocess.check_call([python, '-m' 'pip', 'install', '--upgrade', '--user', 'python-gitlab'])
import gitlab
gl = gitlab.Gitlab('')
project = gl.projects.list(search='wfm_stitching')[0]
if required_version:
tag = project.tags.get('v{0}'.format(required_version))
# Get the latest tag
tag = project.tags.list(order_by='updated', sort='desc')[0]
description = tag.attributes['release']['description']
# Search for mark-down style upload in the form [link-text](upload-url) and extract upload-url
upload ='\[.*\]\((.*)\)', description).group(1)
# Join with the project web url to obtain the full address
upload_url = project.attributes['web_url'] + upload
return upload_url
def do_wfm_stitching_install(python, required_version):
"""Perform the installation of the wfm-stitching pip (wheel) package.
Updgrades if already installed. Installation goes to user area."""
package_url = extract_upload_url(python, required_version)
# Try to install or upgrade the package
subprocess.check_call([python, '-m' 'pip', 'install', '--upgrade', '--user', package_url])
# Check that the installation or upgrade worked
actual_version = extract_wfm_version(python)
if required_version and (not actual_version == required_version):
print('Warning wrong version installed {0}'.format(actual_version))
print('Successfully installed wfm-stitching {0}'.format(str(actual_version)))
url = 'git+'
if required_version:
url = '{0}@{1}'.format(url, required_version)
subprocess.check_call([python, '-m' 'pip', 'install', '--user', '--upgrade', url])
def do_wfm_stitching_uninstall(python):
"""Convenience function to allow the removal of the wfm-stitching package"""
subprocess.check_call([python, '-m' 'pip', 'uninstall', '-y', 'wfm-stitching'])
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Install WFM core package from')
parser.add_argument('-v', '--version', default=None, help='optionally specify the version you wish to use i.e. v0.1.2. Defaults to latest version')
args = parser.parse_args()
interpreter = os.path.join(os.path.dirname(sys.executable), 'python')
# Optionally provide a specific tag as required_version argument i.e: LooseVersion('0.1.1')
do_wfm_stitching_install(interpreter, required_version=None)
do_wfm_stitching_install(interpreter, required_version=args.version)
Supports Markdown
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