From bfd6aefe4d4c0a03d176fb9bd35945493d97ecb3 Mon Sep 17 00:00:00 2001
From: Tue Herlau <tuhe@dtu.dk>
Date: Thu, 13 Jul 2023 14:00:16 +0200
Subject: [PATCH] Robust approach to python executable for virtual environments

---
 src/codesnipper.egg-info/PKG-INFO | 2 +-
 src/snipper/fix_i.py              | 6 ++++--
 src/snipper/version.py            | 2 +-
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/codesnipper.egg-info/PKG-INFO b/src/codesnipper.egg-info/PKG-INFO
index ddbe216..0112cf2 100644
--- a/src/codesnipper.egg-info/PKG-INFO
+++ b/src/codesnipper.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 2.1
 Name: codesnipper
-Version: 0.1.18.5
+Version: 0.1.18.6
 Summary: A lightweight framework for censoring student solutions files and extracting code + output
 Home-page: https://lab.compute.dtu.dk/tuhe/snipper
 Author: Tue Herlau
diff --git a/src/snipper/fix_i.py b/src/snipper/fix_i.py
index 5ddbba5..ed413f5 100644
--- a/src/snipper/fix_i.py
+++ b/src/snipper/fix_i.py
@@ -2,6 +2,8 @@ import functools
 import textwrap
 from snipper.legacy import block_process
 from snipper.block_parsing import full_strip
+import sys
+
 import os
 if os.name == 'nt':
     import wexpect as we
@@ -22,7 +24,7 @@ def rsession(analyzer, lines, extra):
             print(k['output'])
 
         import time
-        an = we.spawn("python", encoding="utf-8", timeout=20)
+        an = we.spawn(sys.executable, encoding="utf-8", timeout=20)
         try:
             an.setwinsize(400, 400) # set window size to avoid truncated output or input.
         except AttributeError as e:
@@ -133,7 +135,7 @@ def run_i(lines, file, output):
         # an.setecho(True) # TH January 2023: Seems to fix an issue on linux with truncated lines. May cause problems on windows?
 
         if extra['python'] is None:
-            an = we.spawn("python", encoding="utf-8", timeout=20)
+            an = we.spawn(sys.executable, encoding="utf-8", timeout=20)
             try:
                 an.setwinsize(400, 400)  # set window size to avoid truncated output or input.
             except AttributeError as e:
diff --git a/src/snipper/version.py b/src/snipper/version.py
index 569cd72..3c26865 100644
--- a/src/snipper/version.py
+++ b/src/snipper/version.py
@@ -1 +1 @@
-__version__ = "0.1.18.5"
+__version__ = "0.1.18.6"
-- 
GitLab