Skip to content

Commit

Permalink
Only do --user installs if we think we are not in a venv/virtualenv (#…
Browse files Browse the repository at this point in the history
…409)

Signed-off-by: Chad Wilson <chadw@thoughtworks.com>
  • Loading branch information
chadlwilson authored Nov 25, 2024
1 parent aa95835 commit d94eb62
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
11 changes: 7 additions & 4 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,18 @@
def install():
plugin_zip = create_zip()
call(['gauge', 'uninstall', 'python', '-v', get_version()])
exit_code = call(['gauge', 'install', 'python', '-f',
os.path.join(BIN, plugin_zip)])
exit_code = call(['gauge', 'install', 'python', '-f', os.path.join(BIN, plugin_zip)])
generate_package()
p = os.listdir("dist")[0]
print(f"Installing getgauge package using pip: \n\tpip install dist/{p}")
call([sys.executable, "-m", "pip", "install",
f"dist/{p}", "--upgrade", "--user"])
install_cmd = [sys.executable, "-m", "pip", "install", f"dist/{p}", "--upgrade"]
if not in_venv():
install_cmd.append("--user")
call(install_cmd)
sys.exit(exit_code)

def in_venv():
return sys.prefix != sys.base_prefix

def create_setup_file():
with open("setup.tmpl", "r", encoding="utf-8") as tmpl:
Expand Down
6 changes: 5 additions & 1 deletion check_and_install_getgauge.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@ def get_version():
return ''

def install_getgauge(getgauge_version):
install_cmd = [sys.executable, "-m", "pip", "install", getgauge_version, "--user"]
install_cmd = [sys.executable, "-m", "pip", "install", getgauge_version]
if not in_venv():
install_cmd.append("--user")
if "dev" in getgauge_version:
install_cmd.append("--pre")
check_output([" ".join(install_cmd)], shell=True)

def in_venv():
return sys.prefix != sys.base_prefix

def assert_versions():
python_plugin_version = get_version()
Expand Down
2 changes: 1 addition & 1 deletion python.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "python",
"version": "0.4.7",
"version": "0.4.8",
"description": "Python support for gauge",
"run": {
"windows": [
Expand Down

0 comments on commit d94eb62

Please sign in to comment.