Skip to content

Conversation

@eirnym
Copy link
Contributor

@eirnym eirnym commented Aug 26, 2018

Uses Python 3.7 from Python.org if installed (this was overlooked since build 150), credits to @kiryph
Adds checks MacPorts if python from it is used after Homebrew.

@kiryph
Copy link

kiryph commented Aug 26, 2018

Great idea to improve the macvim/vimrc file itself, so python3 installation from macports, next to https://www.python.org/downloads/mac-osx/, is also used if present.

Add homebrew as well

I think you did not actually add the location of homebrew:

set pythonthreehome=/usr/local/Frameworks/Python.framework/Versions/3.7

This would be a third if-clause.
Homebrew python3 is used by default from macvim. So your PR should be fine.

(I do not like the asymmetry between python2 and python3 configuration: python2-homebrew has to be set, for python3-homebrew nothing; maybe this has something to do that a python2 is pre-installed)

@eirnym
Copy link
Contributor Author

eirnym commented Aug 26, 2018

macOS still doesn't have any Python3 preinstalled and this leads to a different handling of Python versions. Rumors said that macOS 10.14 doesn't have it as well.
So for basic binary installation you'll have no problem to use :py or :pyx commands, but it's required to install Python 3 from any other source if needed.

@kiryph
Copy link

kiryph commented Aug 26, 2018

By default the pre-installed python2 is used?

@eirnym
Copy link
Contributor Author

eirnym commented Aug 26, 2018

yes, according to strings Vim | grep Python (I use the binary installation from github)

@kiryph
Copy link

kiryph commented Aug 27, 2018

I also use the binary installation from github. So the results on my machine agree:

❯ strings /Applications/MacVim.app/Contents/MacOS/Vim | grep Python
/usr/local/Frameworks/Python.framework/Versions/3.7/Python
/System/Library/Frameworks/Python.framework/Versions/2.7/Python

It is good to confirm this specifically. Thanks for pointing this method out.
However, I noticed in the past that the exact version has to match, e.g. 3.6.4 instead of 3.6.3.
Do you know a possibility how to figure the exact version number out from the binary?

Order of Used Python Versions

determined how MacVim is built and by the distributed MacVim $VIM/vimrc

Python2:

  1. /usr/local/Library/Frameworks/Python.framework/Versions/2.7 (Homebrew)
  2. /opt/local/Library/Frameworks/Python.framework/Versions/2.7 (MacPorts)
  3. /System/Library/Frameworks/Python.framework/Versions/2.7 (system, configured)

Python3:

  1. /usr/local/Library/Frameworks/Python.framework/Versions/3.7 (Homebrew, configured)
  2. opt/local/Library/Frameworks/Python.framework/Versions/3.7 (MacPorts)
  3. /Library/Frameworks/Python.framework/Versions/3.7 (python.org)

Update Comments

IMHO, the comments in $VIM/vimrc could be updated and made more explicit:

" Python2
" MacVim is configured by default to use the pre-installed python2 version in
" /System/Library/Frameworks/Python.framework/Versions/2.7/Python
" However, following code adjusts the used python2 version if a Homebrew or
" MacPorts python2 installation can be found:
" Python3
" MacVim is configured to use Homebrew python3 installed into
" /usr/local/Frameworks/Python.framework/Versions/3.7/Python
" If this cannot be found, following code tries to find a MacPorts
" or python3 installation from python.org:

Also a comment from https://github.com/macvim-dev/macvim/wiki/Python-2.x-and-Python-3.x
could be added:

" Python2 & Python3
" Common Python distribution doesn't allow to use Python 2.7 and Python 3.7
" at the same time due to Python shared module loading.
" More details and how to built python2, python3 and MacVim yourself
" to achieve this can be found here
" https://github.com/macvim-dev/macvim/wiki/Python-2.x-and-Python-3.x

Finally, the user could be reminded if he has installed python2/3 in a non-default directory, he must
adjust it himself in his vimrc.

Python2 from python.org

For python2, an installation from https://www.python.org/downloads/release/python-2715/
could be also be preferred instead of the pre-installed version. The order would look like

  1. /usr/local/Library/Frameworks/Python.framework/Versions/2.7 (Homebrew)
  2. /opt/local/Library/Frameworks/Python.framework/Versions/2.7 (MacPorts)
  3. /Library/Frameworks/Python.framework/Versions/2.7 (python.org)
  4. /System/Library/Frameworks/Python.framework/Versions/2.7 (system, configured)

@eirnym
Copy link
Contributor Author

eirnym commented Aug 28, 2018

@kiryph added comments without paths as they constant and well known for both installations. Also I added a python 2.7 from python.org installation detection. Although, I resigned to add a comment of simulteniuos loading of Python 2 and 3 as it described in :help python page as this is a part of the base Vim as well as adjusting these pats. Nevertheless, you is allowed to specify paths as they're just options.

@splhack splhack merged commit 592e3c7 into macvim-dev:master Sep 22, 2018
@eirnym eirnym deleted the vimrc-python37 branch September 22, 2018 10:23
ychin added a commit to ychin/macvim that referenced this pull request Dec 5, 2018
Vim patch 8.1.560

Targets macOS 10.8+

Features:
- macOS Mojave (10.14) is now supported.
    - MacVim's UI now works with Dark Mode.
    - Fixed broken rendering and flickering under Mojave when using the
      default Core Text renderer. macvim-dev#757
- guioption 'k' is supported again. macvim-dev#731
    - This option prevents window from resizing when UI elements such as
      toolbars or tabs show or hide themselves.

Fixes:
- Fixed misc fullscreen and window resizing bugs and artifacts macvim-dev#745
- Dragging tabs to reorder now works properly macvim-dev#789
- Fixed timer callback handling in GUI macvim-dev#749
- Fixed native tabs (10.12+) interring with Vim tabs macvim-dev#788
- Fixed Japanese IME Ctrl-U/Ctrl-O handling macvim-dev#742
- Fixed MMShareFindPboard and Cmd-E/Cmd-G interactions macvim-dev#780
- Better handling of guifontwide font size macvim-dev#737
- Better python discovery in default vimrc macvim-dev#739

Known Issues:
- Scrolling performance is slightly worse under Mojave macvim-dev#796

Script interfaces have compatibility with these versions:
- Lua 5.3
- Perl 5.18
- Python2 2.7
- Python3 3.7
- Ruby 2.5
ychin added a commit that referenced this pull request Dec 5, 2018
Vim patch 8.1.560

Targets macOS 10.8+

Features:
- macOS Mojave (10.14) is now supported.
    - MacVim's UI now works with Dark Mode.
    - Fixed broken rendering and flickering under Mojave when using the
      default Core Text renderer. #757
- guioption 'k' is supported again. #731
    - This option prevents window from resizing when UI elements such as
      toolbars or tabs show or hide themselves.

Fixes:
- Fixed misc fullscreen and window resizing bugs and artifacts #745
- Dragging tabs to reorder now works properly #789
- Fixed timer callback handling in GUI #749
- Fixed native tabs (10.12+) interring with Vim tabs #788
- Fixed Japanese IME Ctrl-U/Ctrl-O handling #742
- Fixed MMShareFindPboard and Cmd-E/Cmd-G interactions #780
- Better handling of guifontwide font size #737
- Better python discovery in default vimrc #739

Known Issues:
- Scrolling performance is slightly worse under Mojave #796

Script interfaces have compatibility with these versions:
- Lua 5.3
- Perl 5.18
- Python2 2.7
- Python3 3.7
- Ruby 2.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants