I have a standard development environment I build via scripts in Github Codespaces to work on projects that come up.
Up until recently, I had been compiling vim from source to upgrade the VIM 8 that the upstream debian image came with to VIM 9 so I could use Copilot in VIM via TPope's great plugin.
Recently I started a new project, so created a new codespace using my standard scripts, and in this new environment instead of Python 3.9 being installed, the upstream image has upgraded to Python 3.10.
Now when compiling VIM, the configure output says "checking if compile and link flags for Python 3 are sane... no", whereas previously it would say yes, and consequently of course VIM now is compiled with Python3 disabled.
Here is the configure command I'm running that used to work and now doesn't:
./configure --enablepython3interp=yes --disable-gui --without-x --enable-gui=no
Here is the output of that configure command from a codespace I still have available where I configure VIM with Python 3.9 installed, where "sane... yes" is output:
checking --enable-pythoninterp argument... no
checking --enable-python3interp argument... yes
checking --with-python3-command argument... no
checking for python3... /opt/conda/bin/python3
checking Python version... 3.9
checking Python is 3.0 or better... yep
checking Python's abiflags...
checking Python's install prefix... /opt/conda
checking Python's execution prefix... /opt/conda
checking Python's configuration directory...
/opt/conda/lib/python3.9/config-3.9-x86_64-linux-gnu
checking Python3's dll name... libpython3.9.a
checking if -pthread should be used... yes
checking if compile and link flags for Python 3 are sane... yes
checking if -fPIE can be added for Python3... yes
Now here is one I compiled recently with Python 3.10 installed, where "sane... no" is output:
checking --enable-pythoninterp argument... no
checking --enable-python3interp argument... yes
checking --with-python3-command argument... no
checking for python3... /opt/conda/bin/python3
checking Python version... 3.10
checking Python is 3.0 or better... yep
checking Python's abiflags...
checking Python's install prefix... /opt/conda
checking Python's execution prefix... /opt/conda
checking Python's configuration directory...
/opt/conda/lib/python3.10/config-3.10-x86_64-linux-gnu
checking Python3's dll name... libpython3.10.a
checking if -pthread should be used... yes
checking if compile and link flags for Python 3 are sane... no: PYTHON3 DISABLED
I have followed other question answers and the compiling VIM FAQ's available, but the configure settings appear to be right so I can't figure out why with the version of python increase to 3.10 this broke, unless it's a bug. Help is much appreciated!
Update:
Here is the relevant output of the config.log file:
configure:6304: checking --enable-pythoninterp argument
configure:6313: result: no
configure:6655: checking --enable-python3interp argument
configure:6664: result: yes
configure:6671: checking --with-python3-command argument
configure:6680: result: no
configure:6690: checking for python3
configure:6708: found /opt/conda/bin/python3
configure:6720: result: /opt/conda/bin/python3
configure:6734: checking Python version
configure:6743: result: 3.10
configure:6746: checking Python is 3.0 or better
configure:6751: result: yep
configure:6754: checking Python's abiflags
configure:6768: result:
configure:6771: checking Python's install prefix
configure:6780: result: /opt/conda
configure:6783: checking Python's execution prefix
configure:6792: result: /opt/conda
configure:6814: checking Python's configuration directory
configure:6840: result: /opt/conda/lib/python3.10/config-3.10-x86_64-linux-gnu
configure:6873: checking Python3's dll name
configure:6886: result: libpython3.10.a
configure:6901: checking if -pthread should be used
configure:6931: gcc -o conftest -g -O2 -pthread -L/usr/local/lib conftest.c -lselinux >&5
configure:6931: $? = 0
configure:6932: result: yes
configure:6947: checking if compile and link flags for Python 3 are sane
configure:6964: gcc -o conftest -g -O2 -I/opt/conda/include/python3.10 -pthread -L/usr/local/lib conftest.c -lselinux -L/opt/conda/lib/python3.10/config-3.10-x86_64-linux-gnu -lpython3.10 -lcrypt -lpthread -ldl -lutil -lrt -lm -lm >&5
/usr/bin/ld: cannot find -lpython3.10
collect2: error: ld returned 1 exit status
configure:6964: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME ""
| #define PACKAGE_TARNAME ""
| #define PACKAGE_VERSION ""
| #define PACKAGE_STRING ""
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| #define UNIX 1
| #define STDC_HEADERS 1
| #define HAVE_SYS_WAIT_H 1
| #define HAVE_UNSIGNED_LONG_LONG_INT 1
| #define HAVE_LONG_LONG_INT 1
| #define HAVE_SYS_TYPES_H 1
| #define HAVE_SYS_STAT_H 1
| #define HAVE_STDLIB_H 1
| #define HAVE_STRING_H 1
| #define HAVE_MEMORY_H 1
| #define HAVE_STRINGS_H 1
| #define HAVE_INTTYPES_H 1
| #define HAVE_STDINT_H 1
| #define HAVE_UNISTD_H 1
| #define HAVE_SELINUX 1
| #define FEAT_HUGE 1
| #define USE_XSMP_INTERACT 1
| #define FEAT_DIFF 1
| /* end confdefs.h. */
|
| int
| main ()
| {
|
| ;
| return 0;
| }
configure:6968: result: no: PYTHON3 DISABLED
Line 6964 contains the command that's failing, providing the output "/usr/bin/ld: cannot find -lpython3.10". Is anyone familiar with parsing that command and understand what the problem with it that leads to the error?
Further Update: Thanks Friedrich for the hint--the libpython file was indeed not in the location you suggested checking. So nearest I can figure is this wasn't an issue when the system python and conda python were both 3.9, because the versions matched in the check process and passed. When the upstream imaged rolled conda python to 3.10, they no longer matched and failed.
Using the find-libpython module to track it down (because "find" wasn't cutting it), I found that the conda env lib is '/opt/conda/lib/libpython3.10.so.1.0'
So, I tried adding this argument to the config command:
'--with-python3-config-dir=/opt/conda/lib'.
It worked! The config output now said that the compile and link flags are sane.
So, I ran make and then installed. And..... it didn't work. VIM crashed with this as the error:
vim: error while loading shared libraries: libpython3.10.so.1.0: cannot open shared object file: No such file or directory
I believe that the '--with-python3-config-dir=' argument is deprecated, so it might not have been the right path to do down. Now that we know where the libpython file is located, is there a better argument I can provide configure make?
Final update: have a working solution now, which is not to use the deprecated config-dir argument, but instead the --with-python3-command one instead:
./configure --enable-python3interp --disable-gui --without-x --with-python3-command=/usr/bin/python3
With that command, vim compiled with Python3 enabled and starts up fine.
It doesn't seem to matter that it's using the system version of python since I can run any code I want inside the conda environment using the .vimrc and plugins I have set up. So this solves it, appreciate everyone's help=)
ld
is your linker. It's failing because it does not find the filelibpython3.10.a
in any of its include directories. Presumably, that file should be in/opt/conda/lib/python3.10/config-3.10-x86_64-linux-gnu
. That's where the guessing starts. You could verify the file's there and not broken. Most likely it's a misconfiguration. Maybe system libs are fighting those from conda. Without knowing your exact setup one can only guess at the root cause. Try and provide enough context so people can reproduce your problem.