|
1 | 1 | import glob |
| 2 | +import json |
| 3 | +import os |
| 4 | +import sys |
2 | 5 | from setuptools import setup, find_packages |
3 | 6 |
|
4 | 7 | with open('matlab_kernel/__init__.py', 'rb') as fid: |
|
9 | 12 | break |
10 | 13 |
|
11 | 14 | DISTNAME = 'matlab_kernel' |
| 15 | + |
| 16 | +# generating kernel.json for both kernels |
| 17 | +os.makedirs(os.path.join(DISTNAME, 'matlab'), exist_ok=True) |
| 18 | +with open(os.path.join(DISTNAME, 'kernel_template.json'), 'r') as fp: |
| 19 | + matlab_json = json.load(fp) |
| 20 | +matlab_json['argv'][0] = sys.executable |
| 21 | +with open(os.path.join(DISTNAME, 'matlab','kernel.json'), 'w') as fp: |
| 22 | + json.dump(matlab_json, fp) |
| 23 | + |
| 24 | +os.makedirs(os.path.join(DISTNAME, 'matlab_connect'), exist_ok=True) |
| 25 | +with open(os.path.join(DISTNAME, 'kernel_template.json'), 'r') as fp: |
| 26 | + matlab_json = json.load(fp) |
| 27 | +matlab_json['argv'][0] = sys.executable |
| 28 | +matlab_json['display_name'] = 'Matlab (Connection)' |
| 29 | +matlab_json['name'] = "matlab_connect" |
| 30 | +matlab_json['env'] = {'connect-to-existing-kernel': '1'} |
| 31 | +with open(os.path.join(DISTNAME, 'matlab_connect','kernel.json'), 'w') as fp: |
| 32 | + json.dump(matlab_json, fp) |
| 33 | + |
12 | 34 | PACKAGE_DATA = { |
13 | 35 | DISTNAME: ['*.m'] + glob.glob('%s/**/*.*' % DISTNAME) |
14 | 36 | } |
15 | 37 | DATA_FILES = [ |
16 | 38 | ('share/jupyter/kernels/matlab', [ |
17 | | - '%s/kernel.json' % DISTNAME |
| 39 | + '%s/matlab/kernel.json' % DISTNAME |
| 40 | + ] + glob.glob('%s/images/*.png' % DISTNAME) |
| 41 | + ), |
| 42 | + ('share/jupyter/kernels/matlab_connect', [ |
| 43 | + '%s/matlab_connect/kernel.json' % DISTNAME |
18 | 44 | ] + glob.glob('%s/images/*.png' % DISTNAME) |
19 | 45 | ) |
20 | 46 | ] |
|
0 commit comments