Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use relative imports #98

Merged
merged 1 commit into from
Sep 21, 2021
Merged

Use relative imports #98

merged 1 commit into from
Sep 21, 2021

Conversation

sbidoul
Copy link
Contributor

@sbidoul sbidoul commented Sep 21, 2021

Coming from #83 I think this should help.

I tested python -m zfs_autobackup with python2 and 3, and the zipapp and both seem work fine.

@psy0rz
Copy link
Owner

psy0rz commented Sep 21, 2021

I tried your changes to no avail:

psy@ws1 ~/zfs_autobackup % python3 -m zipapp zfs_autobackup  -p "/usr/bin/env python3" -o zfs-autobackup  ; ./zfs-autobackup
Traceback (most recent call last):
  File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "./zfs-autobackup/__main__.py", line 8, in <module>
ImportError: attempted relative import with no known parent package
psy@ws1 ~/zfs_autobackup % python3 --version                                                                                
Python 3.8.10
psy@ws1 /tmp % lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 20.04.3 LTS
Release:	20.04
Codename:	focal

I'll try upgrading and on another system. Maybe its something local.

(But i can confirm everything still works with your changes, including creating and installing the pip package.)

@sbidoul
Copy link
Contributor Author

sbidoul commented Sep 21, 2021

I tried your changes to no avail:

I think it's because you are packing the content of the zfs_autobackup directory instead of the directory itself.

The original procedure in #83 (comment) works for me.
It packs the zfs_autobackup directory and tells it the main entry point is zfs_autobackup:cli.

But i can confirm everything still works with your changes, including creating and installing the pip package

Yep. Relative imports is good practice anyway and this should be safe to merge.

@psy0rz psy0rz merged commit 9dc280a into psy0rz:master Sep 21, 2021
@psy0rz
Copy link
Owner

psy0rz commented Sep 21, 2021

I think it's because you are packing the content of the zfs_autobackup directory instead of the directory itself.

DOH! I tried by using the whole gitrepo, instead of the zfs_autobackup subdir and now its fine.

I'll also try to include argparse and colorama in it, as that seems to be possible according to zipapp docs.

@sbidoul sbidoul deleted the relative-imports branch September 21, 2021 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants