I am working on a module (mypackage) using Eclipse/PyDev and Python 2.7. I have other packages and modules that need to use it. In order to make sure the other packages and modules are always using a working version of mypackage, I decided to deploy mypackage to site-packages using distutils (same computer), which I will only update if the development version of mypackage in PyDev has been debugged after making changes.
In order to get mypackage to work when deployed to site-packages, I had to write it using absolute imports. The problem with that is that now when I try to run the modules within the develoment version of mypackage from Eclipse for debugging, it is importing other modules in mypackage from site-packages rather than from the development version in Eclipse.
Is there a way to get around this? I would hate to have to rewrite my code with absolute-imports every time I want to update mypackage in site-packages, and then change it back if I want to make changes and debug my code in Eclipse.
Adding the project directory /${PROJECT_DIR_NAME} to the project's PYTHONPATH seems to have done the trick.
Before, I only had /${PROJECT_DIR_NAME}/mypackage in the project's PYTHONPATH. So I suspect that, when using absolute imports, Eclipse was unable to find /${PROJECT_DIR_NAME}/mypackage/mypackage/mymodule and would then proceed to search in site-packages.
PyDev imports from package in site-packages rather than package in development (absolute-imports)