sbp opened a new pull request #23:
URL: https://github.com/apache/incubator-ponymail-foal/pull/23


   The Python files in the `tools` directory are written to be run as scripts 
from that directory. This means that the `archiver.py` file doesn't work when 
installed as a package, which its own documentation advises, because it cannot 
find the `plugins` directory when imported as a package rather than run as a 
script.
   
   The obvious solution to this is to change the `plugins` imports in 
`archiver.py` to be relative dotted imports, but this then causes `archiver.py` 
to fail when it is imported from the `import-mbox.py` script.
   
   The problem is that Python [really doesn't 
like](https://stackoverflow.com/questions/16981921/relative-imports-in-python-3)
 files being used as both scripts and package modules. There have been many 
suggested workarounds for this over the years, with varying levels of 
complexity. This PR takes the [simple 
approach](https://stackoverflow.com/a/49480246) of using relative dotted 
imports only if `__package__` is set.
   
   A more advanced solution would be to treat `tools` as a package which can be 
installed using pip. This would require much more effort, but would probably be 
easier for end users. In lieu of that, this PR also adds a simple `__init__.py` 
file which imports from `archiver.py`, so that installing `tools` as a package 
now only requires copying the whole directory instead of also copying 
`archiver.py` to `__init__.py`.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to