@melaya/runner 1.0.33 → 1.0.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/pythonEnv.js +23 -5
- package/package.json +1 -1
package/dist/pythonEnv.js
CHANGED
|
@@ -175,12 +175,30 @@ export async function ensurePythonEnv(systemPython, expectedVersion, onProgress
|
|
|
175
175
|
}
|
|
176
176
|
// Scrapling browser binaries — best-effort. The fast-path AsyncFetcher
|
|
177
177
|
// (curl_cffi TLS impersonation) works without this; only StealthyFetcher
|
|
178
|
-
// (Cloudflare-bypass rescue path) needs Chromium.
|
|
179
|
-
//
|
|
180
|
-
//
|
|
181
|
-
//
|
|
178
|
+
// (Cloudflare-bypass rescue path) needs Chromium. Scrapling has no
|
|
179
|
+
// __main__.py — invoke its CLI entry point via `from scrapling.cli
|
|
180
|
+
// import main; main(['install'])` so the call works the same on every
|
|
181
|
+
// platform without reaching into the venv's Scripts/bin folder.
|
|
182
|
+
// Non-fatal: if it fails (offline, mirror down, scrapling.cli rename in
|
|
183
|
+
// a future version) the search just stays on the fast path.
|
|
182
184
|
onProgress("installing scrapling browsers (best-effort, for stealth rescue path)");
|
|
183
|
-
const scrCode = await runProc(venvPython(), ["-
|
|
185
|
+
const scrCode = await runProc(venvPython(), ["-c",
|
|
186
|
+
"import sys\n" +
|
|
187
|
+
"# Try every known CLI shape across scrapling versions, return 0 on first success.\n" +
|
|
188
|
+
"tried = []\n" +
|
|
189
|
+
"for mod, attr in (('scrapling.cli','main'), ('scrapling.__main__','main'), ('scrapling.cli','cli')):\n" +
|
|
190
|
+
" try:\n" +
|
|
191
|
+
" m = __import__(mod, fromlist=[attr])\n" +
|
|
192
|
+
" fn = getattr(m, attr)\n" +
|
|
193
|
+
" try: fn(['install'])\n" +
|
|
194
|
+
" except TypeError: fn() # zero-arg variants\n" +
|
|
195
|
+
" sys.exit(0)\n" +
|
|
196
|
+
" except Exception as e:\n" +
|
|
197
|
+
" tried.append(f'{mod}.{attr}: {type(e).__name__}: {e}')\n" +
|
|
198
|
+
" continue\n" +
|
|
199
|
+
"print('scrapling install: no working CLI entry — tried:'); [print(' -', t) for t in tried]\n" +
|
|
200
|
+
"sys.exit(2)\n",
|
|
201
|
+
], onProgress);
|
|
184
202
|
if (scrCode !== 0) {
|
|
185
203
|
onProgress(`(scrapling install exited ${scrCode} — fast-path fetcher still works; stealth-rescue disabled)`);
|
|
186
204
|
}
|