fix: fix uv conflict
This commit is contained in:
parent
e12b39bda1
commit
bbe04589b8
2 changed files with 14 additions and 3 deletions
|
|
@ -29,6 +29,11 @@ local function run_scraper(platform, subcommand, args, opts)
|
||||||
local cmd = { 'uv', 'run', '--directory', plugin_path, '-m', 'scrapers.' .. platform, subcommand }
|
local cmd = { 'uv', 'run', '--directory', plugin_path, '-m', 'scrapers.' .. platform, subcommand }
|
||||||
vim.list_extend(cmd, args)
|
vim.list_extend(cmd, args)
|
||||||
|
|
||||||
|
local env = vim.fn.environ()
|
||||||
|
env.VIRTUAL_ENV = ''
|
||||||
|
env.PYTHONPATH = ''
|
||||||
|
env.CONDA_PREFIX = ''
|
||||||
|
|
||||||
if opts and opts.ndjson then
|
if opts and opts.ndjson then
|
||||||
local uv = vim.loop
|
local uv = vim.loop
|
||||||
local stdout = uv.new_pipe(false)
|
local stdout = uv.new_pipe(false)
|
||||||
|
|
@ -38,7 +43,7 @@ local function run_scraper(platform, subcommand, args, opts)
|
||||||
local handle
|
local handle
|
||||||
handle = uv.spawn(
|
handle = uv.spawn(
|
||||||
cmd[1],
|
cmd[1],
|
||||||
{ args = vim.list_slice(cmd, 2), stdio = { nil, stdout, stderr } },
|
{ args = vim.list_slice(cmd, 2), stdio = { nil, stdout, stderr }, env = env },
|
||||||
function(code, signal)
|
function(code, signal)
|
||||||
if buf ~= '' and opts.on_event then
|
if buf ~= '' and opts.on_event then
|
||||||
local ok_tail, ev_tail = pcall(vim.json.decode, buf)
|
local ok_tail, ev_tail = pcall(vim.json.decode, buf)
|
||||||
|
|
@ -97,7 +102,7 @@ local function run_scraper(platform, subcommand, args, opts)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local sysopts = { text = true, timeout = 30000 }
|
local sysopts = { text = true, timeout = 30000, env = env }
|
||||||
if opts and opts.sync then
|
if opts and opts.sync then
|
||||||
local result = vim.system(cmd, sysopts):wait()
|
local result = vim.system(cmd, sysopts):wait()
|
||||||
return syshandle(result)
|
return syshandle(result)
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,13 @@ function M.setup_python_env()
|
||||||
|
|
||||||
if vim.fn.isdirectory(venv_dir) == 0 then
|
if vim.fn.isdirectory(venv_dir) == 0 then
|
||||||
logger.log('Setting up Python environment for scrapers...')
|
logger.log('Setting up Python environment for scrapers...')
|
||||||
local result = vim.system({ 'uv', 'sync' }, { cwd = plugin_path, text = true }):wait()
|
local env = vim.fn.environ()
|
||||||
|
env.VIRTUAL_ENV = ''
|
||||||
|
env.PYTHONPATH = ''
|
||||||
|
env.CONDA_PREFIX = ''
|
||||||
|
local result = vim
|
||||||
|
.system({ 'uv', 'sync' }, { cwd = plugin_path, text = true, env = env })
|
||||||
|
:wait()
|
||||||
if result.code ~= 0 then
|
if result.code ~= 0 then
|
||||||
logger.log('Failed to setup Python environment: ' .. result.stderr, vim.log.levels.ERROR)
|
logger.log('Failed to setup Python environment: ' .. result.stderr, vim.log.levels.ERROR)
|
||||||
return false
|
return false
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue