Compare commits
No commits in common. "6abe02f5ee157194b9c801abd5cc888c615ac7a3" and "622620f6d087fd442a7885943ea0ba18a22e89ed" have entirely different histories.
6abe02f5ee
...
622620f6d0
2 changed files with 6 additions and 17 deletions
|
|
@ -25,15 +25,6 @@ end
|
||||||
---@param args string[]
|
---@param args string[]
|
||||||
---@param opts { sync?: boolean, ndjson?: boolean, on_event?: fun(ev: table), on_exit?: fun(result: table) }
|
---@param opts { sync?: boolean, ndjson?: boolean, on_event?: fun(ev: table), on_exit?: fun(result: table) }
|
||||||
local function run_scraper(platform, subcommand, args, opts)
|
local function run_scraper(platform, subcommand, args, opts)
|
||||||
if not utils.setup_python_env() then
|
|
||||||
local msg = 'no Python environment available (install uv or nix)'
|
|
||||||
logger.log(msg, vim.log.levels.ERROR)
|
|
||||||
if opts and opts.on_exit then
|
|
||||||
opts.on_exit({ success = false, error = msg })
|
|
||||||
end
|
|
||||||
return { success = false, error = msg }
|
|
||||||
end
|
|
||||||
|
|
||||||
local plugin_path = utils.get_plugin_path()
|
local plugin_path = utils.get_plugin_path()
|
||||||
local cmd = utils.get_python_cmd(platform, plugin_path)
|
local cmd = utils.get_python_cmd(platform, plugin_path)
|
||||||
vim.list_extend(cmd, { subcommand })
|
vim.list_extend(cmd, { subcommand })
|
||||||
|
|
|
||||||
|
|
@ -129,8 +129,7 @@ local function discover_nix_python()
|
||||||
end
|
end
|
||||||
|
|
||||||
local plugin_path = M.get_plugin_path()
|
local plugin_path = M.get_plugin_path()
|
||||||
vim.notify('[cp.nvim] Building Python environment with nix...', vim.log.levels.INFO)
|
logger.log('Building Python environment with nix...', nil, true)
|
||||||
vim.cmd.redraw()
|
|
||||||
local result = vim
|
local result = vim
|
||||||
.system(
|
.system(
|
||||||
{ 'nix', 'build', plugin_path .. '#pythonEnv', '--no-link', '--print-out-paths' },
|
{ 'nix', 'build', plugin_path .. '#pythonEnv', '--no-link', '--print-out-paths' },
|
||||||
|
|
@ -178,8 +177,6 @@ function M.setup_python_env()
|
||||||
if vim.fn.executable('uv') == 1 then
|
if vim.fn.executable('uv') == 1 then
|
||||||
local plugin_path = M.get_plugin_path()
|
local plugin_path = M.get_plugin_path()
|
||||||
logger.log('Python env: uv sync (dir=' .. plugin_path .. ')')
|
logger.log('Python env: uv sync (dir=' .. plugin_path .. ')')
|
||||||
vim.notify('[cp.nvim] Setting up Python environment...', vim.log.levels.INFO)
|
|
||||||
vim.cmd.redraw()
|
|
||||||
|
|
||||||
local env = vim.fn.environ()
|
local env = vim.fn.environ()
|
||||||
env.VIRTUAL_ENV = ''
|
env.VIRTUAL_ENV = ''
|
||||||
|
|
@ -189,10 +186,7 @@ function M.setup_python_env()
|
||||||
.system({ 'uv', 'sync' }, { cwd = plugin_path, text = true, env = env })
|
.system({ 'uv', 'sync' }, { cwd = plugin_path, text = true, env = env })
|
||||||
:wait()
|
:wait()
|
||||||
if result.code ~= 0 then
|
if result.code ~= 0 then
|
||||||
logger.log(
|
logger.log('Failed to setup Python environment: ' .. result.stderr, vim.log.levels.ERROR)
|
||||||
'Failed to setup Python environment: ' .. (result.stderr or ''),
|
|
||||||
vim.log.levels.ERROR
|
|
||||||
)
|
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
if result.stderr and result.stderr ~= '' then
|
if result.stderr and result.stderr ~= '' then
|
||||||
|
|
@ -270,6 +264,10 @@ function M.check_required_runtime()
|
||||||
return false, timeout.reason
|
return false, timeout.reason
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if not M.setup_python_env() then
|
||||||
|
return false, 'no Python environment available (install uv or nix)'
|
||||||
|
end
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue