Build VIM with Python and Ruby via pyenv and rbenv

編譯一個可以動態支援 Python(pyenv) 以及 Ruby(rbenv) 的 VIM.

$ sudo apt install lua5.3 liblua5.3-dev luajit libluajit-5.1-dev tcl-dev libperl-dev
$ CFLAGS="-I/opt/brotli/include -I/opt/curl/include -I/opt/libzip/include -I/opt/openssl/include" \
  CPPFLAGS="-I/opt/brotli/include -I/opt/curl/include -I/opt/libzip/include -I/opt/openssl/include" \
  LDFLAGS="-L/opt/brotli/lib -L/opt/curl/lib -L/opt/libzip/lib -L /opt/openssl/lib" \
  CONFIGURE_OPTS="--enable-shared \
  --enable-optimizations \
  --enable-loadable-sqlite-extensions \
  --enable-ipv6 \
  --with-doc-strings \
  --with-pymalloc \
  --with-c-locale-coercion \
  --with-dtrace \
  --with-openssl=/opt/openssl" \
  pyenv install 2.7.16

$ CFLAGS="-I/opt/brotli/include -I/opt/curl/include -I/opt/libzip/include -I/opt/openssl/include" \
  CPPFLAGS="-I/opt/brotli/include -I/opt/curl/include -I/opt/libzip/include -I/opt/openssl/include" \
  LDFLAGS="-L/opt/brotli/lib -L/opt/curl/lib -L/opt/libzip/lib -L /opt/openssl/lib" \
  CONFIGURE_OPTS="--enable-shared \
  --enable-optimizations \
  --enable-loadable-sqlite-extensions \
  --enable-ipv6 \
  --with-doc-strings \
  --with-pymalloc \
  --with-c-locale-coercion \
  --with-dtrace \
  --with-openssl=/opt/openssl" \
  pyenv install 3.7.3

$ RUBY_CONFIGURE_OPTS="--enable-shared \
  --enable-shared \
  --enable-dtrace \
  --with-openssl-dir=/opt/openssl" \
  rbenv install 2.6.3

$ pyenv local --unset
$ pyenv shell --unset
$ pyenv global 2.7.16 3.7.3

$ rbenv local --unset
$ rbenv shell --unset
$ rbenv global 2.6.3

$ pyenv versions
  system
* 2.7.16 (set by /home/kouni/.pyenv/version)
* 3.7.3 (set by /home/kouni/.pyenv/version)
$ python -V
Python 2.7.16
$ python3 -V
Python 3.7.3

$ rbenv versions
* 2.6.3 (set by /home/kouni/.rbenv/version)
$ ruby -v
ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux]

$ git clone https://github.com/vim/vim.git
$ cd vim
$ CFLAGS="-O3" LDFLAGS="-Wl,-rpath=${HOME}/.pyenv/versions/2.7.16/lib:${HOME}/.pyenv/versions/3.7.3/lib:${HOME}/.rbenv/versions/2.6.2/lib" ./configure \
  --prefix=/opt/vim \
  --enable-fail-if-missing \
  --enable-luainterp \
  --enable-mzschemeinterp \
  --enable-perlinterp \
  --enable-pythoninterp=dynamic \
  --enable-python3interp=dynamic \
  --enable-tclinterp \
  --enable-rubyinterp=dynamic \
  --enable-cscope \
  --enable-terminal \
  --enable-multibyte \
  --enable-hangulinput \
  --enable-xim \
  --enable-fontset \
  --enable-gui \
  --enable-gnome-check \
  --with-modified-by="Kouni" \
  --with-features=huge \
  --with-luajit \
  --with-x \
$ make
$ sudo make install

測試:

$ vim --version | egrep -iE 'ruby|python'

:python print(sys.version)

:python3 print(sys.version)

ref: https://github.com/lambdalisue/vim-pyenv/issues/8

comments powered by Disqus