|
12 | 12 | break
|
13 | 13 |
|
14 | 14 | 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 |
15 | 24 |
|
16 | 25 | # generating kernel.json for both kernels
|
17 | 26 | os.makedirs(os.path.join(DISTNAME, 'matlab'), exist_ok=True)
|
18 | 27 | with open(os.path.join(DISTNAME, 'kernel_template.json'), 'r') as fp:
|
19 | 28 | matlab_json = json.load(fp)
|
20 |
| -matlab_json['argv'][0] = sys.executable |
| 29 | +matlab_json['argv'][0] = PY_EXECUTABLE |
21 | 30 | with open(os.path.join(DISTNAME, 'matlab','kernel.json'), 'w') as fp:
|
22 | 31 | json.dump(matlab_json, fp)
|
23 | 32 |
|
24 | 33 | os.makedirs(os.path.join(DISTNAME, 'matlab_connect'), exist_ok=True)
|
25 | 34 | with open(os.path.join(DISTNAME, 'kernel_template.json'), 'r') as fp:
|
26 | 35 | matlab_json = json.load(fp)
|
27 |
| -matlab_json['argv'][0] = sys.executable |
| 36 | +matlab_json['argv'][0] = PY_EXECUTABLE |
28 | 37 | matlab_json['display_name'] = 'Matlab (Connection)'
|
29 | 38 | matlab_json['name'] = "matlab_connect"
|
30 | 39 | matlab_json['env'] = {'connect-to-existing-kernel': '1'}
|
|
0 commit comments