Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pip executing on every run #152

Merged
merged 1 commit into from
Jul 24, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 11 additions & 15 deletions check_and_install_getgauge.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
import subprocess
import sys
import os
import pkg_resources
from distutils import version
from subprocess import Popen, PIPE
import json
import pkg_resources
from subprocess import check_output


def get_version():
proc = Popen("gauge -v --machine-readable",
stdout=PIPE, stderr=PIPE, shell=True)
out, _ = proc.communicate()
out = check_output(["gauge", "-v", "--machine-readable"])
data = json.loads(str(out.decode()))
for plugin in data['plugins']:
if plugin['name'] == 'python':
Expand All @@ -25,25 +20,26 @@ def get_dev_getgauge_version(plugin_nightly_version):


def install_getgauge(getgauge_version):
install_cmd = [sys.executable, "-m", "pip", "install", getgauge_version, "--user"]
if "dev" in getgauge_version:
subprocess.call([sys.executable, "-m", "pip", "install", "--pre",
getgauge_version, "--user"], stdout=open(os.devnull, 'wb'))
else:
subprocess.call([sys.executable, "-m", "pip", "install",
getgauge_version, "--user"], stdout=open(os.devnull, 'wb'))
install_cmd.append("--pre")
check_output(install_cmd)


def assert_versions():
python_plugin_version = get_version()
expected_gauge_version = python_plugin_version
if not python_plugin_version:
print('The gauge python plugin is not installed!')
exit(1)

expected_gauge_version = python_plugin_version
if "nightly" in python_plugin_version:
expected_gauge_version = get_dev_getgauge_version(
python_plugin_version)

try:
getgauge_version = pkg_resources.get_distribution('getgauge').version
if getgauge_version is not expected_gauge_version:
if getgauge_version != expected_gauge_version:
install_getgauge("getgauge=="+expected_gauge_version)
except pkg_resources.DistributionNotFound:
install_getgauge("getgauge=="+expected_gauge_version)
Expand Down