Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python in Windows Store apps

The Windows Store app Python 3 For Metro claims that it allows users to edit and run Python files (I can't get it to work). How is this possible from within the sandbox? Can I run a file (say test.py on the desktop) from my JavaScript app?

like image 336
Max Ferguson Avatar asked Jan 08 '13 09:01

Max Ferguson


People also ask

Is Python available in Windows Store?

The Python interpreter and the extensive standard library are freely available in source or binary form for all major platforms from the Python Web site, https://www.python.org/, and may be freely distributed.

Should I install Python from Windows Store?

I highly recommend you not to use python installed from the Windows Store, because you'll face such errors, and even more nasty ones.

Is Python free on Microsoft Store?

Python Tools for Visual Studio is a completely free extension, developed and supported by Microsoft with contributions from the community. Visit our Github page to see or participate in PTVS development.

How do I install Python on Windows Store?

To install the package, ensure you have the latest Windows 10 updates and search the Microsoft Store app for “Python 3.11”. Ensure that the app you select is published by the Python Software Foundation, and install it. Python will always be available for free on the Microsoft Store.


2 Answers

How is this possible from within the sandbox?

I have ported the Python interpreter to WinRT to achieve that. Instead of using Win32 API, it now uses WinRT API (in particular for reading files from the user's Documents folder).

Can I run a file (say test.py on the desktop) from my JavaScript app?

In principle, yes. You need to take the python33.dll from my app, wrap it as a WinRT component, and then call it. It actually is a WinRT component already, but doesn't expose any of the Python API. See

http://hg.python.org/sandbox/loewis/file/ee9f8c546ddd/win8app/python33

like image 199
Martin v. Löwis Avatar answered Sep 27 '22 17:09

Martin v. Löwis


Basically, what you need to do is write a C++ "shell" app according to the Metro rules, then host the Python interpreter inside that C++ app. And again, scrub the Python codebase so that it runs within the Metro sandbox.

You can then go a step further, and have the C++ shell expose WinRT libraries to the Python environment. There's probably a way to get Python to expose WinRT objects, but that would be a LOT of work.

You won't be able to call directly from JavaScript into Python - you'll need a WinRT component in the middle.

This is a lot of work, and requires some fairly low level work in C.

like image 30
Chris Tavares Avatar answered Sep 27 '22 17:09

Chris Tavares