3

I'm using PyInstaller (v2.1) to bundle a Python app for different platforms. I'm using an external tool for my GUI which invokes the PyInstaller bundled executable that will act as a backend server.

I'm having problems with bundling on the Mac(OS X 10.10) though. When my PyInstaller bundled Unix executable (which is meant to run as a background process) is invoked from the GUI tool, it successfully starts up w/o a window, but unfortunately, along with a terminal icon in the dock.

I've supplied the --no-console option, with debug=False while building the executable, but to no effect. This seemed to work perfectly on Windows.

Should I be looking at some PyInstaller option to prevent the executable icon from popping up on the Dock? Or should I be looking at some OS X options for the same?

To summarise: I wish to prevent the background process from appearing on the dock(on OS X) when invoked from an external application.

An alternate question could also be: What are the Pyinstaller directives to create a purely background application?

Note: I've also tried bundling my python app as a .app, and tried meddling around with the *.plist file, but that didn't help either(apart from the fact that it doesn't seem right because it's meant to run only as a background process)

Here's how the plist file would look:

...
<plist version="1.0">
<dict>
    ...
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>LSBackgroundOnly</key>
    <string>1</string>
    <key>LSUIElement</key>
    <true/>
</dict>
</plist>
farthVader
  • 888
  • 11
  • 19

2 Answers2

1

*I've also tried bundling my python app as a .app, and tried meddling around with the .plist file

It would help if you state what you actually did here. Usually the key LSUIElement when set to true should do what you want. As the docs state: -

Specifies whether the app is an agent app, that is, an app that should not appear in the Dock or Force Quit window. See LSUIElement for details.

TheDarkKnight
  • 27,181
  • 6
  • 55
  • 85
  • I've updated my question. Using those settings didn't seem to have any effect. I'm using Yosemite, so is it possible that these settings may be different? I'd also like to emphasise on the fact that the end-user will never be clicking on the python app. It is meant to be invoked by another application that the end-user will be interacting with. – farthVader Feb 24 '15 at 15:41
  • Try using a string as the value, as mentioned here: http://stackoverflow.com/questions/2762456/lsuielement-not-working – TheDarkKnight Feb 24 '15 at 15:49
  • Not working. Icon still pops up. :( This is the setting right now... `CFBundlePackageType APPL LSBackgroundOnly 1 LSUIElement 1 ` – farthVader Feb 24 '15 at 15:57
  • Note that no window pops up because of the --no-console/--no-window directive. But the dock icon does. Is pyinstaller overriding this setting somehow? – farthVader Feb 24 '15 at 16:04
  • It sounds like a pyinstaller issue as the LSUIElement should work and I also use it with Yosemite. – TheDarkKnight Feb 24 '15 at 16:05
  • This also states that the flag is all you need: https://uselessthingies.wordpress.com/2008/05/18/an-app-without-dock-icon-and-menu-bar/ I wonder if OS X has cached the use of it. Perhaps logging off and on again may show a different result. – TheDarkKnight Feb 24 '15 at 16:07
  • You are right about caching though. I read somewhere that touching the .app flushes the cache, which is what I always do after editing the plist. PyInstaller has a bootloader that runs with the same proc name as our original app. The fact that the plist file already had LSBackgroundOnly set to True may indicate that this plist is meant for the bootloader process which is by default, hidden. – farthVader Feb 24 '15 at 16:14
  • I just confirmed on the above. I removed the LSBackgroundOnly key-value pair; touched the app; and ran it. This time an additional Icon popped up on the dock. I'd like to know if you actually created an agent app using PyInstaller, or if you were providing the inputs based on how a plist is normally meant to behave. – farthVader Feb 24 '15 at 16:18
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/71604/discussion-between-thedarkknight-and-farthvader). – TheDarkKnight Feb 24 '15 at 16:30
0

Tristan79's fork of PyInstaller, which includes recompiled bootloaders and a patch, solved the issue for me.

Justin Shenk
  • 538
  • 1
  • 4
  • 17