Entitlements to use Python from sandbox?

I’m experimenting with the Python plugin of einhugur.com
http://einhugur.com/Html/ScriptEngines.html

does anyone know whether a special requirement for running Python scripts in a sandboxed OS X app is required? And which one, if ever? For instance if one would like to add modules?

I try to make use of Python-docx in order to create word docs directly:
https://python-docx.readthedocs.org/en/latest/index.html

At first I must admit, that I am not completely sure and do not have an active developer account at Apple and I do not have the Einhugur components but read info on their website.

The component seems to be using an preinstalled Python 2.7 or 3.4 on your system. So you need to install the components you’re in need of manually which needs afaik admin rights. Also I do not think that it is possible to access tools out of your sandbox boundaries.

What about integrating a Python version in your distribution, that already has the needed modules and can run in your sandbox?

Python 2.7 is still pre-installed on Mac OS. You might want to ask Björn how the Python stuff is run. Perhaps with a shell?

I’m also using Python. But so far I’m making an application out of a Python script. This needs a shell script for creating the app and then the app of course needs to be signed.

I read a bit about executing external stuff from MAS apps and when I understood correctly, it is prohibited to call external systems like Java, Python etc. from within your app.

Beatrix is right with the preinstalled Python, but it is lacking his needed packages, so he needs to reinstall.

What probably is possible is developing a console python app, make an app/exe out of it by using py2app or similar and include it in your distribution package.

[quote=163788:@Tom Bass]I read a bit about executing external stuff from MAS apps and when I understood correctly, it is prohibited to call external systems like Java, Python etc. from within your app.

Beatrix is right with the preinstalled Python, but it is lacking his needed packages, so he needs to reinstall.

What probably is possible is developing a console python app, make an app/exe out of it by using py2app or similar and include it in your distribution package.[/quote]

Shell is permitted ; I have several MAS apps based on it. So you can execute terminal commands, and from what I read here http://beckism.com/2008/05/run_python_mac_os_x/ it should be no problem.

For instance, save this as hello.py

print "Hello, World!"

Then run in terminal as

Python hello.py

In a shell, “Hello, World!” is returned in shell.result.

Same thing for Java, btw.

@Michel Bujardet You have several MacAppstore (MAS) apps that use terminal? If so, then it’s great and I appreciate being corrected as I am no MAS expert :slight_smile:
The article is from 2008 where no MAS was “visible” and the latest comments seem to talk also only about common, non MAS apps. In non MAS (sandboxed) apps it is definitely possible to access shell.

[quote=163793:@Tom Bass]@Michel Bujardet You have several MacAppstore (MAS) apps that use terminal? If so, then it’s great and I appreciate being corrected as I am no MAS expert :slight_smile:
The article is from 2008 where no MAS was “visible” and the latest comments seem to talk also only about common, non MAS apps. In non MAS (sandboxed) apps it is definitely possible to access shell.[/quote]

Proof is in the pudding. I do have several apps that use Shell http://documentation.xojo.com/index.php/shell sold in the MAS. A couple of them are GUI for command line utilities otherwise difficult to use for average users. They are sandboxed, work perfectly, and sell nicely.

I often use a bash shell script program from within my apps as well.

Please note that I am talking about shell, and not terminal. Terminal is the way to test manually, and shell is the way to automate command lines from within Xojo.

@Michel Bujardet thanks for this information and clarification! Like what I said - I am no MAS expert :slight_smile:

Thank you guys, for all the infos! I will try out and see what is possible. I still want to avoid having to maintain a sandboxed and a non-sandboxed version of the same app. But I could imagine to have a crippled MAS version which does not expose features like creating word documents directly, without word.

For a non-MAS version I still can allow any kind of entitlements and still keep the same data-paths (inside of the sandbox container) for the two versions of the program.

A first test confirms that I can run a python script from a sandboxed app, without setting any special entitlements.
I use the Einhugur plugin to run the script.

What I did is to modify one of the example projects of Einhugur (“Python Simple Test”) and copy its folder “PythonModules” with a CopyFiles step into the ressources folder of the app.

After building, I use AppWrapper 3 to sandbox and codesign the app.

On first start, I copy the python folder with its contents out to Application Support folder in the sandbox container.

And then I altered the example app to look for the modules at the new location.

And like this I can run the python script which are in there. No entitlements set in AppWrapper.

==

What I still have to do is to test whether I can install Python-docx from there as well.

(I try to make use of Python-docx in order to create word docs directly:
https://python-docx.readthedocs.org/en/latest/index.html )