PythonBridge anyone?

Continuing the discussion from How to Open URLs Containing Emoji Characters from an AppleScript:

I noticed this on Reddit:

Python for (macOS) Automation - An in-progress package for automating Mac applications

Hi all, I’ve been working on a “bridge” between Python and AppleScript/JXA that uses PyObjC and ScriptingBridge to interface with applications. The goal is ultimately to simplify communication between Python and Mac applications while staying true to Python conventions. I’m also bringing scripting capabilities to non-scriptable applications through various techniques such as UI scripting, official APIs, URL schemes, etc. It’s still in the early stages, so any and all feedback is appreciated!
Main GitHub repo: GitHub - SKaplanOfficial/PyXA: Python for Automation
Documentation (W.I.P.): PyXA Documentation — PyXA 0.0.7 documentation
A few examples:
PyXA script to save the current Safari tab's URL to a "Saved URLs" note · GitHub Using PyXA, Automator, and PIL to create a mosaic of selected images. · GitHub Using PyXA to get the number of shortcuts in each shortcuts folder · GitHub

This all sounded very familiar…

@estockly: “This all sounded very familiar…”

Heh. I have long since lost count of the skilled knowledgable programmers who go “Hold on a minute lads, I’ve got a great idea.”—only to prove that their greatest idea in the world isn’t worth squit when five minutes’ spent on due diligence would have told them it’s wrong. So when I say “this is very old news”, I mean two decades old!

  1. Appscript is still here, and it had solved the entire problem—correctly—by 2006.[1] The Python3 version definitely still works: there’s a maintainer who keeps the PyPI packages up to date and I still depend on py3-appscript in my own automations (for now).

  2. The original Ruby rb-appscript is defunct, although there was a third-party fork (rb-scpt) which carried it on.

  3. While objc-appscript was atrocious code even by my standards and rightly long-dead, the SwiftAutomation framework that followed it was both >99.9% competent at speaking Apple events and remarkably pleasant in gluing AE’s loosey-goosey and Swift’s “no soup for you!” wildly disparate type systems together. SA’s actually a very nice bridge. (Although I’ve not used it for several years, so no surprises if Apple has broken it since.)

  4. Lastly, there’s nodeautomation which puts appscript-style automation into Node.js. I resurrected (read: largely rewrote) nodeautomation at the start of this year for use in my automated AppleScript-to-JavaScript code translator + migration strategy, for Adobe CC automators who wish to start migrating their existing AppleScript investment over to UXP in the next few years. So that one, while it’s a bit duct-tapey, works too, and will continue to work for as long as I offer AS-to-UXP migration services (hopefully next 3–5 years, Apple- and Adobe-willing).

And that’s not counting all the other first- and third-party AE bridges over the last 30 years, of which there are at least a dozen including Apple’s own efforts. The only three(!) AE bridges that ever worked right were Frontier’s, AppleScript’s, and appscript (including its descendents). Although Mac::Glue may be acknowledged for giving it half-decent crack. All the rest were thoroughly technically unfit for purpose; never mind capturing a market share worth a damn, or even any users at all. (This includes Mark’s own well-intentioned JavaScriptOSA, for anyone curious.)

Anyway, I’ve done SKaplan the solid [2] of pointing out that he’s done it completely wrong and is utterly wasting his time. Whether or not he takes that as constructive feedback or bruised ego is up to him, but to everyone else: Do not waste your time on PyXA. It’s built on Scripting Bridge, and Scripting Bridge can’t automate itself out of a paper bag, never mind be a competent or even credible alternative to AppleScript.


[1] Right before the Mac Automation team’s Scripting Bridge and JXA deliberately went and unsolved it again, cratering Mac Automation’s future for good.

[2] If I sound a tad… pithy, consider that I have, in 20 years, attempted every possible approach, including being super-sweet and helpful, absolutely nice as pie, and none of them worked either. So this is definitely a “them” problem, not merely a “me” problem. So I find it quickest just to be me, blunt as rocks, as this quickly eliminates arrogant unreachable dolts who think they know better. Also ’cos dumping 10,000 hours of my own life into this stuff, plus hundreds of hours of other peoples’ too, just to see it all wasted does make me salty. (So anyone who wishes to talk, please DM so we can go off-list and save everyone else’s eyeballs.)