Thread: [Pyobjc-dev] py2app: unable to load nib-file
Brought to you by:
ronaldoussoren
|
From: Johan R. <joh...@gm...> - 2009-04-13 20:24:20
|
I've created a PyObjC project using Xcode, and everything works just
fine when I hit Build and Go.
But it happens that I'm better suited for using emacs and command-line
tools, so I tried to write up
a simple setup.py;
#...
setup(
name="Foo",
app=["main.py"],
data_files=["English.lproj"],
)
Running setup.py py2app -A creates the dist and build directories.
The problem starts when trying
to run the executable:
2009-04-13 22:22:29.513 Foo[46645:10b] Unable to load nib file:
MainMenu, exiting
Has I missed anything in my setup.py file?
|
|
From: Ian B. <ia...@on...> - 2009-04-14 00:57:56
|
Hey Johan,
The problem is likely with your data_files declaration. You can't
just toss data_files a folder and have it intelligently include
everything in it. You have to give it a complete file list of
everything you want included in your project.
Here's the code that I'm using to automatically populate data_files;
it may have issues (probably should be modified to exclude .svn
folders if you're using SVN, for instance), but at least it's an
example of the kind of thing you'll need to do:
import os
# Sets what directory to crawl for files to include
# Relative to location of setup.py; leave off trailing slash
includes_dir = 'src'
# Set the root directory for included files
# Relative to the bundle's Resources folder, so '../../' targets
bundle root
includes_target = '../../'
# Initialize an empty list so we can use list.append()
includes = []
# Walk the includes directory and include all the files
for root, dirs, filenames in os.walk(includes_dir):
if root is includes_dir:
final = includes_target
else:
final = includes_target + root[len(includes_dir)+1:] + '/'
files = []
for file in filenames:
if (file[0] != '.'):
files.append(os.path.join(root, file))
includes.append((final, files))
setup(
name='Foo',
app = ['main.py'],
data_files = includes,
)
Ian
On Apr 13, 2009, at 1:23 PM, Johan Rydberg wrote:
> I've created a PyObjC project using Xcode, and everything works just
> fine when I hit Build and Go.
>
> But it happens that I'm better suited for using emacs and command-line
> tools, so I tried to write up
> a simple setup.py;
>
> #...
> setup(
> name="Foo",
> app=["main.py"],
> data_files=["English.lproj"],
> )
>
> Running setup.py py2app -A creates the dist and build directories.
> The problem starts when trying
> to run the executable:
>
> 2009-04-13 22:22:29.513 Foo[46645:10b] Unable to load nib file:
> MainMenu, exiting
>
> Has I missed anything in my setup.py file?
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by:
> High Quality Requirements in a Collaborative Environment.
> Download a free trial of Rational Requirements Composer Now!
> http://p.sf.net/sfu/www-ibm-com
> _______________________________________________
> Pyobjc-dev mailing list
> Pyo...@li...
> https://lists.sourceforge.net/lists/listinfo/pyobjc-dev
——————————————————
Ian Beck
ia...@on...
Tagamac: simple mac tagging
http://tagamac.com
|
|
From: Johan R. <joh...@gm...> - 2009-04-14 06:55:13
|
Odd, because I've seen people just add English.lproj to data_files. For example, look at /Developer/Examples/Python/PyObjC/Cocoa/AppKit/Todo/setup.py. Thanks for your code example. On Tue, Apr 14, 2009 at 2:57 AM, Ian Beck <ia...@on...> wrote: > Hey Johan, > > The problem is likely with your data_files declaration. You can't > just toss data_files a folder and have it intelligently include > everything in it. You have to give it a complete file list of > everything you want included in your project. > > Here's the code that I'm using to automatically populate data_files; > it may have issues (probably should be modified to exclude .svn > folders if you're using SVN, for instance), but at least it's an > example of the kind of thing you'll need to do: > > import os > > # Sets what directory to crawl for files to include > # Relative to location of setup.py; leave off trailing slash > includes_dir = 'src' > > # Set the root directory for included files > # Relative to the bundle's Resources folder, so '../../' targets > bundle root > includes_target = '../../' > > # Initialize an empty list so we can use list.append() > includes = [] > > # Walk the includes directory and include all the files > for root, dirs, filenames in os.walk(includes_dir): > if root is includes_dir: > final = includes_target > else: > final = includes_target + root[len(includes_dir)+1:] + '/' > files = [] > for file in filenames: > if (file[0] != '.'): > files.append(os.path.join(root, file)) > includes.append((final, files)) > > setup( > name='Foo', > app = ['main.py'], > data_files = includes, > ) > > Ian > > On Apr 13, 2009, at 1:23 PM, Johan Rydberg wrote: > >> I've created a PyObjC project using Xcode, and everything works just >> fine when I hit Build and Go. >> >> But it happens that I'm better suited for using emacs and command-line >> tools, so I tried to write up >> a simple setup.py; >> >> #... >> setup( >> name="Foo", >> app=["main.py"], >> data_files=["English.lproj"], >> ) >> >> Running setup.py py2app -A creates the dist and build directories. >> The problem starts when trying >> to run the executable: >> >> 2009-04-13 22:22:29.513 Foo[46645:10b] Unable to load nib file: >> MainMenu, exiting >> >> Has I missed anything in my setup.py file? >> >> ------------------------------------------------------------------------------ >> This SF.net email is sponsored by: >> High Quality Requirements in a Collaborative Environment. >> Download a free trial of Rational Requirements Composer Now! >> http://p.sf.net/sfu/www-ibm-com >> _______________________________________________ >> Pyobjc-dev mailing list >> Pyo...@li... >> https://lists.sourceforge.net/lists/listinfo/pyobjc-dev > > —————————————————— > Ian Beck > ia...@on... > > Tagamac: simple mac tagging > http://tagamac.com > > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by: > High Quality Requirements in a Collaborative Environment. > Download a free trial of Rational Requirements Composer Now! > http://p.sf.net/sfu/www-ibm-com > _______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev > |
|
From: Ronald O. <ron...@ma...> - 2009-04-14 07:40:27
Attachments:
smime.p7s
|
On 14 Apr, 2009, at 8:54, Johan Rydberg wrote: > Odd, because I've seen people just add English.lproj to data_files. > For example, look at > /Developer/Examples/Python/PyObjC/Cocoa/AppKit/Todo/setup.py. Adding English.lproj to data_files should just work, if it doesn't you have found a bug in py2app. Ronald |
|
From: Johan R. <joh...@gm...> - 2009-04-14 07:46:32
|
Looking in the dist/Foo.app/Resources, English.lproj is there and it contains the MainMenu.xib file. How does the code know to look into the English.lproj directory? When I get back from work I'll try to assemble a small tarball with a non-working example. On Tue, Apr 14, 2009 at 9:40 AM, Ronald Oussoren <ron...@ma...> wrote: > > On 14 Apr, 2009, at 8:54, Johan Rydberg wrote: > >> Odd, because I've seen people just add English.lproj to data_files. >> For example, look at >> /Developer/Examples/Python/PyObjC/Cocoa/AppKit/Todo/setup.py. > > Adding English.lproj to data_files should just work, if it doesn't you have > found a bug in py2app. > > Ronald > > |
|
From: Johan R. <joh...@gm...> - 2009-04-14 16:58:00
|
BTW, how do Cocoa know to seach inside English.lproj? Is there defined search order for resources? On Tue, Apr 14, 2009 at 9:40 AM, Ronald Oussoren <ron...@ma...> wrote: > > On 14 Apr, 2009, at 8:54, Johan Rydberg wrote: > >> Odd, because I've seen people just add English.lproj to data_files. >> For example, look at >> /Developer/Examples/Python/PyObjC/Cocoa/AppKit/Todo/setup.py. > > Adding English.lproj to data_files should just work, if it doesn't you have > found a bug in py2app. > > Ronald > > |
|
From: Ronald O. <ron...@ma...> - 2009-04-14 07:51:20
Attachments:
smime.p7s
|
On 14 Apr, 2009, at 9:46, Johan Rydberg wrote: > Looking in the dist/Foo.app/Resources, English.lproj is there and it > contains the MainMenu.xib file. > How does the code know to look into the English.lproj directory? > > When I get back from work I'll try to assemble a small tarball with a > non-working example. Could you try if converting the ".xib" file to a ".nib" file works (IIRC you can use Save As... in Interface Builder for that, otherwise it is a property in the NIB settings)? The ".xib" files cannot be loaded directly by Cocoa but need to be compiled before they can be used. Xcode automaticly does this for you, released versions of py2app do no yet do that. The version of py2app in subversion fixes this issue for regular builds, but not for alias builds (the -A flag). Ronald > > On Tue, Apr 14, 2009 at 9:40 AM, Ronald Oussoren <ron...@ma... > > wrote: >> >> On 14 Apr, 2009, at 8:54, Johan Rydberg wrote: >> >>> Odd, because I've seen people just add English.lproj to data_files. >>> For example, look at >>> /Developer/Examples/Python/PyObjC/Cocoa/AppKit/Todo/setup.py. >> >> Adding English.lproj to data_files should just work, if it doesn't >> you have >> found a bug in py2app. >> >> Ronald >> >> |
|
From: Johan R. <joh...@gm...> - 2009-04-14 08:28:48
|
I'll try that. Thanks for the suggestion. Can I modify my setup.py to automaticly convert my xib's to nibs, using ibtool? I suppose I need to hook up in the build phase. I have a feeling that XIB's work better with my version control software (bazaar). On Tue, Apr 14, 2009 at 9:51 AM, Ronald Oussoren <ron...@ma...> wrote: > > On 14 Apr, 2009, at 9:46, Johan Rydberg wrote: > >> Looking in the dist/Foo.app/Resources, English.lproj is there and it >> contains the MainMenu.xib file. >> How does the code know to look into the English.lproj directory? >> >> When I get back from work I'll try to assemble a small tarball with a >> non-working example. > > Could you try if converting the ".xib" file to a ".nib" file works (IIRC you > can use Save As... in Interface Builder for that, otherwise it is a property > in the NIB settings)? > > The ".xib" files cannot be loaded directly by Cocoa but need to be compiled > before they can be used. Xcode automaticly does this for you, released > versions of py2app do no yet do that. The version of py2app in subversion > fixes this issue for regular builds, but not for alias builds (the -A flag). > > Ronald > >> >> On Tue, Apr 14, 2009 at 9:40 AM, Ronald Oussoren <ron...@ma...> >> wrote: >>> >>> On 14 Apr, 2009, at 8:54, Johan Rydberg wrote: >>> >>>> Odd, because I've seen people just add English.lproj to data_files. >>>> For example, look at >>>> /Developer/Examples/Python/PyObjC/Cocoa/AppKit/Todo/setup.py. >>> >>> Adding English.lproj to data_files should just work, if it doesn't you >>> have >>> found a bug in py2app. >>> >>> Ronald >>> >>> > > |
|
From: Ronald O. <ron...@ma...> - 2009-04-14 08:37:56
Attachments:
smime.p7s
|
On 14 Apr, 2009, at 10:28, Johan Rydberg wrote: > I'll try that. Thanks for the suggestion. > > Can I modify my setup.py to automaticly convert my xib's to nibs, > using ibtool? > I suppose I need to hook up in the build phase. There is a hook in the build phase, but that hook is not yet used in alias mode. If you don't mind waiting a little longer during builds you can use "python setup.py py2app" instead of "python setup.py py2app -A" and then the XIB file should automaticly be converted once you install the version of py2app that's in the subversion repository at http://svn.pythonmac.org/py2app/py2app/trunk. I want to finish some work I've done at Pycon sometime soon, which is rather invasive and would require changes for alias mode as well. I'll fix the file conversion hooks during that merge as well. I am afraid that the work I need to finish is one of those "80% done in 20% of the time"-jobs, which means I don't have a estimate on when this will be finished. You could always add a bit of Python code to your setup.py file that calls ibtool to convert the xib files and include the converted files as your resource_data. That's not as clean as proper support in py2app, but would keep you going for now. > > I have a feeling that XIB's work better with my version control > software (bazaar). IIRC bazaar has one metadata directory at the toplevel of a project, rather than a metadata directory in every directory in your project (which subversion uses), which means both XIB's and NIB's should work just fine with bazaar. Ronald > > > > On Tue, Apr 14, 2009 at 9:51 AM, Ronald Oussoren <ron...@ma... > > wrote: >> >> On 14 Apr, 2009, at 9:46, Johan Rydberg wrote: >> >>> Looking in the dist/Foo.app/Resources, English.lproj is there and it >>> contains the MainMenu.xib file. >>> How does the code know to look into the English.lproj directory? >>> >>> When I get back from work I'll try to assemble a small tarball >>> with a >>> non-working example. >> >> Could you try if converting the ".xib" file to a ".nib" file works >> (IIRC you >> can use Save As... in Interface Builder for that, otherwise it is a >> property >> in the NIB settings)? >> >> The ".xib" files cannot be loaded directly by Cocoa but need to be >> compiled >> before they can be used. Xcode automaticly does this for you, >> released >> versions of py2app do no yet do that. The version of py2app in >> subversion >> fixes this issue for regular builds, but not for alias builds (the - >> A flag). >> >> Ronald >> >>> >>> On Tue, Apr 14, 2009 at 9:40 AM, Ronald Oussoren <ron...@ma... >>> > >>> wrote: >>>> >>>> On 14 Apr, 2009, at 8:54, Johan Rydberg wrote: >>>> >>>>> Odd, because I've seen people just add English.lproj to >>>>> data_files. >>>>> For example, look at >>>>> /Developer/Examples/Python/PyObjC/Cocoa/AppKit/Todo/setup.py. >>>> >>>> Adding English.lproj to data_files should just work, if it >>>> doesn't you >>>> have >>>> found a bug in py2app. >>>> >>>> Ronald >>>> >>>> >> >> |
|
From: Ronald O. <ron...@ma...> - 2009-04-14 18:14:31
Attachments:
smime.p7s
|
On 14 Apr, 2009, at 18:57, Johan Rydberg wrote: > BTW, how do Cocoa know to seach inside English.lproj? Is there > defined search order for > resources? The order is determined by the Language settings in the "International" preference pane. When none of the languages matches a .lproj folder in your .app folder the systems searches directly in the Resources folder. The actual mechanism is described in Apple's documentation somewhere (I don't have a handy reference). Ronald > > On Tue, Apr 14, 2009 at 9:40 AM, Ronald Oussoren <ron...@ma... > > wrote: >> >> On 14 Apr, 2009, at 8:54, Johan Rydberg wrote: >> >>> Odd, because I've seen people just add English.lproj to data_files. >>> For example, look at >>> /Developer/Examples/Python/PyObjC/Cocoa/AppKit/Todo/setup.py. >> >> Adding English.lproj to data_files should just work, if it doesn't >> you have >> found a bug in py2app. >> >> Ronald >> >> |
|
From: Nigel K. <ni...@ex...> - 2009-04-14 23:07:53
|
On Tue, Apr 14, 2009 at 11:13 AM, Ronald Oussoren <ron...@ma...> wrote: > > On 14 Apr, 2009, at 18:57, Johan Rydberg wrote: > >> BTW, how do Cocoa know to seach inside English.lproj? Is there >> defined search order for >> resources? > > The order is determined by the Language settings in the "International" > preference pane. When none of the languages matches a .lproj folder in your > .app folder the systems searches directly in the Resources folder. The > actual mechanism is described in Apple's documentation somewhere (I don't > have a handy reference). http://developer.apple.com/documentation/CoreFOundation/Conceptual/CFBundles/Concepts/SearchAlgorithm.html#//apple_ref/doc/uid/20001120 gives an overview and some relevant links. > > Ronald > >> >> On Tue, Apr 14, 2009 at 9:40 AM, Ronald Oussoren <ron...@ma...> >> wrote: >>> >>> On 14 Apr, 2009, at 8:54, Johan Rydberg wrote: >>> >>>> Odd, because I've seen people just add English.lproj to data_files. >>>> For example, look at >>>> /Developer/Examples/Python/PyObjC/Cocoa/AppKit/Todo/setup.py. >>> >>> Adding English.lproj to data_files should just work, if it doesn't you >>> have >>> found a bug in py2app. >>> >>> Ronald >>> >>> > > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by: > High Quality Requirements in a Collaborative Environment. > Download a free trial of Rational Requirements Composer Now! > http://p.sf.net/sfu/www-ibm-com > _______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev > > |