Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Erik Johansson
@Eiken
:) didnt know if you wanted it polluted
Toke Jepsen
@tokejepsen
Think we are all interested in off topic stuff as well. There is also an off topic tag on the Pyblish forums😀
Erik Johansson
@Eiken
so offtopic python question then :)
Tractor got a python module that is very neat
but in the same site-packages folder that it lives also nimby and PySide lives
so if I use PYTHONPATH env variable or sys.path.append i have had some fun issues with mismatching versions of those packages in applications that include them
so the question is basically can you load a module with submodules using imp or importlib by full path
i cant get it to work
can only load single files
[erjo@3d47 ~]$ cd /opt/pixar/Tractor-2.2/lib/python2.7/site-packages
[erjo@3d47 site-packages]$ ls -la
total 20
drwxr-xr-x  7 root root    73 Jan  2  2016 .
drwxr-xr-x 26 root root 12288 Mar 30  2016 ..
drwxr-xr-x  3 root root   136 Jan  2  2016 dateutil
drwxr-xr-x  2 root root   106 Jan  2  2016 nimby
drwxr-xr-x  2 root root  4096 Jan  2  2016 PySide
drwxr-xr-x  2 root root    66 Jan  2  2016 rmanpy
drwxr-xr-x  5 root root    56 Jan  2  2016 tractor
how it looks
Marcus Ottosson
@mottosso
Hey, just saw this
Are you familiar with Ecosystem or Rez?
In a nutshell, they're environment management tools and what they would do, at a practical level, is to put each of those packages in it's own directory, potentially with it's own version number.
PySide_1.21/
   PySide
tractor_2.5/
  tractor
...
In that way, you add each directory to your PYTHONPATH, and can have multiple co-existing versions alongside each other
$ export PYTHONPATH=$(pwd)/PySide_1.21:$(pwd)/tractor_2.5
Alternatively, as a temporary measure, or if you can't alter that directory, then you could add the path to your sys.path, import tractor and then remove the path again.
tractor would remain cached in sys.modules from anywhere else you import it
Erik Johansson
@Eiken
yeah i got my own version of ecosystem for managing different versions and etc
but i want to avoid modifying the default directory structure of tractor
Marcus Ottosson
@mottosso
Ah ok, so it was more specifically about this particular case
Erik Johansson
@Eiken
temporarily adding and removing sounds like it should be doable
yeah this specific case
i'll give that a try
Marcus Ottosson
@mottosso
Sure, I would try the sys.path approach first; you can do it via imp and others, but the import system is complex stuff, I always run into edge cases early when trying to work around it
import sys
sys.path.insert(0, "/path/to/tractor")
import tractor
sys.path.pop(0)
Erik Johansson
@Eiken
thanks, should work fine, only a couple few places its imported
Marcus Ottosson
@mottosso
If you put it in userSetup.py or the like, you could get away with only doing it once per Python session.
Marcus Ottosson
@mottosso
Question and answer stored here for future reference!
Erik Johansson
@Eiken
:thumbsup:
Erik Johansson
@Eiken
implemented, works as I want
thanks Marcus
Marcus Ottosson
@mottosso
Cool, glad it helped!
Erik Johansson
@Eiken
one less thing that can blow up in my face :D
Erik Johansson
@Eiken
time for roy galan
hope we win this year again
Marcus Ottosson
@mottosso
Roy galan?
Erik Johansson
@Eiken
swedish commercial awards at berns
Marcus Ottosson
@mottosso
Ah, nice
What is your contender?
Erik Johansson
@Eiken
conan exiles for best animation
Marcus Ottosson
@mottosso
Is it public?
Erik Johansson
@Eiken
and sveriges radio 90 år for best vfx
yeah
that turned out big
Marcus Ottosson
@mottosso
Ah yeah, I saw that one
Awesome :)
Erik Johansson
@Eiken
and this for best vfx