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

Support running fades inside a virtualenv #405

Open
judy2k opened this issue Oct 7, 2020 · 6 comments
Open

Support running fades inside a virtualenv #405

judy2k opened this issue Oct 7, 2020 · 6 comments

Comments

@judy2k
Copy link

judy2k commented Oct 7, 2020

I decided to install fades using the pipx tool, which is a great way of managing various Python executables. Obviously it's not supported - the first time I tried to run a fades script, it told me so - great error reporting!

I've worked around this by following the correct installation instructions, and installed the deb package. But I'd really like to use pipx to install fades instead.

@judy2k
Copy link
Author

judy2k commented Oct 7, 2020

I'd be happy to do the work on this myself if you'll accept the feature.

If you let me know what's probably going to cause me problems in the implementation, that will help.

@facundobatista
Copy link
Member

Hello @judy2k, thanks for your time and reporting your experience with fades!

Is it supported to run a virtualenv inside another virtualenv? ("nested", I mean). AFAIK we don't let fades run inside a virtualenv because of that.

@gilgamezh
Copy link
Contributor

gilgamezh commented Oct 7, 2020

It sounds super interesting. I think the challenge is that you are going to be running from a virtualenv.

I think it's not super-hard to get it working but I'm not sure if we want to do it (because it will be kind of a hack)

To give you an idea you can check here https://github.com/PyAr/fades/blob/master/fades/main.py#L201
and here https://github.com/PyAr/fades/blob/master/fades/main.py#L467

Just playing for some time it will probably work but I'm afraid of any other lib making assumptions and it will start crashing.

Other challenge will be the venv creation (fades/envbuilder.py). No idea here, but it's matter of testing.

But thinking in your problem maybe it's a super good idea to use pipx as a lib and ask it to install the python version that you want to use?

in fades you can tell it to use a particular python --python. Following what we did in the past it seems a good idea. I'm thinking in something like

fades --pipx python3.6 -r requirements.txt my_project.py

Do you think it's possible? I don't have experience with pipx, my usual workflow is to install the python version using my distro solution (archlinux) and then ask fades to create the venv using it

Update: I'm reading pipx docs. Thay are also using cowsay as an example XD

@judy2k
Copy link
Author

judy2k commented Oct 8, 2020

Thanks for your responses!

The only backing I have right now is that tox also manages virtualenvs, and can also be run from a virtualenv.

I think it's definitely possible that nesting virtualenvs might cause problems. I'm not sure if venv supports it, but IIRC, pew does. That obviously doesn't mean it's a good idea, and when I used pew regularly, I used to avoid nesting a virtualenv inside another.

A better approach would probably be for fades to traverse the tree of virtualenvs that fades is installed within (hopefully not actually nested, but you get the idea) until it finds the original python install, and then to spin off a virtualenv from that. I'm not entirely certain how you do that, but I'm optimistic that it's possible without too much hackery.

I also really like the idea of specifying the version of Python that's required, and having fades identify that and ensure the virtualenv is created from an appropriate Python version.

@judy2k
Copy link
Author

judy2k commented Oct 8, 2020

It's worth noting that pipx doesn't install python at all, it just creates a virtualenv for each library/utility you've asked it to install, and then ensures that the executables are "linked" to that virtualenv so when you run them they run within their own personal virtualenv automatically.

@facundobatista
Copy link
Member

Related: instead of "pipx installing" foo, and then having foo (running from a virtualenv) in my PATH, I got used to put in my bashrc something like alias foo=fades -d foo -x foo. The good thing in my solution is that when I install a new machine and I bring my bashrc, the moment I call "foo" it will make fades to create the virtualenv and it just will work (no need to install it previously!).

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

No branches or pull requests

3 participants