How do I use mason-core.package to install a pip package? #1453
-
|
I'm trying to set up Mason to install pylsp-black (since I'm already using it to install pylsp, and I want the to live in the same pyenv). I've managed to understand that I can add my own packages by setting up a local registry: require'mason'.setup {
registries = {
'github:mason-org/mason-registry',
'lua:<my-local-registry-lua-package>.index',
},
}And then, in the return {
['pylsp-black'] = '<my-local-registry-lua-package>.pylsp-black',
}Which routes to the Lua file that should describe the actual package. The examples in the repository only show local paths, but I've managed to play with them and somehow get to something like this: local Package = require'mason-core.package'
return Package.new {
name = 'pylsp-black',
desc = 'Black support for pylsp',
homepage = 'https://github.com/python-lsp/python-lsp-black',
languages = { 'Python' },
categories = { 'LSP' },
install = function(ctx)
ctx.receipt:with_name('python-lsp-black')
ctx.receipt:with_schema_version('1.1')
ctx.receipt:with_completion_time(vim.loop.gettimeofday())
ctx.receipt:with_primary_source(ctx.receipt.pip3('python-lsp-black'))
ctx.receipt:build()
end,
}When I run this, it does create a How can I get it to actually install the package? I can't find examples or documentation anywhere... |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
Hello! See #1369 (comment). |
Beta Was this translation helpful? Give feedback.
Oh also, you should not write the receipt manually like that (except for
ctx.receipt:with_primary_source()), the core installer takes care of the rest.Packages are entirely isolated, so to install another pip package in the LSP environment you'll have to drop into the virtual environment of that package. Very hacky, untested, illustration of this: