Upcoming changes to scripting for macOS


#1

For developers

first, Use zsh as the default shell on your Mac
and some hacker news comments

second, in the macOS 10.15 Beta Release Notes, with also some hacker news comments

that part

Scripting Language Runtimes

Deprecations

  • Scripting language runtimes such as Python, Ruby, and Perl are included in macOS for compatibility with legacy software. Future versions of macOS won’t include scripting language runtimes by default, and might require you to install additional packages. If your software depends on scripting languages, it’s recommended that you bundle the runtime within the app. (49764202)

  • Use of Python 2.7 isn’t recommended as this version is included in macOS for compatibility with legacy software. Future versions of macOS won’t include Python 2.7. Instead, it’s recommended that you run python3 from within Terminal. (51097165)


How this can impact you? well … with Adobe AIR if you use things like
the NativeProcess class

when in the Device profiles
you define

<supportedProfiles>extendedDesktop</supportedProfiles>

for either a native installer (.dmg or .exe or .deb/.rpm)
see Communicating with native processes in AIR

To communicate with native processes, package an AIR application to be installed via a native installer. The file type of native installer is specific to the operating system for which it is created:

  • It is a DMG file on Mac OS.
  • It is an EXE file on Windows.
  • It is an RPM or DEB package on Linux.

These applications are known as extended desktop profile applications. You can create a native installer file by specifying the -target native option when calling the -package command using ADT.

or a captive runtime
see Packaging a captive runtime bundle for desktop computers

Benefits

  • No separate runtime redistribution required
  • Can use the NativeProcess API

On a mac, when you will execute a shell script something.sh it will now default to zsh if you did not use a shebang line, see On the Shebang

see also File.openWithDefaultApplication() to see a table of of file extension that are prevented to open by default

but that’s with File.openWithDefaultApplication(), with NativeProcess you can run those defaults :slight_smile:

For ex, you could have a simple .bat for Windows and .sh for macOS / Linux that detect if Python is available on the system, and if yes then use NativeProcess to execute script.py.

But that is also changing for macOS, if you relied on Scripting Language Runtimes being already there by default on the system, like Perl, Python, Ruby … well not anymore.

Now, same as Windows, you will have to detect them and propose to install them if they are missing and you need them, or use an alternative method.


To cover all the grounds, you have basically 2 alternatives:

  1. use a native extension or ANE
    will integrate even better with ActionScript 3
    but only Windows and macOS, and you have to develop it / test it / compile it
    eg. maybe not easy for anyone to just add an ANE like that
  2. use a binary executable that does not need to have a scripting engine pre-installed
    for example, you can find some py2exe and alike to convert some python scripts to a binary executable, but sadly does not work on all platforms

Little self promo, if you do use Redtamarin for such small scripts, you can easily convert it to a projector by merging the runtime and the script so in the end the native process run an binary executable (that does not need to depends on a scripting engine being installed on the system).

With the added advantage that you also program it in AS3, and you can produce from the same bytecode, different exe for different platforms: Windows, macOS and Linux.

Very simple example, let’s say you require to be able to read environment variables
with an ANE you will need to write some C/C++ to use the getenv() function
or
with a small Redtamarin program you can quickly implement it and use NativeProcess to get the same functionality, and build an exe.

Or a bit of both, eg. case where you still want to publish on Linux and AIR 2.6 only support NativeProcess but does not support ANE.