This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: bundlebuilder: some way to add non-py files in packages
Type: enhancement Stage: test needed
Components: macOS Versions:
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: bob.ippolito, reowen, ronaldoussoren
Priority: normal Keywords:

Created on 2004-02-19 18:30 by reowen, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (6)
msg61155 - (view) Author: Russell Owen (reowen) Date: 2004-02-19 18:30
I would like some way to load non-python code that is 
contained in packages. In other words, suppose I have:
maindir/
  helpdir/
    __init__.py
    index.html
    ...other python code and help files

I'd like some way to specify that the code in helpdir be 
loaded as code (compiled and the source discarded) but that 
the other files also be copied over. Presently includePackages 
only copies over python files.

The best workaround I've found so far is to specify the 
package in two separate arguments to buildapp: 
includePackages and resources. That copies everything 
(including the python source) and also compiles everything, 
so one ends up with both .py and .pyc files. I then look in 
that folder and discard the python source after 
bundlebuilder is finished. (I suppose that step is optional.)

Simply modifying includePackages so it included non-python 
files is my first thought. It might occasionally include stuff 
that wasn't wanted, but aside from on occasional README 
or something, I doubt it would amount to anything 
significant in most cases.
msg61156 - (view) Author: Bob Ippolito (bob.ippolito) * (Python committer) Date: 2004-02-26 02:37
Logged In: YES 
user_id=139309

why not keep your code and data in separate folders?
msg61157 - (view) Author: Russell Owen (reowen) Date: 2004-02-26 17:28
Logged In: YES 
user_id=431773

Because putting resource files in sub-packages makes them very easy to find. For example:
TUI/
  __init__.py
  Help/
    __init__.py
    index.html, etc.

(TUI is on the python path)
import os, TUI.Help
helpdir = os.path.dirname(TUI.Help.__file__)

This is all the more useful when one's main .py file gets moved by bundlebuilder from within (in my case) TUI up one level.

Also, many folks may be trying to convert existing code (I was) that uses this trick. It seems a shame to have to rewrite it. Of course one need not actually rewrite it, but a bundlebuilder script becomes quite messy for such code without this requested feature.
msg61158 - (view) Author: Bob Ippolito (bob.ippolito) * (Python committer) Date: 2004-02-26 17:36
Logged In: YES 
user_id=139309

Yes, there is plenty of existing code that uses this idiom.. but it's awfully 
hard for bundlebuilder to detect it automatically.  The real solution (that 
doesn't require grotesque intelligence in bundlebuilder) is to propose a 
new extensible idiom for loading resources, which is currently being 
discussed on pythonmac-sig and pygame-users under the subject "python 
+ pygame of OSX".
msg61159 - (view) Author: Russell Owen (reowen) Date: 2004-02-26 17:55
Logged In: YES 
user_id=431773

I completely agree that bb should not have to detect this stuff automatically. I was simply hoping that something such as one of the following could be done:

- includePackages could be modified to include non-python files
- A new option could be added, one similar to includePackages that did everything includePackages does plus also includes all non-python files in the specified packages.
msg83154 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2009-03-04 22:44
I intend to close this issue as it is an enhancement proposal for a 
deprecated module.

Py2app (the modern replacement for bundlebuilder) also doesn't support 
this scenario, although it should be fairly easy to add such support to 
that codebase.
History
Date User Action Args
2022-04-11 14:56:02adminsetgithub: 39951
2009-03-30 21:54:38ronaldoussorensetstatus: open -> closed
resolution: wont fix
2009-03-04 22:44:44ronaldoussorensetnosy: + ronaldoussoren
messages: + msg83154
2009-02-13 04:25:18ajaksu2setstage: test needed
2004-02-19 18:30:26reowencreate