Run python script from the App Sandbox

Curious, is it possible to run a python.py script from the application (App Sandbox) with the foundation.Process?
Or the only way is to include the python distribution under my App, somewhere in Framework or Helpers?
Sure. It's possible. But why would you bother? Why not just do whatever you need to do inside your app?

Of course, I know the answer to that question. Whatever you are trying to do in python is likely more than just a basic python script. Such a task would be difficult, if not impossible, to do using the system-provided python. It might not even be possible if you bundle your own Python. Why do people insist on bundling Python or Java or Electron into everything? Why not just write the app? Yeah. Writing apps is hard. But trust me, getting self-contained, 3rd party runtime machines working in the app sandbox is harder. I'm sure someone will eventually cobble together some "recipe" to help others do it. But all that does is spawn yet another generation of abandon-ware apps. We got plenty of those already.
Lol, for me it is required, as I am building RegExp testing utility (https://apps.apple.com/us/app/regexp/id1546140065) for various languages. Implementations in languages have slight differences, so the best ways to implement flavors is to use the original languages.

Right now I have:
  • Swift/Objc with NSRegularExpression

  • Go (that was easy, considering I can build a CLI and just embed it in the Helpers as CLI tool)

  • JavaScript (with WebKit embedded)

For Python/Ruby, etc I don't want to **** the application itself, and want to use shipped with Mac Python runtimes.

So back to my question, when I try to launch a process with

Code Block
let task = Process()
task.executableURL = "/usr/bin/python3"
task.arguments = [[URL(fileURLWithPath: "python.py", relativeTo: Bundle.main.resourceURL).path]]
...


I get

Code Block
xcrun: error: cannot be used within an App Sandbox


So my original question is, my guess if that is possible to do with App Sandbox, I need to:
  • give some additional capabilities?

  • maybe ask user to point to the Python and have "read-only" access to the file (but that would not give execution permission on the file)

I will appreciate any pointers to what to try, what to read.

For me I have to use the USDZ Tools written in python 3.7 on the x86 architecture.

I could not find any alternatives that converts USDC binary file into USDA Ascii format.

I tried PythonKit which require you to remove the sandbox.

I tried portable-python which always results in errors, possibly due their build script.

To conclude, I would love to use an USDZ Tools built for Swift or even C, but it simply does not exist. So I had to resort to trying to have a python environment in Swit, eventhough it sounds unreasonable and should be avoided.

Run python script from the App Sandbox
 
 
Q