Skip to content

Commit

Permalink
Merge pull request #54 from mottelet/patch-1
Browse files Browse the repository at this point in the history
detect macOS Scilab application bundle
  • Loading branch information
vincentcouvert authored Jul 10, 2024
2 parents bf40160 + 563cc0e commit 4dafa27
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ Add ``--user`` to install in the user-level environment instead of the system en

This kernel needs the Scilab executable to be run, it which will be searched in this order:
- Using environment variable ``SCILAB_EXECUTABLE``,
- Under Windows only, based on registry,
- Under Windows, based on registry,
- Under macOS, based on Spotlight database,
- Using the ``PATH`` environment variable.

Use the ``scilab-adv-cli`` executable if using a Posix-like OS, and ``WScilex-cli.exe`` if using Windows.
Expand Down
15 changes: 14 additions & 1 deletion scilab_kernel/kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
import re
import shutil
import sys
import platform
import tempfile
import importlib
import subprocess
if importlib.util.find_spec('winreg'):
import winreg
from xml.dom import minidom
Expand Down Expand Up @@ -112,7 +114,18 @@ def _detect_executable(self):
yield executable
except FileNotFoundError:
pass


# detect macOS bundle
if platform.system() == 'Darwin':
process = subprocess.run(['mdfind', '-onlyin', '/Applications', 'kMDItemCFBundleIdentifier=org.scilab.modules.jvm.Scilab'],
stdout=subprocess.PIPE,
universal_newlines=True)
bundles = process.stdout
if len(bundles) > 0:
executable = bundles.split('\n', 1)[0] + "/Contents/bin/scilab-adv-cli"
self.log.warning('macOS Application binary: ' + executable)
yield executable

# detect on the path
if os.name == 'nt':
executable = 'WScilex-cli'
Expand Down

0 comments on commit 4dafa27

Please sign in to comment.