import question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ksenia Marasanova

    import question

    Hi list,

    I'd appreciate any advice on the following:

    In the "live" environment, I have some Python scripts which make use of
    Python packages. The directory structure is something like that:
    /live/
    /live/py/
    /live/lib/

    There is a .pth file in the Python site-packages directory, which
    contains "/live/lib".
    In the scripts, packages are imported with a normal import statement,
    like this:

    from module.submodul e import someclass

    Nothing unusual.

    Now I want to use the same server for "staging" environment. The
    additional directory structure will be:
    /staging/
    /staging/py/
    /staging/lib/

    After testing, files will be copied from "staging" to "live".
    Now my question: what would be the proper way to construct the import
    statement, so no modifications will be needed when copying files? I
    first thought about relative import (from ..lib import something) , but
    it seems not (yet) to be an option :-)


    Appreciate any tips!

    Thanx,
    Ksenia.



  • Larry Bates

    #2
    Re: import question

    I do this by putting what you refer to as "staging"
    on separate logical drive (windows) or with a symlink
    (linux) and placing the root in my pythonpath environment.
    Then I don't have to change my code, just the pythonpath.

    HTH,
    Larry Bates
    Syscon, Inc.

    "Ksenia Marasanova" <ksenia@ksenia. nl> wrote in message
    news:mailman.37 4.1084112165.25 742.python-list@python.org ...[color=blue]
    > Hi list,
    >
    > I'd appreciate any advice on the following:
    >
    > In the "live" environment, I have some Python scripts which make use of
    > Python packages. The directory structure is something like that:
    > /live/
    > /live/py/
    > /live/lib/
    >
    > There is a .pth file in the Python site-packages directory, which
    > contains "/live/lib".
    > In the scripts, packages are imported with a normal import statement,
    > like this:
    >
    > from module.submodul e import someclass
    >
    > Nothing unusual.
    >
    > Now I want to use the same server for "staging" environment. The
    > additional directory structure will be:
    > /staging/
    > /staging/py/
    > /staging/lib/
    >
    > After testing, files will be copied from "staging" to "live".
    > Now my question: what would be the proper way to construct the import
    > statement, so no modifications will be needed when copying files? I
    > first thought about relative import (from ..lib import something) , but
    > it seems not (yet) to be an option :-)
    >
    >
    > Appreciate any tips!
    >
    > Thanx,
    > Ksenia.
    >
    >
    >[/color]


    Comment

    Working...