Skip to content

Instantly share code, notes, and snippets.

@misraX
Last active April 2, 2020 01:19
Show Gist options
  • Save misraX/7ff0483ecaf84d476c194730740d6abe to your computer and use it in GitHub Desktop.
Save misraX/7ff0483ecaf84d476c194730740d6abe to your computer and use it in GitHub Desktop.
macOS Installing Vim From Source With Python3, Python2 and Ruby Support.

README file guides to install latest vim with python2, python3 and ruby using official source installers:

These methods have been tested in macOS sierra 10.12.6 and will likely not fail in most macOS new releases.

Tested with:

  • xcode-select version 2347.
  • Python 3.6.2.
  • Python 2.7.14.
  • VIM - Vi IMproved 8.0.
  • Apple LLVM version 9.0.0 (clang-900.0.37).
  • Ruby 2.4.2p198.

Lets start:

Prerequirments:

  • Xcode command line tools.
  • Python3.
  • Python2.
  • Ruby Stable.

1- Xcode command line tools (If you already installed it Skip this method)

$ xcode-select --install

2- Installing python3 and python2 latest version from the official python website.

https://www.python.org/downloads/mac-osx/

3- Preparing a build folder:

 $ mkdir -p ~/buildFolder
 $ cd ~/buildFolder

4- Installing latest stable version of ruby from source.

$ curl https://cache.ruby-lang.org/pub/ruby/2.4/ruby-2.4.2.tar.gz
$ tar -xzfv ruby-2.4.2.tar.gz
$ cd ruby-2.4.2
$ ./configure
$ make
$ sudo make install
$ cd ..

5- Installing vim:

$ git clone https://github.com/vim/vim.git
$ cd vim
$ cd src
$ make distclean  # if you build Vim before
$ make
$ sudo make install
$ ./configure \
    --enable-multibyte \
    --enable-perlinterp=dynamic \
    --enable-rubyinterp=dynamic \
    --with-ruby-command=/usr/local/bin/ruby \
    --enable-pythoninterp=dynamic \
    --with-python-config-dir=/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config \
    --enable-python3interp \
    --with-python3-config-dir=/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/config-3.6m-darwin \
    --enable-cscope \
    --enable-gui=auto \
    --with-features=huge \
    --with-x \
    --enable-fontset \
    --enable-largefile \
    --disable-netbeans \
    --with-compiledby="misraX https://github.com/misraX" \
    --enable-fail-if-missing

Notes about number 5 and setting python config dir:

  • macOS builtin python2.7 config directory is in /usr/lib/python2.7/config/
  • Official Python installer install python in /Library/Frameworks/Python.framework/Versions/VERSION_NUMBER so the configurateion folder will be in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config for python 2.7 and in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/config-3.6m-darwin for python 3.6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment