Development: How to get around self importing module #65

Closed
opened 2018-06-06 16:26:49 +00:00 by floli · 2 comments
Collaborator

Hello,
when I try to launch borgmatic from a git checkout:

~/software/borgmatic/borgmatic (git)-[master] # python commands/borgmatic.py 

Traceback (most recent call last):
  File "commands/borgmatic.py", line 8, in <module>
    from borgmatic.borg import check as borg_check, create as borg_create, prune as borg_prune, \
  File "/home/florian/software/borgmatic/borgmatic/commands/borgmatic.py", line 8, in <module>
    from borgmatic.borg import check as borg_check, create as borg_create, prune as borg_prune, \
ModuleNotFoundError: No module named 'borgmatic.borg'; 'borgmatic' is not a package

~/software/borgmatic/borgmatic (git)-[master] # echo $PYTHONPATH
:/home/florian/software/borgmatic

this is probably a result of commands/borgmatic.py import from borgmatic, which is interpreted as importing from the same file.

How do you get around this while developing?

Thanks!

Hello, when I try to launch borgmatic from a git checkout: ``` ~/software/borgmatic/borgmatic (git)-[master] # python commands/borgmatic.py Traceback (most recent call last): File "commands/borgmatic.py", line 8, in <module> from borgmatic.borg import check as borg_check, create as borg_create, prune as borg_prune, \ File "/home/florian/software/borgmatic/borgmatic/commands/borgmatic.py", line 8, in <module> from borgmatic.borg import check as borg_check, create as borg_create, prune as borg_prune, \ ModuleNotFoundError: No module named 'borgmatic.borg'; 'borgmatic' is not a package ~/software/borgmatic/borgmatic (git)-[master] # echo $PYTHONPATH :/home/florian/software/borgmatic ``` this is probably a result of `commands/borgmatic.py` import from `borgmatic`, which is interpreted as importing from the same file. How do you get around this while developing? Thanks!
floli changed title from Development: How do get around self importing module to Development: How to get around self importing module 2018-06-06 16:27:01 +00:00
witten added the
question / support
label 2018-06-07 04:42:11 +00:00
Owner

I develop on this by installing borgmatic as "editable". Meaning, with the pip install --editable flag. That means I can hack on the source and see changes reflected immediately, while everything is imported exactly as it would be in the real world. Plus, all of the standard borgmatic console commands are runnable this way as well, assuming they're installed somewhere that's on your PATH (or you're using a virtualenv).

If that process works for you, then I can at least make sure that's mentioned in the documentation.

I develop on this by installing borgmatic as "editable". Meaning, with the `pip install --editable` flag. That means I can hack on the source and see changes reflected immediately, while everything is imported exactly as it would be in the real world. Plus, all of the standard borgmatic console commands are runnable this way as well, assuming they're installed somewhere that's on your `PATH` (or you're using a virtualenv). If that process works for you, then I can at least make sure that's mentioned in the documentation.
Owner

I added some info about using "editable" mode to the borgmatic README during development. So calling this done for now. But please let me know if you have any other issues with this.

I added some info about using "editable" mode to the borgmatic README during development. So calling this done for now. But please let me know if you have any other issues with this.
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: borgmatic-collective/borgmatic#65
No description provided.