Skip to content

Commit 4bf6d50

Browse files
authored
Update installation process (#26)
1 parent 9e561e8 commit 4bf6d50

File tree

8 files changed

+56
-52
lines changed

8 files changed

+56
-52
lines changed

README.md

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,19 @@ Key features of ShellOracle include:
5353

5454
## Installation
5555

56-
To experience the power of ShellOracle, use the following one-liner to download and run the installer Python zip
57-
application:
56+
Installing ShellOracle is easy!
5857

59-
```zsh
60-
curl -sSL https://raw.githubusercontent.com/djcopley/ShellOracle/master/installer.pyz -o /tmp/installer.pyz && python3 /tmp/installer.pyz
61-
```
58+
1. First, pip install the `shelloracle` package
59+
```zsh
60+
python3 -m pip install shelloracle
61+
```
62+
2. Next, run `shelloracle init` and follow the prompts
63+
```zsh
64+
python3 -m shelloracle init
65+
```
6266

6367
> [!NOTE]
64-
> ShellOracle uses Ollama as its default Language Model (LLM) provider. If you are going to use it, follow the
65-
> installation instructions [here](https://ollama.ai/).
68+
> If you chose Ollama as your LLM provider, you will need to install it from [here](https://ollama.ai/).
6669

6770
## Usage
6871

@@ -147,6 +150,13 @@ system_prompt = "..."
147150

148151
## System Requirements
149152

153+
### Software
154+
155+
ShellOracle supports ZSH on macOS and Linux. Bash support is planned; however, it is not currently
156+
supported.
157+
158+
### Hardware
159+
150160
For cloud providers like OpenAI, there are no specific system requirements.
151161

152162
If self-hosting, system requirements vary based on the model used. Refer to the Ollama model registry for more

installer.pyz

-3.44 MB
Binary file not shown.

installer/build-installer-pyz.sh

Lines changed: 0 additions & 2 deletions
This file was deleted.

installer/requirements.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

pyproject.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ classifiers = [
2323
"Development Status :: 4 - Beta",
2424
"Environment :: Console",
2525
"Operating System :: MacOS",
26+
"Operating System :: POSIX :: Linux",
27+
"Intended Audience :: Developers",
2628
"Programming Language :: Python :: 3",
2729
"Programming Language :: Python :: 3.9",
2830
"Programming Language :: Python :: 3.10",
@@ -34,10 +36,13 @@ classifiers = [
3436
[tool.setuptools.packages.find]
3537
where = ["src"]
3638

39+
[tool.setuptools.package-data]
40+
shelloracle = ["shelloracle.txt"]
41+
3742
[tool.setuptools_scm]
3843

3944
[project.scripts]
40-
shor = "shelloracle.shelloracle:cli"
45+
shor = "shelloracle.__main__:main"
4146

4247
[project.urls]
4348
Homepage = "https://github.com/djcopley/ShellOracle"

src/shelloracle/__main__.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,24 @@
1+
import argparse
2+
13
from . import shelloracle
4+
from .bootstrap import bootstrap
5+
6+
7+
def parse_args() -> argparse.Namespace:
8+
parser = argparse.ArgumentParser()
9+
parser.add_argument("--init", help="initialize shelloracle with scripts",
10+
action="store_true")
11+
return parser.parse_args()
12+
13+
14+
def main() -> None:
15+
args = parse_args()
16+
if args.init:
17+
bootstrap()
18+
exit(0)
19+
20+
shelloracle.cli()
21+
222

323
if __name__ == "__main__":
424
shelloracle.cli()
Lines changed: 13 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
import os
2-
import shutil
3-
import subprocess
4-
import zipfile
52
from pathlib import Path
63

74
from prompt_toolkit import print_formatted_text
@@ -18,59 +15,36 @@ def print_error(error: str) -> None:
1815
print_formatted_text(FormattedText([("ansired", error)]))
1916

2017

21-
def pip_output(text: str) -> None:
22-
print_formatted_text(FormattedText([("ansigray", text)]), end="")
23-
24-
2518
def replace_home_with_tilde(path: Path) -> Path:
2619
relative_path = path.relative_to(Path.home())
2720
return Path("~") / relative_path
2821

2922

30-
def ensure_zsh():
23+
def ensure_zsh() -> None:
3124
shell = os.environ.get("SHELL")
25+
if shell is None:
26+
print_error("Unable to determine shell environment. If you are confident "
27+
"that you are running in zsh, run again with `SHELL=zsh python3 -m shelloracle --init`")
28+
exit(1)
3229
if "zsh" not in shell:
3330
print_error(f"'{shell}' is currently unsupported. "
3431
f"Please open an issue https://github.com/djcopley/ShellOracle/issues.")
3532
exit(1)
3633

3734

38-
def install_shelloracle():
39-
print_info("Installing shelloracle")
40-
python = shutil.which("python3")
41-
pip = subprocess.Popen([python, "-m", "pip", "install", "--upgrade", "shelloracle"],
42-
stdout=subprocess.PIPE, text=True)
43-
for line in pip.stdout.readlines():
44-
pip_output(line)
45-
if (ret := pip.wait()) == 0:
46-
print_info("Successfully installed shelloracle")
47-
else:
48-
print_error(f"Unable to install shelloracle")
49-
exit(ret)
50-
51-
5235
zshrc_path = Path.home() / ".zshrc"
5336
shelloracle_zsh_dest = Path.home() / ".shelloracle.zsh"
5437

5538

56-
def read_shelloracle_zsh():
57-
working_dir = Path(__file__).parent.absolute()
58-
zsh_path = "shelloracle.zsh"
59-
if working_dir.suffix == ".pyz":
60-
with zipfile.ZipFile(working_dir, "r") as zip_app:
61-
shelloracle_zsh = zip_app.read(zsh_path)
62-
else:
63-
shelloracle_zsh = (working_dir / zsh_path).read_bytes()
64-
return shelloracle_zsh
65-
66-
67-
def write_shelloracle_zsh():
68-
shelloracle_zsh = read_shelloracle_zsh()
39+
def write_shelloracle_zsh() -> None:
40+
zsh_path = Path(__file__).parent.absolute() / "shelloracle.zsh"
41+
shelloracle_zsh = zsh_path.read_bytes()
6942
shelloracle_zsh_dest.write_bytes(shelloracle_zsh)
7043
print_info(f"Successfully wrote key bindings to {replace_home_with_tilde(shelloracle_zsh_dest)}")
7144

7245

73-
def update_zshrc():
46+
def update_zshrc() -> None:
47+
zshrc_path.touch(exist_ok=True)
7448
with zshrc_path.open("r") as file:
7549
zshrc = file.read()
7650
line = f"[ -f {shelloracle_zsh_dest} ] && source {shelloracle_zsh_dest}"
@@ -81,17 +55,16 @@ def update_zshrc():
8155
print_info(f"Successfully updated {replace_home_with_tilde(zshrc_path)}")
8256

8357

84-
def install():
58+
def bootstrap() -> None:
8559
with create_app_session_from_tty():
8660
ensure_zsh()
87-
install_shelloracle()
8861

8962
if confirm("Enable terminal keybindings?", suffix=" ([y]/n) ") is False:
90-
exit(0)
63+
return
9164

9265
write_shelloracle_zsh()
9366
update_zshrc()
9467

9568

9669
if __name__ == '__main__':
97-
install()
70+
bootstrap()
File renamed without changes.

0 commit comments

Comments
 (0)