[ python-Feature Requests-900514 ] bundlebuilder: easily keep main routine in orig location

SourceForge.net noreply at sourceforge.net
Thu Feb 26 13:03:26 EST 2004


Feature Requests item #900514, was opened at 2004-02-19 10:44
Message generated for change (Comment added) made by reowen
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=900514&group_id=5470

Category: Macintosh
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Russell Owen (reowen)
Assigned to: Nobody/Anonymous (nobody)
Summary: bundlebuilder: easily keep main routine in orig location

Initial Comment:
I'd like to ask that bundlebuilder.py keep the main routine in 
its original location with respect to whatever package it 
appears in, i.e. if the app's main is
MyPgk/Main.py

then the code is put in MyPkg:
Contents/Resources/Modules.zip
      /MyPkg/Main.py

or if no zipping is done:
Contents/Resources/MyPkg/Main.py

I fear this may be too difficult to be worth the work, but I 
wasn't sure and felt it better to ask.

The issue is (as in my 2 previous bundlebuilder requests) 
making it easier to write cross-platform code. If one carefully 
develops code for Mac then one can easily organize it such 
that it fits perfectly within bundlebuilder's assumptions.

But in my case I wrote code to run under unix first, then 
tried to get a working double-clickable Mac app, and it was a 
a surprising amount of work. Among other things, I had to 
rewrite my Main.py so it could be moved relative to its 
package (not a really big deal, but surprising). The other 
requests would simplify or eliminate cleanup work I do after 
the bundle is built.

----------------------------------------------------------------------

>Comment By: Russell Owen (reowen)
Date: 2004-02-26 10:03

Message:
Logged In: YES 
user_id=431773

I think this discussion is getting off track.

It is certainly reasonable (or at least I hope it is) to write
TUI/
  Main.py
and expect unix users to execute Main.py, for example:
alias tui <tui_root>/TUI/Main.py

The problem comes when bundlebuilder helpfully pulls Main.py out of TUI and puts up up at the main level. It seems an odd arrangement of files to me -- I'd much rather stuff all my app's files into a directory and make that a package (to reduce the danger of namespace collisions).

I really don't see the importing issue coming up here. I was hoping bundlebuilder would simply execute the file TUI/Main.py without moving it. It doesn't need to import anything, it just needs to execute the file.

Anyway, I do agree it's not that hard to work around. It just seems a shame that bundlebuilder moves files around without being asked. Once one realizes what is going on, one can figure out workarounds -- such as making the main file movable or writing a stupid 2-line extra script to call the main file.

----------------------------------------------------------------------

Comment By: Bob Ippolito (etrepum)
Date: 2004-02-26 09:43

Message:
Logged In: YES 
user_id=139309

I don't agree with either of your advantages.
- bundlebuilder could compile the "main code" as-is, it just doesn't
- never has to be moved, in exchange for importing foo.bar as 
__main__?  No thanks.

"executable" is for something else.  "mainprogram" is exactly what it 
says it is, it's a program, not a module-inside-a-package-that-should-be-
imported-as-__main__.  Perhaps there could be a 
"writemeamainprogram" argument where you would specify something 
like "foo.bar:main" where foo.bar is the module and main is the 
function.. but then how would you decide which idiom it should be called 
with (sys.argv[1:], sys.argv, no arguments, etc.).

It's not hard to make a two-line program that does what you need it to 
and use that as the mainprogram.. I think this use case is just too 
specific to the style of your single application.  I *always* see the 
separate-main-program idiom used that imports something and calls 
some function, I have *never* seen people symlink something in /usr/
local/bin to something in site-packages.

----------------------------------------------------------------------

Comment By: Russell Owen (reowen)
Date: 2004-02-26 09:33

Message:
Logged In: YES 
user_id=431773

I'm afraid I don't follow your reply. My point was that bundlebuilder could always write some kind of executable whose job was to import and execute the user's main .py script.

This has several advantages:
- The user's main code gets compiled; presumably this makes it run faster
- The user's main code never has to be moved

I suspect the bundlebuilder option "executable" may even have been designed for this task, but I've not yet figured out how to use it; I did try it a bit, but bb still required a "mainprogram" so I realized I hadn't a clue what I was doing and gave up on it.

----------------------------------------------------------------------

Comment By: Bob Ippolito (etrepum)
Date: 2004-02-25 18:39

Message:
Logged In: YES 
user_id=139309

This doesn't *really* make sense.. is it too hard to have a bootstrap 
script that imports and executes this?  Isn't that what you would have on 
other platforms?

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=900514&group_id=5470



More information about the Python-bugs-list mailing list