LeaderF icon indicating copy to clipboard operation
LeaderF copied to clipboard

C extension import with error

Open wlt-cortex opened this issue 2 years ago • 0 comments

  • vim or neovim?
    • [x] vim
    • [ ] neovim
  • Output of vim --version or nvim --version:

VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Oct 24 2020 16:26:37) Included patches: 1-1897 Modified by [email protected] Compiled by [email protected] Huge version without GUI. Features included (+) or not (-): +acl -farsi +mouse_sgr +tag_binary +arabic +file_in_path -mouse_sysmouse -tag_old_static +autocmd +find_in_path +mouse_urxvt -tag_any_white +autochdir +float +mouse_xterm -tcl -autoservername +folding +multi_byte +termguicolors -balloon_eval -footer +multi_lang +terminal +balloon_eval_term +fork() -mzscheme +terminfo -browse +gettext +netbeans_intg +termresponse ++builtin_terms -hangul_input +num64 +textobjects +byte_offset +iconv +packages +textprop +channel +insert_expand +path_extra +timers +cindent +ipv6 -perl +title -clientserver +job +persistent_undo -toolbar -clipboard +jumplist +popupwin +user_commands +cmdline_compl +keymap +postscript +vartabs +cmdline_hist +lambda +printer +vertsplit +cmdline_info +langmap +profile +virtualedit +comments +libcall -python +visual +conceal +linebreak +python3 +visualextra +cryptv +lispindent +quickfix +viminfo +cscope +listcmds +reltime +vreplace +cursorbind +localmap +rightleft +wildignore +cursorshape -lua -ruby +wildmenu +dialog_con +menu +scrollbind +windows +diff +mksession +signs +writebackup +digraphs +modify_fname +smartindent -X11 -dnd +mouse +sound -xfontset -ebcdic -mouseshape +spell -xim +emacs_tags +mouse_dec +startuptime -xpm +eval +mouse_gpm +statusline -xsmp +ex_extra -mouse_jsbterm -sun_workshop -xterm_clipboard +extra_search +mouse_netterm +syntax -xterm_save system vimrc file: "$VIM/vimrc" user vimrc file: "$HOME/.vimrc" 2nd user vimrc file: "~/.vim/vimrc" user exrc file: "$HOME/.exrc" defaults file: "$VIMRUNTIME/defaults.vim" fall-back for $VIM: "/usr/share/vim" Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -Wdate-time -g -O2 -fdebug-prefix-map=/build/vim-KZNIhZ/vim-8.2.1897=. -fstack-protector-strong -Wformat -Werror=format-security -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 Linking: gcc -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim -lm -ltinfo -lselinux -lcanberra -lacl -lattr -lgpm -ldl -L/usr/lib/python3.6/config-3.6m-x86_64-linux-gnu -lpython3.6m -lpthread -ldl -lutil -lm

  • Output of :echo has("python"): 0
  • Output of :echo has("python3"): 1
  • Output of :echo &pythondll(only vim, not neovim):
  • Output of :echo &pythonthreedll(only vim, not neovim):
  • Output of :py print(sys.version):
  • Output of :py3 print(sys.version):

3.6.9 (default, Mar 15 2022, 13:55:28) [GCC 8.4.0]

  • Output of :echo g:Lf_Debug_Cmd:
  • Output of :echo g:Lf_FilesFromCache:
  • Operating system:
    • [x] Linux
    • [ ] Mac OS X
    • [ ] Windows
    • [ ] Etc.
  • Configurations related to LeaderF in vimrc:

Describe your question, feature request, or bug.

After installing the c extension with :LeaderfInstallCExtension, and launching vim with any Leaderf command, there is still output 0 for echo g:Lf_fuzzyEngine_C.

I have dive into the Leaderf source code, and found the code in autoload/leaderf/python/leaderf/manager.py

is_fuzzyEngine_C = False
try:
    import fuzzyEngine
    is_fuzzyEngine_C = True
    cpu_count = multiprocessing.cpu_count()
    lfCmd("let g:Lf_fuzzyEngine_C = 1")
except ImportError as e:
    raise Exception(e)
    lfCmd("let g:Lf_fuzzyEngine_C = 0")

raise a ImportError: undefined symbol: Py_InitModule4_64.

Cause the compilation python version used in install.sh is my work environment, which exactly is 3.7.7. The actually python version Leaderf depends on is the VIM's version, aka 3.6.

Steps to reproduce

Execute the install.sh to compile fuzzyEngine and fuzzyMatchC library with python 3.7.7, and import the library .so (which is the fuzzyEngine.cpython-37m-x86_64-linux-gnu.so and fuzzyMatchC.cpython-37m-x86_64-linux-gnu.so in my machine) with VIM's python version (which is python 3.6 in my env).

Actual behaviour

Raise a ImportError: undefined symbol: Py_InitModule4_64.

Expected behaviour

I suggest that the install.sh may be written in a more robust way, to avoid the possible conflict between python versions. In my scene, I recompile the fuzzy library with the full python binary (3.6) path manually, and then it works.

wlt-cortex avatar Jun 01 '22 02:06 wlt-cortex