New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conflict between module and app name (macos) #7314
Comments
macOS is not case-sensitive by default, so you cannot have a Also, having As far as I'm concerned, this issue is purely self-inflicted; if you want to use PyInstaller, rename one or the other...
True, but our .app bundle code actually uses the standard POSIX application codepath as a middle step (the intermediate That said, you can probably "rename" your application via app bundle's |
Yep, as noted, I get this :)
Well, I lied a little in the washing of the example. Ours is actually not
I guess I'm surprised I'm the first person to have a module name that is the same as the app name. So I guess it is self-inflicted but, it seems like a reasonable thing to me :)
I tried this and got almost all the way to success. The app menu gets the proper name, but the menu items still say "Quit mangledname" instead of "Quit name". Is there something else in |
I suppose it becomes a problem only on macOS, because on Windows, the executable has .exe suffix so there's no name overlap, and on linux, you could cheat by capitalizing the executable's name, like you attempted to.
What UI framework are you using? |
Yep, exactly. I'm all for cheating :)
wxPython I surely appreciate the help, and other than this I love pyinstaller. |
Hmm, for a Qt/PySide2-based application, the following seems to suffice:
program_qt.spec
program_qt.py
from PySide2 import QtCore, QtWidgets
import sys
import signal
app = QtWidgets.QApplication(sys.argv)
app.setApplicationName("Test App")
signal.signal(signal.SIGINT, signal.SIG_DFL)
window = QtWidgets.QWidget()
window.setWindowTitle("Hello world!")
window.show()
app.exec_() This gives me I'll check if wxPython is any different... |
Looks like with program_wx.spec
program_wx.py
import wx
app = wx.App()
app.SetAppName('My App')
frame = wx.Frame(None, title='Hello World!')
frame.Show()
menubar = wx.MenuBar()
wx.MenuBar.MacSetCommonMenuBar(menubar)
app.MainLoop() |
Oooh. I think I'm not currently signing the app (nor do I really plan to) but is changing the I wonder if it would be worth a macos-specific flag to pyinstaller to set the Anyway, thanks so much, I think I can piece together a working solution from this! |
If you are not explicitly providing codesign identity, PyInstaller signs (or at least, attempts to sign) the bundle with ad-hoc identity. So if you modify Info.plist post-hoc, you will invalidate that signature (which might or might not be a problem). But you could manually re-sign the bundle using ad-hoc identity again: But if you override the values in the spec file, like in the examples I gave above (they are collapsed by default due to use of If the question was about the values themselves - I don't know; PyInstaller by default writes executable name in there, but it seems the fields are intended for actual display/application name.
You mean in the CLI? I think not; these are advanced options, and if you need to override them, you should be using .spec file with
The contents of Info.plist and its meaning are not specific to PyInstaller, so I think it falls outside the scope of our documentation. Plus, the display name is also tied to the UI framework that's used by the application. |
Ah, I missed that they were in the spec you provided, that's perfect, thanks.
Yeah, cool that they're set-able in the spec. By docs I just meant to help ward off this question in the future ("What if I get this error because my app and module name are the same, need to change the executable and then override the plist values"). Again, I'm shocked I'm the first to hit this (or the first to report) but maybe a blog post about the solution here would be good enough. Anyway, thanks! |
I guess one way I've dodged this problem without realising is that my package is typically named something sluggified like |
Not sure if I've understood the issue correctly, but this has worked for me for avoiding the name clash:
|
Yep, this works and is what I'm doing now. It wasn't obvious (to me) that I could do that, which is why it seems like it's worth mentioning as a recipe somewhere. But I'm happy at least :) |
We could probably augment the offending error message. pyinstaller/PyInstaller/building/api.py Lines 971 to 975 in d92bf8d
Trying to put stuff this specific into documentation raises the question of where can we put it that's easy to find when you need it and not a distraction if you don't. |
Yeah, understand the concern about where to put it in the docs. FWIW, the error message was pretty clear to me in terms of what was going on and why. And on windows, it's not a problem because the executable has an extension. I'm just surprised I'm the first person to report a conflict with the app and python module being the same - I would expect that to be quite common. So, it would be unfortunate if people are hitting that without a google-able solution. But, maybe people will find this issue, so perhaps that's good enough :) |
Fixed by #7713 |
Description of the issue
Our project is trying to move our data files into our module and pyinstaller fails to do handle this on macos because our
--name
is the same as our one and only module. When I run pyinstaller, I pass--name Foo --add-data=foo/datadir:foo
and pyinstaller fails because it has already createdFoo
in the dist bundle:(If MacOS wasn't case-sensitive, this likely would work because of the capitalization of the app name, but alas)
I've also tried
--add-data=foo:foo
to add the whole module, but the same problem exists, although the error is slightly different (see below in the stacktrace section).We are trying to "be good" and use importlib-resources in our app to find the data files by module:
I can get data files into the bundle just fine by doing:
...but importlib won't find them there because of the
foo.
module scoping.It seems to me (not knowing much about MacOS app requirements) that these files should be able to go into
Resources
andimportlib
should be taught to find them there so that we don't have this conflict. If I mangle the--name
I pass to pyinstaller, then it works because there is no conflict, but then my app's "name" in the title bar, app menu, etc is wrong, which is very unfortunate.If there's something else I can do to work around this that doesn't involve mangling the app name or restructuring out project substantially that would be great. At this point, it seems like I will have to do "importlib.resources or find relative to _ _ file _ _" in our code.
Context information (for bug reports)
pyinstaller --version
:5.7.0
(also tried fromdevelop.zip
per template)3.10.8
(but also repro'd on3.8
Make sure everything is packaged correctly
--noupx
or setupx=False
in your .spec-file--debug
topyi-makespec
orpyinstaller
or useEXE(..., debug=1, ...)
in your .spec file.A minimal example program which shows the error
It would need to be a multi-file tree to reproduce this. I could do it, if necessary but I think it's probably clear. Our directory structure looks like this:
And I'm calling pyinstaller like:
Stacktrace / full error message
If I do
--add-data=foo/datadir:foo
I get this:If I do
--add-data=foo:foo
I get this:The text was updated successfully, but these errors were encountered: