0

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.

joedborg
  • 17,651
  • 32
  • 84
  • 118

1 Answers1

0

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.

Silas Ray
  • 25,682
  • 5
  • 48
  • 63
  • I've found that in the debug configuration, you can overwrite the PYTHONPATH system variable which I am currently using. Just wondering if there was a built in feature. – joedborg Jul 18 '12 at 13:40
  • That can get confusing fast. I think that feature is really meant so you can substitute instrumented libraries when running your code in debug, not so you can have fundamentally different code paths run in debug vs run configuration. If it works for you, great, but I'd recommend against it. – Silas Ray Jul 18 '12 at 13:45
  • Yep, and that's why I've raised this question :) – joedborg Jul 18 '12 at 13:47
  • Well, I'd recommend separate projects if you want to have them checked out side by side. If they have shared, non-branched dependencies that take a long time to branch or check out, you could drop those in another project that both projects reference. Or you could just stick to working on one branch on your machine at once. :) – Silas Ray Jul 18 '12 at 13:54