Thread: [Pyobjc-dev] placing a module inside of an xcode project
Brought to you by:
ronaldoussoren
|
From: Matthew A. <man...@gm...> - 2009-02-20 21:07:35
|
Hello all,
I'm working on a PyObjC app in XCode (leopard). I decided to
encapsulate functionality as a python module in my project, like so:
sourcefile.py
someModule/
__init__.py
modfile1.py
modfile2.py
When I tell XCode to build the project, however, all of the files
inside of the "someModule" directory get flattened in the built
applications "Contents/Resources" folder (meaning, "someModule" is
missing entirely and it's contents are placed in "Contents/Resources".
Obviously, calling
import someModule
in say, "sourcefile.py" doesn't work in such a situation.
I don't really understand the build process, or how py2app works
(though I'm assuming that it's doing the heavy lifting?), or how to
specify that I wish this directory structure to remain intact in the
resulting app's resources folder. I'm uncertain of where any
documentation might be to help me understand the underpinnings I need
to make this all behave.
Help, please?
Thanks a lot!
Matt
|
|
From: Petr M. <pet...@an...> - 2009-02-20 23:56:22
|
Hi, I got struck by this a while ago, though I don't have a definite answer (read it as I'm not completely satisfied with the state of things as I have it regarding this issue), I'd leave you a hint: - "Groups" in XCode's "Groups & Files" view are not necessarily folders. Groups are just some logical groupings of files done by XCode. You can however make the Group translate to folder by right clicking on it and in "Get info" you can choose a path. This makes it (the folder) for the source code, not the actual app bundle. - tweak the build process under the appropriate target. In the "Groups & Files" unfold Targets and the target you want, and add there a "Copy files" phase. Again with right click and "Get info", you can set the name of the folder under the "Resources" folder in the actual app bundle. The last step (and the one I'm not satisfied with) is to move the appropriate files from the "Copy Bundle Resources" (they are added there automatically) to your "Copy files" phase, or add them there if they were not added to the former phase. The new XCode templates to my best understanding do not use the "py2app method". You are free to use it on your own though, but thats probably a different topic. Also, you can notice that the XCode template actually compiles only 1 ObjectiveC file by default and everything other is just copying, so theoretically you can make some changes in the python code directly in the Resources folder in the app bundle you once built. I had not such a need so far though. Also don't forget the console for the python output for debugging, "hidden" under menu-run-console. Hope this helps. If someone knows how to make XCode to play nicely with some large folder hierarchies better, please let me know. My primary concern is that I can't specify the "Copy files" phase for some root folder to have all the files copied without having to specify that file-by-file. I'd suspect one can do that using some external script during the build phase. Cheers, Petr Matthew Anderson wrote: > Hello all, > > I'm working on a PyObjC app in XCode (leopard). I decided to > encapsulate functionality as a python module in my project, like so: > > sourcefile.py > someModule/ > __init__.py > modfile1.py > modfile2.py > > When I tell XCode to build the project, however, all of the files > inside of the "someModule" directory get flattened in the built > applications "Contents/Resources" folder (meaning, "someModule" is > missing entirely and it's contents are placed in "Contents/Resources". > > Obviously, calling > > import someModule > > in say, "sourcefile.py" doesn't work in such a situation. > > I don't really understand the build process, or how py2app works > (though I'm assuming that it's doing the heavy lifting?), or how to > specify that I wish this directory structure to remain intact in the > resulting app's resources folder. I'm uncertain of where any > documentation might be to help me understand the underpinnings I need > to make this all behave. > > Help, please? > > Thanks a lot! > Matt > > ------------------------------------------------------------------------------ > Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA > -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise > -Strategies to boost innovation and cut costs with open source participation > -Receive a $600 discount off the registration fee with the source code: SFAD > http://p.sf.net/sfu/XcvMzF8H > _______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev |
|
From: Armando R. <air...@gm...> - 2009-02-21 06:23:24
|
On Fri, Feb 20, 2009 at 4:07 PM, Matthew Anderson wrote: > Hello all, > > I'm working on a PyObjC app in XCode (leopard). I decided to > encapsulate functionality as a python module in my project, like so: > > sourcefile.py > someModule/ > __init__.py > modfile1.py > modfile2.py > > When I tell XCode to build the project, however, all of the files > inside of the "someModule" directory get flattened in the built > applications "Contents/Resources" folder (meaning, "someModule" is > missing entirely and it's contents are placed in "Contents/Resources". Hi, Matthew. Here are the steps I tried that seemingly work: 1 - In Xcode, Right-Click on "Resources" 2 - Select Add-->Existing Files and select the folder containing your package 3 - In the ensuing dialog, place a check in "Copy items into Destination Group's Folder" 4 - While still in the dialog, make sure "Create Folder References for any added folder" is selected. 5 - Click "Add", and your package folder should be created intact within Resources ready to be accessed. Armando. |
|
From: Matthew A. <man...@gm...> - 2009-02-21 16:13:09
|
Thank you! I didn't know there was such a thing as a "folder reference". Once I know that, the solution is easy to understand. I think I need to sit down and read all of the XCode guides, and then figure out what the python project templates do *exactly*. Matt On Sat, Feb 21, 2009 at 12:23 AM, Armando Rivera <air...@gm...> wrote: > Hi, Matthew. > > Here are the steps I tried that seemingly work: > > 1 - In Xcode, Right-Click on "Resources" > 2 - Select Add-->Existing Files and select the folder containing your package > 3 - In the ensuing dialog, place a check in "Copy items into > Destination Group's Folder" > 4 - While still in the dialog, make sure "Create Folder References for > any added folder" is selected. > 5 - Click "Add", and your package folder should be created intact > within Resources ready to be accessed. > > Armando. |
|
From: Matthew A. <man...@gm...> - 2009-02-21 16:24:23
|
Thanks Petr, I think the folder reference trick will work better for my project than setting up a "copy files" phase to create the directory structure. Maybe that's the technique you were looking for too. As I still have yet to dive into how XCode builds the project, and how py2app may or may not be used, I wonder how import dependencies for locally installed modules are dealt with, if at all. Meaning, if I say, install docutils and use the ReST parser in my program, do I have to take extra steps to make sure that docutils is copied into the app to make the program 'stand alone', or is this taken care of automagically. I guess testing such things would answer the question. Matt On Fri, Feb 20, 2009 at 3:38 PM, Petr Mifek <Pet...@an...> wrote: > > > The new XCode templates to my best understanding do not use the "py2app > method". You are free to use it on your own though, but thats probably a > different topic. > |
|
From: Petr M. <pet...@an...> - 2009-02-21 16:54:56
|
Hi Mathew, I knew about the folder references, but that is no good for my use, because a Folder reference is "read only" from within the XCode environment. That is, I can't easily add or delete files it that folder(s) from within the XCode. So I still have to go with setting it up one-by-one. It is not that big issue, though I have a feeling that time will come when it'll be (that time I'll be forced to leave the XCode and handle that myself ;) ). The XCode/Xcode's PyObjc templates won't do this for you. That means, you must locate all your dependencies by yourself and ensure they are located under the Resources folder in you app bundle (that is the "standard" way to handle that, there are others though, like listing prerequisites in a README ;) ). The py2app goes to some great extent to locate dependencies for your code and include them in the final bundle - but that is not used during the standard XCode3.x-templates-based application. Cheers, Petr Matthew Anderson wrote: > Thanks Petr, > > I think the folder reference trick will work better for my project > than setting up a "copy files" phase to create the directory > structure. Maybe that's the technique you were looking for too. > > As I still have yet to dive into how XCode builds the project, and how > py2app may or may not be used, I wonder how import dependencies for > locally installed modules are dealt with, if at all. Meaning, if I > say, install docutils and use the ReST parser in my program, do I have > to take extra steps to make sure that docutils is copied into the app > to make the program 'stand alone', or is this taken care of > automagically. I guess testing such things would answer the question. > > Matt > > On Fri, Feb 20, 2009 at 3:38 PM, Petr Mifek <Pet...@an...> wrote: >> >> The new XCode templates to my best understanding do not use the "py2app >> method". You are free to use it on your own though, but thats probably a >> different topic. >> > > ------------------------------------------------------------------------------ > Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA > -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise > -Strategies to boost innovation and cut costs with open source participation > -Receive a $600 discount off the registration fee with the source code: SFAD > http://p.sf.net/sfu/XcvMzF8H > _______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev |
|
From: Matthew A. <man...@gm...> - 2009-02-21 17:40:01
|
I hadn't yet even noticed how using folder references prevented you from adding and deleting their contents until you said it. XCode drives me insane for actually editing the text of a python program though, so I've been using TextMate as external editor 99% of the time anyway. The biggest (but not only) issue is that I really want to see visible (but close in color to the background, so not to be distracting) glyphs for newline and tab characters when I write python code, and the XCode editor doesn't seem to do that very well. The XCode "read-only" problem isn't one in TextMate. XCode is probably a better editor for Objective-C than it is for Python. Too bad about the lack of dependency magic in the XCode templates, but good to know that's how it is. Thanks! Matt On Sat, Feb 21, 2009 at 10:54 AM, Petr Mifek <pet...@an...> wrote: > Hi Mathew, > > I knew about the folder references, but that is no good for my use, because > a Folder reference is "read only" from within the XCode environment. That > is, I can't easily add or delete files it that folder(s) from within the > XCode. So I still have to go with setting it up one-by-one. It is not that > big issue, though I have a feeling that time will come when it'll be (that > time I'll be forced to leave the XCode and handle that myself ;) ). > > The XCode/Xcode's PyObjc templates won't do this for you. That means, you > must locate all your dependencies by yourself and ensure they are located > under the Resources folder in you app bundle (that is the "standard" way to > handle that, there are others though, like listing prerequisites in a README > ;) ). The py2app goes to some great extent to locate dependencies for your > code and include them in the final bundle - but that is not used during the > standard XCode3.x-templates-based application. > > > Cheers, Petr |