Cross Platform Python Executable - Mac & Windows? - python

I used pyinstaller to create an executable file (Desktop GUI). I am on Windows, and the person I am sending it to is on Mac.
I was under the impression that pyinstaller was cross platform, but the Mac user gets an error when trying to run the app. What are my options for distributing my GUI for both Windows and Mac?
I have not been able to find a straightforward answer and do not have a Mac to test with. I saw Inno Setup, but haven't found anything saying whether or not it's cross platform.
I need to create a script that can run both Windows and Mac. I am also looking for an easy way to send it electronically.

I have no knowledge of Python but after a quick serach on the internet came up with this which might help you.
A few months ago I went through this process (rather painstakingly I might add) to deploy a simple Xamarin Cross Platform App. In my own experience I have learned that the macOS has very strict rules about how software is to be packaged for deployment on a computer.
If you are using Visual Studio for Mac it will automatically build a packaged installer for you. But, you do have to purchase (at an yearly cost) a Developer ID.
Then, you create specific provision profiles for your application and these are used along with your developer ID to sign your packaged installer. I found it somewhat complicated!
Finally, you follow a procedure via the console on the mac to submit your package for an automatic scan. This is referred to as getting your package notarized (link to a SO question about that process).They provide you a result that then gets stapled to the package.
It is like a double signing. Once this is done then the package can be installed by users using the macOS.
An alternative is that the user run a instance of Windows by using a software package called Parallels. I have to say it is very good and I did enjoy my trial of the software, You can fire up Windows from inside the macOS (no need to reboot) and since it is Windows you can simply run your stahdard installers.
In summary, for the macOS, if you do not correctly sign your package with a developer and application ID, and don't get it notarized and stapled the operating system will throw it back out at you and not run it.

Related

How do I get Python code to run in RStudio? No Python installed in the system

I'm working on a research project where the data is stored in a remote Windows desktop. The desktop does not have Python, it only has Rstudio, but most of the research conducted in this topic was in Python. I want to benchmark already existing implementations, but I can't run the code on the data because there's no Python and this will not change. As far as I understand, tools like reticulate still need an underlying Python interpreter in the system to work and I am not allowed to do that.
Has anyone come up with a smart solution that does not involve me manually translating the python code to R? Any R packages that can read python? Any other out-of-the-box ideas on how to get that code to run on the data?
Can't install Python on Windows? Just Use WinPython
WinPython is a free open-source portable distribution of the Python programming language for Windows 8/10 and scientific and educational usage.
Since it is portable, it is a zero install option. This is probably the best option for you.
https://winpython.github.io/
Once you have WinPython on the machine, if you want to use it with RStudio, you'll need to configure reticulate to use it.
Say you have (1) the remote Windows Desktop that does not have Python and (2) the local computer you work on.
Use the remote Windows Desktop (1) as a git repository, clone that repository on your local machine, make changes to it and run locally using Python, then submit the code to the remote repository again.

Equivalent of pywinauto library for debian

I'm looking for an equivalent Python library that will work when I run my script on Raspberry Pi. I'm under the impression that pywinauto only works on windows machine.
I want to control some inputs to a GUI launched by my script, using my script. Apart from pywinauto I have no idea how to do this. I thought about using command line to control the software directly, but if there is a simpler way I would really appreciate knowing about it.
Thanks for your time.
ATSPI is an Linux accessibility technology to obtain GUI text/rectangle properties programmatically. See how to find and run ATSPI registry daemon and how to enable ATSPI for the most popular types of GUI apps. Usually it's
$ /usr/libexec/at-spi-registryd &
There is a Python bindings for ATSPI. See this answer for details:
How to install pyatspi?
The pyatspi package has too many dependencies like pygobject etc. It also requires some compilation during installation steps. We think this is not user friendly so we decided to use libatspi.so directly (without any dependencies). This work status can be tracked here: https://github.com/pywinauto/pywinauto/pull/449
There is no exact deadline for pywinauto 0.7.0 with this feature (it's a hobby project), but I would say this summer sounds realistic.

How to distribute python software to users of low technical ability?

I have a python application (3.5) that I’m trying to distribute. It:
Uses no GUI libraries (it runs in the browser)
Uses several external packages (Flask, SocketIO, httplib2)
maintains saved config and data files inside the main source directory
The target users:
Use Mac or Windows
Do not understand the concept of the terminal/command line (testing has shown that it can take hours to teach users how to cd into the source directory to run a .py file).
Generally have little difficulty installing the python interpreter from python.org (but have great trouble starting and exiting the python console).
Are generally of very low technical ability.
Preferably, the app should:
be “click and play”, as I have found that typically the cd navigation is the biggest hurdle preventing users from running my application.
not require manually modifying any system settings
I am developing from Ubuntu Linux. I have access to a Windows VM, but not a Mac computer. How do I distribute my application?
There are a couple of applications that can help you to distribute a Python Application, for this case you want to take a look on Python freezing tools like py2exe (windows only) or py2app (MacOs).
This two will help you distribute your code without all the hassle of making the user to install the dependencies and run anything from the command line.
However if your application runs on the browser, you probably want to just put that into a server (take a look of openshift, it's free) it will make your life a lot easier.

How to create OS X app with Python on Windows

I need to automate a cross-platform application build. Entire build runs on Windows machine. Part of it is written in Python and compiles for OS X. Currently this part of build is done manually on OS X.
I tried pyinstaller but it looks like it only building for the platform that it is running on. I also tried py2app but it did not install on Windows.
Are there any tools to compile Python script to OS X app on Windows machine?
Short answer:
Apparently, no simple way to do this with the standard set of tools you have mentioned. I outline a completely unprobable solution in the end that's probably too complex to consider.
End result: Keep doing it manually, it's probably the best option so far.
Drawing from credible and/or official sources:
There's already a long and curated list of options specified in micheal0x2a's excelent answer in Create a single executable from a Python project which outlines most tools available for creating standalone distributions of a Python program. One line stands out:
Also, unless otherwise noted, all programs listed below will produce an exe specifically for the operating system it's running in.
I might have read things wrong but there's no explicit note of cross platform support.
Similar lists can be found in in Distribution Utilities and Freezing Your Code — The Hitchhiker's Guide to Python. From these we can take a look at the Windows supported projects:
bbfreeze: Not maintained, no documentation on limitations generally superceded by the rest in this list.
PyInstaller: According to their documentation:
PyInstaller is tested against Windows, Mac OS X, and Linux. However, it is not a cross-compiler: to make a Windows app you run PyInstaller in Windows; to make a Linux app you run it in Linux, etc. PyInstaller has been used successfully with AIX, Solaris, and FreeBSD, but is not tested against them.
PyInstaller once tried to support cross-compilation (From Linux -> Windows) but later dropped the idea.
cx_freeze: Looking at their Freezing for other platforms question in their Frequently Asked Questions list:
cx_Freeze works on Windows, Mac and Linux, but on each platform it only makes an executable that runs on that platform. So if you want to freeze your program for Windows, freeze it on Windows; if you want to run it on Macs, freeze it on a Mac.
py2app: This is not an option since py2app is supported only OSX machines based on their note:
NOTE: py2app must be used on OSX to build applications, it cannot create Mac applications on other platforms.
So installing it on windows is a no-go.
This wraps out the tools available on for creating standalone applications on Windows. Even if not on Windows though, solutions don't exist for creating an OS agnostic tool.
The general consensus for achieving these sort of things is via Virtual Machines; you create a VM image of the target OS, run the dedicated tool for that OS inside the vm and then tranfer the bundled executable to compatible machines. Since OSX is generally not easy to virtualize, from what I know, you kinda run out of luck here.
One complex probable way:
Now, the reason why I said there is no simple way to do this is because there might be one but, from what I can see, it is so tedious you shouldn't even consider it. The general issue we're facing here is that executables for windows are simply not compatible with OSX, heck, Linux executables aren't either. So what we need is the ability to cross-compile things.
One compiler that I've heard supports cross-compilation is clang. So, in order remedy the incompatibility of executables, you could theoretically use clang as a cross compiler. Problem is, this is not a simple task; it is probably way harder than what you're willing to do since it is riddled with complex issues (From OSX to Windows example).
If you do actually find a way to that you now need a .cpp/.c file from your python scripts. Thankfully this is something that can be done by using tools like Nuitka or Cython.
The gist of these is the same, enter .py exit .cpp/.c. The second tricky part might be setting up the clang compiler to be used with these. I honestly have no idea if anyone has done this.
I haven't looked into them much, but for Nuitka, I know that it can also be used to create a standalone executable when passed the --standalone flag (See: Moving to other machines). So, theoretically you could use Nuitka with clang configured to cross-compile for OSX. Then you can rest; you've earned it.
You can use a docker image https://github.com/sickcodes/Docker-OSX like this to simulate a mac computer.
Then from this simulated mac you could install the pyinstaller and run your command from there.
This would then produce the desired file.
Some people do the same way to create windows executables using pyinstaller on linux.
I dont see why this could not work from windows to mac.
Install fabric (Python module, easily installed with pip) on your Windows machine so that you can run the build on your Mac as part of the same automated build process.
Fabric allows you to utilize SSH from Python. So long as you know how to access the Mac over SSH (just need the IP, username, and password), this is easy. Set it up like this:
from fabric.api import env
env.host_string = '<IP of the Mac Here>'
env.user = '<Username on the Mac>'
env.password = '<Password of the user>'
Then copy over the necessary source files from the Windows machine to the Mac like this (once fabric has been set up as above):
from fabric.operations import put
put(r'\path\to\local\source\files', '/path/to/where/you/want/them')
Now you want to run your build tool, whatever it is. You'll need to use run or sudo for that, depending on if the tool requires admin privileges or not.
from fabric.operations import run, sudo
# sudo works the same as run if you need that instead
run('/path/to/build/tool arguments for build tool')
Finally you have the build output which you can retrieve using get.
from fabric.operations import get
get('/path/to/dist/on/mac', '\local\path\to\store\on\windows')
There we go. Pretty simple. No VM needed - just automate the process that you were already manually doing before. The only real requirement is that your Mac has to be available to be connected to during the build process. If you don't have a readily available Mac server, consider just picking up a used Mac Mini - you can get them for as little as $50 on ebay, if budget is a concern.

Cygwin and Python 2.6

New to python (and programming). What exactly do I need from Cygwin? I'm running python 2.6 on winxp. Can I safely download the complete Cygwin? It just seems like a huge bundle of stuff.
Well, I keep running into modules and functionality (i.e. piping output) which suggest downloading various cygwin components. Will cygwin change or modify any other os functionality or have any other side effects?
There are builds of python which don't require cygwin. For instance (from python.org):
link text
Also, there is the .NET version called Iron Python:
link text
cygwin is effectively a Unix subkernel. Setup and installed in its default manner it won't interrupt or change any existing Windows XP functionality. However, you'll have to start the cygwin equivalent of the command prompt before you can use its functionality.
With that said, some of the functionality you're talking about is available in Windows. Piping definitely is. For instance:
netstat -ano | findstr :1433
is a command line I use to make sure my SQL Server is listening on the default port. The output of netstat is being piped to findstr so I only have to see any lines containing :1433.
I would say the simplest option is to try a Linux Distro. I know if your new Linux can be intimidating, but when I looked at Ubuntu and started developing there my life was changed. Ubuntu is bloated (for linux) however, it comes with the things that I would expect a Microsoft based OS to come pre-packaged with. The limitless amount of free software written by creative minds for creative minds is a wonder. The open-source community is great to get involved in for learning and experience. I can vouch that programming on Linux in any language (except myabe . . . .NET ?) will be a much pleasurable experience from the go. One is windows paths, sure you can still create portable Python applications that will port to windows, it just requires another couple lines of replacing characters and escaping them. If they are personal apps this can be bothersome if you do not plan to distribute them.
I found Ubuntu to be a nice balance suited towards both general usability, and development.
Stock Distro:
Python 2.7
Perl
XTerm
MP3 Player that kills WMP and Winamp =+ V.3.0
E-Mail w/ Thunderbird ( much like outlook express by the makers of Fire Fox browser with add-on and extensions)
Empathy (Internet Chat Client for AIM, ICQ, FACEBOOK, MySpace, etc . . it also keeps all your contacts on one list and operates just like AIM for all accounts)
Gwibber (social networking app that compiles the posts made on your twitter and your Facebook wall into a nice desktop widget that also allows you to reply and comment right from the app.)
Multiple Desktop Support: You can change your "desktop view" by pressing a hot key. Each desktop only has the windows you want on it. So you can create a work space, a chat space, a web browsing space and alternate between them quickly. You can also move windows around between work spaces quickly as needed.
Global Hot-Key Mapper: In your administration options you have an OS wide hot-key map. You can launch programs, and many other tasks simply by assigning a hot-key through the default interface.
Bash, Terminal, Shell, XTerm: These CLI (command line interfaces) offer much more functionality as you found than can be generally found in windows. Yes you can pipe output in windows but that's not what this is about. These CLIs allow you to create scripts that can take user input and perform complex tasks that usually would have to be done manually. The BASH is somewhat a programming language of itself; allowing for the assignment of functions, variables, if statements, etc.
I was very surprised that not only was Ubuntu well and ready to handle the developer but it was also plenty user friendly for your grand-parents. It comes with everything you need out of the box (for an average user not a developer) and the developer only requires a few installs. You're also working in open-source software remember. So you are going to be dealing with bugs and you may be stuck waiting on a ticket to be resolved in Windows for some time. If ever.
Also, Ubuntu is boot-able from CD and you can check out the main interface just by doing so. You can also dual-boot it with a screen asking you which partition/disk to boot after POST boot. There is also a tutorial on running it off a thumb drive.
Linux and the speed of your computer: Linux compared to say Windows 7 is EXTREMELY lightweight. What is considered to be a MID level computer such as an AMD Phenom 955 Black Edition x4 and it will run like a high level computer. 1 gib of memory goes quite a bit further in Linux than it does in windows.
The best way to try a Linux distro is as follows. You do not have to install it on the system. You can sandbox it with a virtual environment if you like it and want the speed and overhead improvements of running it stand-alone maybe consider the dual-boot at first followed by the "change".
Download the Linux Dist ISO of your choosing. For new users again Ubuntu, Mint, something simple. Something debian. Mostly due to the ease of using a good package manager. Download Oracle Virtual Box . Follow the instructions, create a new virtual disk, then start the virtual disk with install media placed in DVD drive or virtual DVD drive and install like a normal OS.
In my experience unless it is essential that you be using windows all the time, there is no reason not to try a Linux Distro. Just be careful because something like ArchLinux or SlackWare may scare you off right away; where as distros like Ubuntu, Mint, and others have built in GUI right off the bat. Linux comes in many varieties. It is more loosely coupled than windows you for example you can use any desktop environment you want. Linux is just a kernal. The distros are collections of tools the group maintaining the distro thinks will fit their over-all goal and purpose. Desktop Environments, programming tools, package managers, and other freely licensed pieces of software.

Categories

Resources