summarylogtreecommitdiffstats
path: root/archlinux-use-system.patch
blob: 1c0b829d87c2e1a8245bc8b41fd256f36fcae500 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
From cfd7a64dc81e4acf7a0c1a072d328187073bc5a3 Mon Sep 17 00:00:00 2001
From: Claudia Pellegrino <claui@users.noreply.github.com>
Date: Mon, 10 Mar 2025 13:07:29 +0100
Subject: [PATCH 1/3] Arch-Linux-specific: install optdeps via pacman

---
 aider/scrape.py | 34 +++++++++++++---------------------
 1 file changed, 13 insertions(+), 21 deletions(-)

diff --git a/aider/scrape.py b/aider/scrape.py
index 7977a854..cb33c947 100755
--- a/aider/scrape.py
+++ b/aider/scrape.py
@@ -18,9 +18,9 @@ def install_playwright(io):
     try:
         from playwright.sync_api import sync_playwright
 
-        has_pip = True
+        has_playwright = True
     except ImportError:
-        has_pip = False
+        has_playwright = False
 
     try:
         with sync_playwright() as p:
@@ -29,40 +29,32 @@ def install_playwright(io):
     except Exception:
         has_chromium = False
 
-    if has_pip and has_chromium:
+    if has_playwright and has_chromium:
         return True
 
-    pip_cmd = utils.get_pip_install(["aider-chat[playwright]"])
-    chromium_cmd = "-m playwright install --with-deps chromium"
-    chromium_cmd = [sys.executable] + chromium_cmd.split()
-
-    cmds = ""
-    if not has_pip:
-        cmds += " ".join(pip_cmd) + "\n"
+    packages = []
+    if not has_playwright:
+        packages.append("python-playwright")
     if not has_chromium:
-        cmds += " ".join(chromium_cmd) + "\n"
+        packages.append("chromium")
+    pacman_cmd = ["sudo", "pacman", "-Syu", *packages]
 
-    text = f"""For the best web scraping, install Playwright:
+    text = f"""For the best web scraping, run pacman as follows:
 
-{cmds}
+{" ".join(pacman_cmd)}
 See {urls.enable_playwright} for more info.
 """
 
     io.tool_output(text)
-    if not io.confirm_ask("Install playwright?", default="y"):
+    if not io.confirm_ask(f"Install {" and ".join(packages)}?", default="y"):
         return
 
-    if not has_pip:
-        success, output = utils.run_install(pip_cmd)
+    if packages:
+        success, output = utils.run_install(pacman_cmd)
         if not success:
             io.tool_error(output)
             return
 
-    success, output = utils.run_install(chromium_cmd)
-    if not success:
-        io.tool_error(output)
-        return
-
     return True
 
 
-- 
2.48.1


From 099ff26820d544992a426f10d8cc7d11ab1d4b1a Mon Sep 17 00:00:00 2001
From: Claudia Pellegrino <claui@users.noreply.github.com>
Date: Mon, 10 Mar 2025 14:43:05 +0100
Subject: [PATCH 2/3] Arch-Linux-specific: use system Chromium

---
 aider/scrape.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/aider/scrape.py b/aider/scrape.py
index cb33c947..c0431204 100755
--- a/aider/scrape.py
+++ b/aider/scrape.py
@@ -24,7 +24,7 @@ def install_playwright(io):
 
     try:
         with sync_playwright() as p:
-            p.chromium.launch()
+            p.chromium.launch(executable_path="/usr/bin/chromium")
             has_chromium = True
     except Exception:
         has_chromium = False
@@ -130,7 +130,7 @@ class Scraper:
 
         with sync_playwright() as p:
             try:
-                browser = p.chromium.launch()
+                browser = p.chromium.launch(executable_path="/usr/bin/chromium")
             except Exception as e:
                 self.playwright_available = False
                 self.print_error(str(e))
-- 
2.48.1


From 31da5476699e74b34a23a7a27b818cdc557bf359 Mon Sep 17 00:00:00 2001
From: Claudia Pellegrino <claui@users.noreply.github.com>
Date: Mon, 10 Mar 2025 21:28:29 +0100
Subject: [PATCH 3/3] Arch-Linux-specific: install boto3 via pacman

---
 aider/models.py |  6 +++---
 aider/utils.py  | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+), 3 deletions(-)

diff --git a/aider/models.py b/aider/models.py
index 3c85b73e..62e82ce1 100644
--- a/aider/models.py
+++ b/aider/models.py
@@ -18,7 +18,7 @@ from PIL import Image
 from aider.dump import dump  # noqa: F401
 from aider.llm import litellm
 from aider.sendchat import ensure_alternating_roles, sanity_check_messages
-from aider.utils import check_pip_install_extra
+from aider.utils import check_archlinux_package, check_pip_install_extra
 
 RETRY_TIMEOUT = 60
 
@@ -829,8 +829,8 @@ def check_for_dependencies(io, model_name):
     """
     # Check if this is a Bedrock model and ensure boto3 is installed
     if model_name.startswith("bedrock/"):
-        check_pip_install_extra(
-            io, "boto3", "AWS Bedrock models require the boto3 package.", ["boto3"]
+        check_archlinux_package(
+            io, "boto3", "python-boto3"
         )
 
     # Check if this is a Vertex AI model and ensure google-cloud-aiplatform is installed
diff --git a/aider/utils.py b/aider/utils.py
index 322a4431..42012417 100644
--- a/aider/utils.py
+++ b/aider/utils.py
@@ -370,6 +370,38 @@ def check_pip_install_extra(io, module, prompt, pip_install_cmd, self_update=Fal
     print(printable_shell_command(cmd))
 
 
+def check_archlinux_package(io, module, archlinux_package):
+    if module:
+        try:
+            __import__(module)
+            return True
+        except (ImportError, ModuleNotFoundError, RuntimeError):
+            pass
+
+    cmd = ["sudo", "pacman", "-Syu", archlinux_package]
+    io.tool_warning("Using this feature requires a package to be installed.")
+
+    if not io.confirm_ask("Run pacman?", default="y", subject=printable_shell_command(cmd)):
+        return
+
+    success, output = run_install(cmd)
+    if success:
+        if not module:
+            return True
+        try:
+            __import__(module)
+            return True
+        except (ImportError, ModuleNotFoundError, RuntimeError) as err:
+            io.tool_error(str(err))
+            pass
+
+    io.tool_error(output)
+
+    print()
+    print("Install failed, try running this command manually:")
+    print(printable_shell_command(cmd))
+
+
 def printable_shell_command(cmd_list):
     """
     Convert a list of command arguments to a properly shell-escaped string.
-- 
2.48.1