pyenv / pyenv-virtualenv

a pyenv plugin to manage virtualenv (a.k.a. python-virtualenv)
MIT License
6.3k stars 398 forks source link

pyenv virtualenv does not correctly link the c++ libraries associated to the python package #462

Open favrei opened 1 year ago

favrei commented 1 year ago

related to #459

I am using pyenv 3.8.17 with pyenv-virtualenv 1.2.1(commit: c85c1c9e) on Pop OS. I created a virtual environment called wristband using pyenv virtualenv 3.8.17 wristband.

However, when I activate the virtual environment and run python3-config --includes, it shows me a path that does not exist:

/home/pete/.pyenv/versions/3.8.17/envs/wristband/include/python3.8

I suppose the link should be created or the files should be clone to the corresponding location? Thank you for checking this.

Steps and outputs:

# list headers without activate virtualenv
pete@pop-os:~$ pyenv shell 3.8.17
pete@pop-os:~$ python3-config --includes
-I/home/pete/.pyenv/versions/3.8.17/include/python3.8 -I/home/pete/.pyenv/versions/3.8.17/include/python3.8
(3.8.17/envs/wristband) pete@pop-os:~$ ls /home/pete/.pyenv/versions/3.8.17/include/python3.8/ | head -n10
abstract.h
asdl.h
ast.h
bitset.h
bltinmodule.h
boolobject.h
bytearrayobject.h
bytes_methods.h
bytesobject.h
cellobject.h

# list headers after activated virtualenv
pete@pop-os:~$ pyenv activate 3.8.17/envs/wristband
(3.8.17/envs/wristband) pete@pop-os:~$ python3-config --includes
-I/home/pete/.pyenv/versions/3.8.17/envs/wristband/include/python3.8 -I/home/pete/.pyenv/versions/3.8.17/envs/wristband/include/python3.8
(3.8.17/envs/wristband) pete@pop-os:~$ ls /home/pete/.pyenv/versions/3.8.17/envs/wristband/include/python3.8 | head -n10
ls: cannot access '/home/pete/.pyenv/versions/3.8.17/envs/wristband/include/python3.8': No such file or directory
A-CGray commented 2 months ago

I am seeing the same issue, I believe it's being caused by the changes in #460

On the current master branch of pyenv and pyenv virtualenv, python3-config --includes returns the path to an empty directory:

>pyenv install 3.11
>pyenv virtualenv 3.11.9 test
>pyenv activate test
>python3-config --includes
-I/home/ali/.pyenv/versions/3.11.9/envs/test/include/python3.11 -I/home/ali/.pyenv/versions/3.11.9/envs/test/include/python3.11
>ls -lFh /home/ali/.pyenv/versions/3.11.9/envs/test/include/python3.11
total 0

I believe instead of /home/ali/.pyenv/versions/3.11.9/envs/test/include/python3.11, python3-config --includes should be using /home/ali/.pyenv/versions/3.11.9/include/python3.11, which does contain all the correct header files.

If I roll back to pyenv-virtual v1.2.1, before #460 was merged, python3-config --includes points to the system python headers:

>python3-config --includes      
-I/usr/include/python3.12 -I/usr/include/python3.12

I understand this is not correct (having seen #459 ), which is what motivated #460 , but I can at least build codes that rely on the python headers with this since presumably the python 3.12 headers work with 3.11.