Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 584426 - app-editors/vim: load libpython2.7.dylib from /usr/lib instead of from $EPREFIX
Summary: app-editors/vim: load libpython2.7.dylib from /usr/lib instead of from $EPREFIX
Status: RESOLVED FIXED
Alias: None
Product: Gentoo/Alt
Classification: Unclassified
Component: Prefix Support (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Prefix
URL:
Whiteboard:
Keywords: PATCH
Depends on:
Blocks:
 
Reported: 2016-05-29 05:27 UTC by yegle
Modified: 2020-12-13 16:16 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description yegle 2016-05-29 05:27:24 UTC
It looks like vim is linked to /usr/bin/python for some reason.

1. Run ":python import sys; print(sys.version);" in vim from prefix, gives
2.7.10 (default, Oct 23 2015, 19:19:21)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)]

$ /usr/bin/python -c 'import sys; print(sys.version)'
2.7.10 (default, Oct 23 2015, 19:19:21)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)]

$ .gentoo/usr/bin/python2 -c 'import sys; print(sys.version)'
2.7.11 (default, Apr 24 2016, 11:32:08)
[GCC 4.2.1 Compatible Clang 3.7.1 (tags/RELEASE_371/final)]

which indicate the interpreter is /usr/bin/python

2. But at the same time I can't find any clue that it's indeed linked to system python:

$ otool -L .gentoo/usr/bin/vim
.gentoo/usr/bin/vim:
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)
	/Users/ych/.gentoo/usr/lib/libncurses.6.dylib (compatibility version 6.0.0, current version 6.0.0)
	/Users/ych/.gentoo/usr/lib/libiconv.2.dylib (compatibility version 8.0.0, current version 8.1.0)

Output from emerging vim:
checking --enable-pythoninterp argument... yes
checking for python2... /Users/ych/.gentoo/usr/bin/python2.7
checking Python version... 2.7
checking Python is 2.3 or better... yep
checking Python's install prefix... /Users/ych/.gentoo/usr
checking Python's execution prefix... /Users/ych/.gentoo/usr
checking Python's configuration directory... /Users/ych/.gentoo/usr/lib/python2.7/config
checking Python's dll name... libpython2.7.dylib
checking if -pthread should be used... no
checking if compile and link flags for Python are sane... yes
checking --enable-python3interp argument... yes
checking for python3... /Users/ych/.gentoo/usr/bin/python3.5
checking Python version... 3.5
checking Python is 3.0 or better... yep
checking Python's abiflags...
checking Python's install prefix... /Users/ych/.gentoo/usr
checking Python's execution prefix... /Users/ych/.gentoo/usr
checking Python's configuration directory... /Users/ych/.gentoo/usr/lib/python3.5/config-3.5
checking Python3's dll name... libpython3.5.dylib
checking if -pthread should be used... no
checking if compile and link flags for Python 3 are sane... yes
checking whether we can do without RTLD_GLOBAL for Python... no
checking whether we can do without RTLD_GLOBAL for Python3... yes

3. it even gives bizarre result when executing ":python import sys; print(sys.path)" in vim:
[u'/Users/ych/.vim/bundle/YouCompleteMe/python/ycm/../../third_party/ycmd', u'/Users/ych/.vim/bundle/YouCompleteMe/autoload/../pyt
hon', '/Users/ych/.gentoo/usr/lib/python27.zip', '/Users/ych/.gentoo/usr/lib/python2.7', '/Users/ych/.gentoo/usr/lib/python2.7/pla
t-darwin', '/Users/ych/.gentoo/usr/lib/python2.7/plat-mac', '/Users/ych/.gentoo/usr/lib/python2.7/plat-mac/lib-scriptpackages', '/
Users/ych/.gentoo/usr/Extras/lib/python', '/Users/ych/.gentoo/usr/lib/python2.7/lib-tk', '/Users/ych/.gentoo/usr/lib/python2.7/lib
-old', '/Users/ych/.gentoo/usr/lib/python2.7/lib-dynload', '/Users/ych/.gentoo/usr/lib/python2.7/site-packages', '_vim_path_']
Comment 1 yegle 2016-05-29 16:10:46 UTC
Managed to get a dtruss result:

11658/0x145b8e:    165475      40     28 stat64("libpython2.7.dylib\0", 0x7FFF5051ED48, 0x1)         = -1 Err#2
11658/0x145b8e:    165490      17     12 stat64("/Users/ych/lib/libpython2.7.dylib\0", 0x7FFF5051F128, 0x1)      = -1 Err#2
11658/0x145b8e:    165508      20     16 stat64("/usr/local/lib/libpython2.7.dylib\0", 0x7FFF5051F128, 0x1)      = -1 Err#2
11658/0x145b8e:    165760     762    251 stat64("/usr/lib/libpython2.7.dylib\0", 0x7FFF5051F128, 0x1)        = 0 0
11658/0x145b8e:    165874     847    106 open("/usr/lib/libpython2.7.dylib\0", 0x0, 0x0)         = 3 0

If I link /Users/ych/lib/libpython2.7.dylib to the one in $EPREFIX, then it load the correct interpreter. I'm currently using this as a workaround.
Comment 2 yegle 2016-05-29 16:48:35 UTC
Okay, so vi_cv_dll_name_python in vim's configure eventually passed to dlopen(). Since we want to make sure it always load the libpython2.7.dylib in $EPREFIX, we should set it to an absolute path instead of just `libpython2.7.dylib`.
Comment 3 yegle 2016-05-29 17:01:56 UTC
A patch like this would work (obviously need some improvement to not hardcode ".dylib")

--- app-editors/vim/vim-7.4.1821.ebuild.orig	2016-05-29 10:00:28.000000000 -0700
+++ app-editors/vim/vim-7.4.1821.ebuild	2016-05-29 10:01:15.000000000 -0700
@@ -213,6 +213,7 @@
 				myconf+=(
 					--enable-python${v}interp
 					vi_cv_path_python${v}="${PYTHON}"
+					vi_cv_dll_name_python${v}="${EPREFIX}/usr/lib/lib${EPYTHON}.dylib"
 				)
 			}
Comment 4 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2020-12-08 07:32:42 UTC
Still an issue?
Comment 5 Fabian Groffen gentoo-dev 2020-12-13 16:16:37 UTC
just verified, this works fine nowadays