rye icon indicating copy to clipboard operation
rye copied to clipboard

Creating empty virtual envs

Open cojua8 opened this issue 1 year ago • 4 comments

Hi!,

I'm looking for a way to set a standalone virtualenv, which will be use as default python by apps like vscode or pycharm or nvim. Is there an existing way to do this?

cojua8 avatar May 15 '23 19:05 cojua8

Can you provide more details about this request? Is this about having some sort of throwaway virtualenv?

mitsuhiko avatar May 15 '23 21:05 mitsuhiko

yeah!, something like what pyenv-virtualenv does

cojua8 avatar May 15 '23 21:05 cojua8

I'm not entirely sure I understand what the point of this is in the context of rye. Can you elaborate how you would use this?

mitsuhiko avatar May 15 '23 22:05 mitsuhiko

A use example is python neovim, which requires pynvim to be installed. As I don't want to install pynvim globally, I need a virtual environment to install it. It is also not a tool, so it does not quite fit using the install command of Rye.

Another use example is pycharm, which requires a python installation for running its tools I think.

In general, the use case is where another program uses python, but you don't use python or tools directly.

As Rye manages python versions and virtual environments, I think it would be a good thing to have

cojua8 avatar May 15 '23 23:05 cojua8

Would pipx be a solution? It is what you should use to install python applications globally for your user. Unlike pip it ensures your local installations do not conflict with each other when they have the same dependency but not necessarily at the same version. It does this by creating separate virtual environments for each application.

python3 -m pip install --user pipx
python3 -m pipx ensurepath
python3 -m pipx install pynvim

doolio avatar Aug 28 '23 10:08 doolio

pipx is aimed for end-user apps. pynvim is just a package, not an end user app, so I think that wouldn't be a solution

cojua8 avatar Aug 28 '23 15:08 cojua8

Closing this as out of scope for Rye.

mitsuhiko avatar Jan 21 '24 19:01 mitsuhiko

@mitsuhiko Not sure if this was the OP's intent, but here's a use case: I usually work on multiple projects with a general theme (in my case scientific computing) that share many dependencies. What I used to do (and wanted to replicate with rye, but couldn't find a clear-cut solution) was to create a shared conda virtual environment (e.g., called dev or sci), which would host all shared and non-shared dependencies of these projects, so every time I wanted to work on one, everything would just work right out of the box without having to constantly switching virtualenvs.

I'm very new to rye, but so far, it seems that one way to achieve this in rye is to install all those dependencies in the global scope, which doesn't seem like a good idea (?).

ma-sadeghi avatar Feb 25 '24 16:02 ma-sadeghi

In that case you can probably use a virtual project: https://rye-up.com/guide/virtual/

Would that work for you?

mitsuhiko avatar Feb 25 '24 22:02 mitsuhiko

Thanks for the pointer, I'm experimenting with it atm; I think it'll do the job.

ma-sadeghi avatar Feb 26 '24 11:02 ma-sadeghi