asdf-community / asdf-python

Python plugin for the asdf version manager
https://github.com/asdf-vm/asdf
MIT License
656 stars 56 forks source link

Using asdf python with virtual env #47

Closed AvnerCohen closed 5 years ago

AvnerCohen commented 5 years ago

There gotta to be something pretty basic I am missing.

I have multiple virtual environments for multiple projects, I use this to isolate dependencies between the various projects.

Here I have a ".tools-version" that is different from the "global" python version:

HSCode/  › python --version
Python 3.7.2
HSCode/  › cd test
test/  › python --version
Python 2.7.14

Based on that I want to create a new virtualenev that will work with the local python version, however:

test/  › mkvirtualenv -p $(which python) test_venv
Running virtualenv with interpreter /Users/$$$/.asdf/shims/python
Using base prefix '/Users/$$$/.asdf/installs/python/3.7.2'
New python executable in /Users/$$$/.virtualenvs/test_venv/bin/python
Installing setuptools, pip, wheel...done.

(test_venv) test/  › python --version
Python 3.7.2

Any ideas or pointers regarding the workflow for virtual environments + asdf-python ?

AvnerCohen commented 5 years ago

This seems to be handled with: https://github.com/asdf-vm/asdf/issues/150

TL;DR;

 mkvirtualenv -p $(asdf where python)/bin/python test_venv

To create the venv, not the nicest, but I guess it is what it is.

AvnerCohen commented 5 years ago

An even better solution:

python -m venv myvenv

https://github.com/asdf-vm/asdf/issues/150#issuecomment-513782282

dagadbm commented 4 years ago

i am just using asdf-direnv to manage this for now