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?
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.
I highly recommend you not to use python installed from the Windows Store, because you'll face such errors, and even more nasty ones.
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.
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.
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With