Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [pip] added venv_args to configuration options #1557

Closed
wants to merge 1 commit into from

Conversation

magnuslarsen
Copy link

Added the ability to pass arguments to the venv-creator

This is especially useful when for example, using python-language-server on a Linux based distro that packages pip-packages as system packages (Debian-based, Arch, ...)

By default you do not get access to system-site packages, meaning no LSP-features for those packages, unless you manually install them (again) in the python-language-server-venv

Passing the following circumvents all of that, by allowing the venv to access system packages:

require("mason").setup({
	pip = {
		venv_args = { "--system-site-packages" },
	},
})

ref: https://docs.python.org/3/library/venv.html#creating-virtual-environments

Copy link
Owner

@williamboman williamboman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, thanks for the PR 👍!

This has been brought up before and I'm a bit hesitant to the idea. My rationale is that, per my understanding, this would only really play nicely if you install your packages globally (according to whatever --system-site-packages considers global). If you choose to use a project-local virtual environment (which I'd like to believe is the norm), local packages would not be recognized even with this flag enabled. At this point you might as well manage this package outside of Mason, along with the rest.

Furthermore, python-lsp-server in particular should support loading different environments via its configuration, so I'd like to believe this is mostly a configuration issue. I'm aware this is severely undocumented and probably causes issues for many users, I'm not sure where the best place to solve it would be though.

@magnuslarsen
Copy link
Author

You are right, this seems to be a configuration issue.

I'm using the community version of the python-language-server (pylsp), but the same config as mentioned in above issue worked here as well

I got a few dependency errors after setting the environment to the /usr/bin/python3 (likely due to Ubuntu shipping old pip packages) - nothing that prevents it from working though

Thanks for an invaluable plugin :-)

@BlueDrink9
Copy link

Responded to this argument in #1584

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants