squeeze and package imports

Discussion in 'Python' started by Mathias Waack, Sep 25, 2003.

  1. Hi,

    I've got a problem with Fredrik's squeeze tool. I've got a script
    which accesses a Oracle DB with the help of DCOracle. This script
    works very well, but after squeezing it the "import DCOracle" fails.
    The DCOracle package consists of several python files and some
    shared libs. The import of one shared lib from within the package
    fails. It looks like a problem with the code responsible for
    searching the appropriate module file.

    Let me try to illustrate the situation. DCOracle ist installed under
    /tmp for example:

    /tmp
    +--- DCOracle
    +----- odb.py
    +----- Buffer.sl
    +----- __init__.py
    ...

    __init__.py imports odb.py which imports Buffer.sl, that means in
    odb.py you can find statements like
    from Buffer import Buffer

    If I import it from my script:

    sys.path.append("/tmp")
    import DCOracle

    it works without squeezing and fails with squeezing. In the latter
    case, the Buffer import statement named above fails. The traceback
    shows, which import in which file is executed, but instead of the
    directory names of each file it prints only question marks "?". Thus
    I thought, if the import code doesn't know about the current
    directory, it can't import the Buffer module, because it can't look
    into the "same" directory. And so my second try:

    sys.path.append("/tmp")
    sys.path.append("/tmp/DCOracle")
    import DCOracle

    And everything works fine. But I'm still curious - there seems to be
    something wrong with the import hooks in the squeeze module. BTW,
    I'm using python 2.2.2.

    Any ideas?

    Mathias
     
    Mathias Waack, Sep 25, 2003
    #1
    1. Advertising

  2. Mathias Waack wrote:

    > it works without squeezing and fails with squeezing. In the latter
    > case, the Buffer import statement named above fails. The traceback
    > shows, which import in which file is executed, but instead of the
    > directory names of each file it prints only question marks "?". Thus
    > I thought, if the import code doesn't know about the current
    > directory, it can't import the Buffer module, because it can't look
    > into the "same" directory. And so my second try:
    >
    > sys.path.append("/tmp")
    > sys.path.append("/tmp/DCOracle")
    > import DCOracle
    >
    > And everything works fine. But I'm still curious - there seems to be
    > something wrong with the import hooks in the squeeze module. BTW,
    > I'm using python 2.2.2.


    Python didn't have packages back in the early days when squeeze
    was written (Python 1.3 or so); afaik, nobody's ever gotten around
    to add true package support to the tool.

    for a modern replacement, see:

    http://www.mcmillan-inc.com/install1.html

    </F>
     
    Fredrik Lundh, Sep 26, 2003
    #2
    1. Advertising

  3. Mathias Waack, Sep 27, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Big Bill
    Replies:
    7
    Views:
    436
    Big Bill
    May 7, 2004
  2. David Pratt
    Replies:
    4
    Views:
    346
    David Pratt
    May 13, 2006
  3. Albert
    Replies:
    4
    Views:
    10,996
    Albert
    Jul 10, 2008
  4. zildjohn01
    Replies:
    0
    Views:
    678
    zildjohn01
    Feb 22, 2011
  5. Victor Hooi
    Replies:
    1
    Views:
    124
    Devin Jeanpierre
    Nov 25, 2013
Loading...

Share This Page