I’m looking into branching python packages in Eclipse using the Subclipse plugin. I can physically branch fine, the problem occurs when I’m using the Debug and Run feature in Eclipse. It doesn’t change where the imports are coming from; take this example…
PythonProject > trunk > test > __init__.py
main.py
message.py
main.py contains:
from test.message import message
print message
message.py contains:
message = "Hello world!"
the __init__ is empty.
When branching:
PythonProject > branches > 1 > test > __init__.py
main.py
message.py
main.py contains:
from test.message import message
print message
message.py contains:
message = "Hello earth!"
But when I run debug or run from the branched main.py I get “Hello world!” printed. I need Eclipse to pick up the new PYTHONPATH. I know this can be done with a sys.path.append / sys.pah.insert but I hope there’s a much slicker solution.
Hope this makes sense.
You could create separate projects in Eclipse for the branches and set their
PYTHONPATHs differently. There’s probably another, hackier way to do it (and maybe a non-hacky way too), but the idea of a project is that it is a cohesive unit. By definition, different branches are not part of a cohesive whole.