Skip to content

Commit f2b5e0f

Browse files
committed
handle python executable when building wheels
1 parent 433723d commit f2b5e0f

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

setup.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,28 @@
1212
break
1313

1414
DISTNAME = 'matlab_kernel'
15+
PY_EXECUTABLE = 'python'
16+
17+
# when building wheels, directly use 'python' in the kernelspec.
18+
if any(a.startswith("bdist") for a in sys.argv):
19+
PY_EXECUTABLE = 'python'
20+
21+
# when directly installing, use sys.executable to get python full path.
22+
if any(a.startswith("install") for a in sys.argv):
23+
PY_EXECUTABLE = sys.executable
1524

1625
# generating kernel.json for both kernels
1726
os.makedirs(os.path.join(DISTNAME, 'matlab'), exist_ok=True)
1827
with open(os.path.join(DISTNAME, 'kernel_template.json'), 'r') as fp:
1928
matlab_json = json.load(fp)
20-
matlab_json['argv'][0] = sys.executable
29+
matlab_json['argv'][0] = PY_EXECUTABLE
2130
with open(os.path.join(DISTNAME, 'matlab','kernel.json'), 'w') as fp:
2231
json.dump(matlab_json, fp)
2332

2433
os.makedirs(os.path.join(DISTNAME, 'matlab_connect'), exist_ok=True)
2534
with open(os.path.join(DISTNAME, 'kernel_template.json'), 'r') as fp:
2635
matlab_json = json.load(fp)
27-
matlab_json['argv'][0] = sys.executable
36+
matlab_json['argv'][0] = PY_EXECUTABLE
2837
matlab_json['display_name'] = 'Matlab (Connection)'
2938
matlab_json['name'] = "matlab_connect"
3039
matlab_json['env'] = {'connect-to-existing-kernel': '1'}

0 commit comments

Comments
 (0)