import question

  • Thread starter Ksenia Marasanova
  • Start date
K

Ksenia Marasanova

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.submodule 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.
 
L

Larry Bates

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Import redirects 0
python import error 7
Question about import hooks 0
Distutils error 2
Import Problems 2
import bug 15
NumPy installation won't import correctly 6
Import order question 0

Members online

Forum statistics

Threads
474,197
Messages
2,571,040
Members
47,634
Latest member
RonnyBoelk

Latest Threads

Top