Skip to content

Commit

Permalink
Merge pull request #161 from RibomBalt/master
Browse files Browse the repository at this point in the history
  • Loading branch information
blink1073 authored May 9, 2022
2 parents 433723d + f2b5e0f commit 96533ae
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,28 @@
break

DISTNAME = 'matlab_kernel'
PY_EXECUTABLE = 'python'

# when building wheels, directly use 'python' in the kernelspec.
if any(a.startswith("bdist") for a in sys.argv):
PY_EXECUTABLE = 'python'

# when directly installing, use sys.executable to get python full path.
if any(a.startswith("install") for a in sys.argv):
PY_EXECUTABLE = sys.executable

# generating kernel.json for both kernels
os.makedirs(os.path.join(DISTNAME, 'matlab'), exist_ok=True)
with open(os.path.join(DISTNAME, 'kernel_template.json'), 'r') as fp:
matlab_json = json.load(fp)
matlab_json['argv'][0] = sys.executable
matlab_json['argv'][0] = PY_EXECUTABLE
with open(os.path.join(DISTNAME, 'matlab','kernel.json'), 'w') as fp:
json.dump(matlab_json, fp)

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

0 comments on commit 96533ae

Please sign in to comment.