Skip to content

Commit b0c7b23

Browse files
committed
[roottest] Inherit python executable from main process in nbdiff.py
This makes sure that we're using the exact Python version in the notebook tests that ROOT was built against.
1 parent e829075 commit b0c7b23

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

roottest/python/JupyROOT/nbdiff.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"%s "
1818
"--output %s"
1919
)
20-
pythonInterpName = "python3"
20+
pythonInterpName = sys.executable
2121

2222
rootKernelFileContent = (
2323
"""{
@@ -161,16 +161,16 @@ def getKernelName(inNBName):
161161
with open(inNBName) as f:
162162
nbj = json.load(f)
163163
if nbj["metadata"]["kernelspec"]["language"] == "python":
164-
return pythonInterpName
164+
return "python3"
165165
else: # we support only Python and C++
166166
return "root"
167167

168168

169-
def canReproduceNotebook(inNBName, kernelName, needsCompare):
169+
def canReproduceNotebook(inNBName, needsCompare):
170170
tmpDir = addEtcToEnvironment(os.path.dirname(inNBName))
171171
outNBName = inNBName.replace(nbExtension, "_out" + nbExtension)
172172
interpName = getInterpreterName()
173-
convCmd = convCmdTmpl % (interpName, kernelName, inNBName, outNBName)
173+
convCmd = convCmdTmpl % (interpName, getKernelName(inNBName), inNBName, outNBName)
174174
exitStatus = os.system(convCmd) # we use system to inherit the environment in os.environ
175175
shutil.rmtree(tmpDir)
176176
if needsCompare:
@@ -206,7 +206,5 @@ def isInputNotebookFileName(filename):
206206
except:
207207
raise ImportError("Cannot import jupyter")
208208

209-
kernelName = getKernelName(nbFileName)
210-
211-
retCode = canReproduceNotebook(nbFileName, kernelName, needsCompare)
209+
retCode = canReproduceNotebook(nbFileName, needsCompare)
212210
sys.exit(retCode)

0 commit comments

Comments
 (0)