p3d stuff does not handle __init__.py properly

i have some code in utli/init.py

in normal python when i import i get no error

from util import v3,v4,vHpr

but in the p3d packed i get an error:

Traceback (most recent call last):
  File "/root/pandaworker/panda3d-1.7.0/built_cmu/direct/p3d/AppRunner.py", line 411, in run
  File "/root/pandaworker/panda3d-1.7.0/built_cmu/direct/task/Task.py", line 496, in run
  File "/root/pandaworker/panda3d-1.7.0/built_cmu/direct/task/Task.py", line 454, in step
  File "/root/pandaworker/panda3d-1.7.0/built_cmu/direct/showbase/Messenger.py", line 352, in __taskChainDispatch
  File "/root/pandaworker/panda3d-1.7.0/built_cmu/direct/showbase/Messenger.py", line 410, in __dispatch
  File "/root/pandaworker/panda3d-1.7.0/built_cmu/direct/p3d/AppRunner.py", line 493, in __startIfReady
  File "VFSImporter", line 153, in load_module
  File "/p/2awr/c.py", line 27, in <module>
    from client.clientbase import Base
  File "VFSImporter", line 153, in load_module
  File "/p/2awr/client/clientbase.py", line 15, in <module>
    from usernet import UserNetwork
  File "VFSImporter", line 153, in load_module
  File "/p/2awr/client/usernet.py", line 2, in <module>
    from sim.simulation import Faction
  File "VFSImporter", line 153, in load_module
  File "/p/2awr/sim/simulation.py", line 24, in <module>
    from util import v3,v4,vHpr
ImportError: cannot import name v3

When i look into the multifile i see some really odd stuff:

util/__init__.pyo
util/__init__/__init__.pyo
util/autoload.pyo
util/eggatlas.pyo
util/eggtools.pyo
util/hotcode.pyo
util/imagetable.pyo
util/intmath.pyo
util/logger.pyo
util/mesh.pyo
util/navigation.pyo
util/nodetex.pyo
util/odict.pyo
util/pvfs.pyo
util/rectpack.pyo
util/sha.pyo
util/task.pyo
util/texttools.pyo

It looks like it creates a folder for the init files?

It looks like the real init file does not have my definition, while the other one that in the init directory does.

$ grep v3 __init__.pyo 
$ grep v3 __init__/__init__.pyo 
Binary file __init__/__init__.pyo matches

If the system wants to work this way, it should load the init/init.pyo when loading the init.pyo.

This was a bug I fixed just before the 1.7 release. Have you tried it with the latest?

David

I think this is the most recent one, hosted at runtime.panda3d.org .

Actually, now that I look more closely, maybe this is a new bug I wasn’t aware of. There might be something about your directory structure, or something about the way you are importing, or something about the way you are creating the p3d file, that tricks packp3d into making this extra init/init.pyo file.

Does the same thing happen when you use packp3d on an ordinary directory structure that contains init.py files within subdirectories? If not, can you isolate what it is that you are doing differently that causes this?

David

I am using ppackage.p3d, sorry for confusion, and here is my pdef file:

from pandac.PandaModules import Filename, PandaSystem, getModelPath
from pandac.PandaModules import getModelPath, Filename, ConfigVariableFilename, DSearchPath, ExecutionEnvironment


packager.setHost('http://katana.aff2aw.com/d/')

class code(package):
    """ this is the main client code packadge """
    
    config(
        version="0.1",
        display_name = "code",
        platform_specific = False)
    
    file("/p/2awr/c.py")
    file("/p/2awr/__init__.py")
    
    dir('/p/2awr/cfg','cfg')
    dir('/p/2awr/client','client')
    dir('/p/2awr/common','common')
    dir('/p/2awr/inferno','inferno')
    dir('/p/2awr/net','net')
    dir('/p/2awr/sim','sim')
    dir('/p/2awr/treegui','treegui')
    dir('/p/2awr/util','util')
    
    exclude("/p/2awr/client/tests/*")
    exclude("/p/2awr/common/tests/*")
    exclude("/p/2awr/inferno/tests/*")
    exclude("/p/2awr/net/tests/*")
    exclude("/p/2awr/sim/tests/*")
    exclude("/p/2awr/treegui/tests/*")
    exclude("/p/2awr/util/tests/*")
    
    require('panda3d')
    require('egg')
    
class data(package):
    """ this is the sim packadge """
    config(
        version="0.1",
        display_name = "data",
        platform_specific = False)

    dir('/p/2awr/data','data')
    
class aff2aw(p3d):
    """ empty holder p3d that should download all other packadges """
    config(
        version="0.1",
        display_name = "AFF:Second Anterean War",
        platform_specific = False)
        
    require('code')
    require('data')
    mainModule('c')

Hmm, this is a little unexpected:

    file("/p/2awr/c.py")
    file("/p/2awr/__init__.py") 

First, it’s weird to add the init.py file explicitly; and second, it’s weird to add .py files as files, and not as modules. (Arguably, the Packager ought to be able to handle this correctly; but I wasn’t expecting Python files to be added in this way when I coded it up. I’ll have to look into fixing this later.)

In the meantime, try replacing this with:

    module('c')

David

If i use:

module('c') 

I get this errors and crap:

Unknown module: c
There are some missing modules: ['adjucor', 'aeora', 'aesir', 'agriculturalstation', 'alfazard', 'anubis', 'baal', 'basecomponents', 'bast', 'breeze', 'cerberus', 'chons', 'damocles', 'daphne', 'darsalaam', 'dawnstar', 'everstar', 'firefly', 'fox', 'freya', 'fueldepot1', 'gemini', 'griphon', 'habstation1', 'heimdall', 'hfs', 'hind', 'horus', 'huginn', 'iret', 'ishtar', 'javert', 'katana', 'khamun', 'loki', 'mainmenu', 'mjolnir', 'mock.sm', 'morningstar', 'muninn', 'ordermenu', 'orion', 'osiris', 'outpost', 'players', 'preferences', 'pridec', 'quetesh', 'ragnarok', 'raksasha', 'ranger', 'rapier', 'refinery1', 'rejkhart', 'relay1', 'repairdepot1', 'requisition', 'rhapsody', 'selectionbar', 'shipyard1', 'shu', 'sobek', 'sword', 'ti', 'tradedepot1', 'treadwaylpcc', 'treegui', 'util', 'valhalla', 'valkyrie', 'viper', 'vladimir', 'warbird', 'win']

But c module is not really a problem. Using it that way works quite well. Unless its connected to the util problem dont worry about it.

I would think this code is where the problem/bug is?

dir('/p/2awr/util','util') 
...
exclude("/p/2awr/util/tests/*")