Skip to content
This repository was archived by the owner on Dec 27, 2023. It is now read-only.

Commit e75783a

Browse files
committed
Added OSX installer
1 parent 6ea2077 commit e75783a

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

src/Installer/MacInstaller.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,40 @@ public function __construct(MacSystem $system, $composerCmd)
1818
{
1919
parent::__construct($system, $composerCmd);
2020
}
21+
22+
/**
23+
* @return string
24+
*/
25+
protected function getInstallPath()
26+
{
27+
$currentUser = $this->system->getCurrentUser();
28+
29+
if ('root' === $currentUser) {
30+
return '/Applications/jupyter-php';
31+
} else {
32+
return $this->system->getCurrentUserHome().'/Library/jupyter-php';
33+
}
34+
}
35+
36+
/**
37+
*
38+
*/
39+
protected function installKernel()
40+
{
41+
$kernelDef = json_encode([
42+
'argv' => ['php', $this->getInstallPath().'/pkgs/src/kernel.php', '{connection_file}'],
43+
'display_name' => 'PHP',
44+
'language' => 'php',
45+
'env' => new \Stdclass
46+
]);
47+
48+
$currentUser = $this->system->getCurrentUser();
49+
50+
$kernelSpecPath = ('root' === $currentUser) ?
51+
'/usr/local/share/jupyter/kernels/jupyter-php' :
52+
$this->system->getCurrentUserHome().'/Library/Jupyter/kernels/jupyter-php';
53+
54+
$this->system->ensurePath($kernelSpecPath);
55+
file_put_contents($kernelSpecPath.'/kernel.json', $kernelDef);
56+
}
2157
}

0 commit comments

Comments
 (0)