Skip to content

Commit d94eb62

Browse files
authored
Only do --user installs if we think we are not in a venv/virtualenv (#409)
Signed-off-by: Chad Wilson <[email protected]>
1 parent aa95835 commit d94eb62

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

build.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,18 @@
2828
def install():
2929
plugin_zip = create_zip()
3030
call(['gauge', 'uninstall', 'python', '-v', get_version()])
31-
exit_code = call(['gauge', 'install', 'python', '-f',
32-
os.path.join(BIN, plugin_zip)])
31+
exit_code = call(['gauge', 'install', 'python', '-f', os.path.join(BIN, plugin_zip)])
3332
generate_package()
3433
p = os.listdir("dist")[0]
3534
print(f"Installing getgauge package using pip: \n\tpip install dist/{p}")
36-
call([sys.executable, "-m", "pip", "install",
37-
f"dist/{p}", "--upgrade", "--user"])
35+
install_cmd = [sys.executable, "-m", "pip", "install", f"dist/{p}", "--upgrade"]
36+
if not in_venv():
37+
install_cmd.append("--user")
38+
call(install_cmd)
3839
sys.exit(exit_code)
3940

41+
def in_venv():
42+
return sys.prefix != sys.base_prefix
4043

4144
def create_setup_file():
4245
with open("setup.tmpl", "r", encoding="utf-8") as tmpl:

check_and_install_getgauge.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,15 @@ def get_version():
1414
return ''
1515

1616
def install_getgauge(getgauge_version):
17-
install_cmd = [sys.executable, "-m", "pip", "install", getgauge_version, "--user"]
17+
install_cmd = [sys.executable, "-m", "pip", "install", getgauge_version]
18+
if not in_venv():
19+
install_cmd.append("--user")
1820
if "dev" in getgauge_version:
1921
install_cmd.append("--pre")
2022
check_output([" ".join(install_cmd)], shell=True)
2123

24+
def in_venv():
25+
return sys.prefix != sys.base_prefix
2226

2327
def assert_versions():
2428
python_plugin_version = get_version()

python.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"id": "python",
3-
"version": "0.4.7",
3+
"version": "0.4.8",
44
"description": "Python support for gauge",
55
"run": {
66
"windows": [

0 commit comments

Comments
 (0)