Hacker News new | ask | show | jobs
by teilo 2045 days ago
I was surprised to see that we got native Ruby 2.6 and Python 3.8 in the box. I thought Apple had deprecated scripting languages.
1 comments

Apple deprecated direct access to system-provided interpreter installations, which is a good thing. Interpreter support was not and will not be a problem, the implication of the deprecation is you should install your own copy of those interpreters instead.
Yes, I understand that we can and should always install our own, and I have for years either with Homebrew or Conda. (Actually most of my development is python on Linux via Vagrant).

But on the M1 Mini, out of the box, you can open Terminal, and python3 launches the Python 3.8 REPL. Python 2.7 also launches out of the box. So, can you explain what you mean by "direct access" not being allowed? I'm not following your distinction.

It's damn convenient having python always available when managing a fleet of Macs with JAMF.

I can imagine many existing tools still rely on the commands being directly accessible on PATH, and Apple may be reluctant to break them outright even that’s the goal. They are declared deprecated so people would refrain from using them for new things, and move old things away from them. That’s basically what deprecation means in software, as I understand it. Those commands wouldn’t be called deprecated if Apple breaks them outright.
Right, but in that case I would not expect them to upgrade Python to 3.8.
It’s quite likely Apple still wants Python.framework to be available (which is not deprecated) and it’s easier to upgrade the whole thing.
Python 3.8 for example got moved from the base OS install to Xcode's command line toolset. For developers, that doesn't change much.
It's in the base OS actually.
Nope. Python2 is inbox, but Python3 redirects to the Xcode/developer tools copy.

  % sw_vers
  ProductName: macOS
  ProductVersion: 11.1
  BuildVersion: 20C5048k
  % ls /Library/Python/                  
  2.7
  % ls /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/
  Headers  Python3  Resources Versions
  % ls /System/Library/Frameworks/Python.framework/
  Python  Resources Versions
Ok. Well, I don't have the Xcode command line tools installed. This is what I see:

  % ls -l /usr/bin/python*
  lrwxr-xr-x  1 root  wheel      75 Jan  1  2020 /usr/bin/python -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
  lrwxr-xr-x  1 root  wheel      82 Jan  1  2020 /usr/bin/python-config -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7-config
  lrwxr-xr-x  1 root  wheel      75 Jan  1  2020 /usr/bin/python2 -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
  lrwxr-xr-x  1 root  wheel      75 Jan  1  2020 /usr/bin/python2.7 -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
  lrwxr-xr-x  1 root  wheel      82 Jan  1  2020 /usr/bin/python2.7-config -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7-config
  -rwxr-xr-x  1 root  wheel  137536 Jan  1  2020 /usr/bin/python3
  lrwxr-xr-x  1 root  wheel      76 Jan  1  2020 /usr/bin/pythonw -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/pythonw2.7
  lrwxr-xr-x  1 root  wheel      76 Jan  1  2020 /usr/bin/pythonw2.7 -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/pythonw2.7

  % ls -l /usr/bin/pip*
  -rwxr-xr-x  1 root  wheel  137536 Jan  1  2020 /usr/bin/pip3
I had assumed that /usr/bin/python3 was part of the system, since it is not a symlink. But then when I do this, I see it is indeed hitting Xcode:

   % /usr/bin/python3
  objc[12852]: Class AMSupportURLConnectionDelegate is implemented in both ?? (0x20ab7e7a0) and ?? (0x1143782b8). One of the two will be used. Which one is undefined.
  objc[12852]: Class AMSupportURLSession is implemented in both ?? (0x20ab7e7f0) and ?? (0x114378308). One of the two will be used. Which one is undefined.
  Python 3.8.2 (default, Oct  2 2020, 10:45:41)
  [Clang 12.0.0 (clang-1200.0.32.27)] on darwin
  Type "help", "copyright", "credits" or "license" for more information.
  >>> import os
  >>> print(os.environ['PYTHONPATH'])
  Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/os.py", line 675, in __getitem__
      raise KeyError(key) from None
  KeyError: 'PYTHONPATH'
So Xcode is definitely involved.

EDIT: So I uninstalled Xcode. /usr/bin/python3 is there, but it is clearly a stub file of some sort. If you run it without Xcode or Xcode command line tools installed, you get a popup to install the command line tools. So python3 is not part of the system, but the stubs for it are. Thanks for the patience.

Even more interesting, if you have Xcode, but not the command line tools, the stub launches Python3.8 from the Xcode installation. Once you install the command line tools, it then switches to launching that version. Presumably this is all because of the read-only system volume.