linuxmint / warpinator

Share files across the LAN
GNU General Public License v3.0
1.18k stars 80 forks source link

cannot import name 'ServiceInfo' from 'zeroconf' #87

Closed SwampRabbit closed 3 years ago

SwampRabbit commented 3 years ago

After packaging (with pbuilder) the just released 1.2.0, I get the following while trying to test executing it:

cannot import name 'ServiceInfo' from 'zeroconf' (/usr/libexec/warpinator/zeroconf_/__init__.py) Note: This file exists but is empty.

This is on MX-19 (Debian Buster) and MX-21alpha (Debian Bullseye). I packaged and installed python3-zeroconf (0.27.1) at the same time.

Thanks in advance for your assistance in narrowing this down.

mtwebster commented 3 years ago

Hi, I started downloading and bundling zeroconf as part of the build - see https://github.com/linuxmint/warpinator/blob/master/install-scripts/download_zeroconf.py. I did this so I could stop worrying about api changes and just use a consistent version everywhere. It installs a copy in a subfolder of the warpinator install folder (/usr/libexec/warpinator/zeroconf_).

It sounds like the download is failing during the build, so you end up with the empty file.

It will still run with the system version as long as it's > 0.27 - we check which version to use here: https://github.com/linuxmint/warpinator/blob/master/src/server.py#L29-L33

You can disable the bundling with a meson build option (`bundle-zeroconf') which defaults to true. If you do this, make sure to remove that empty zeroconf_ file so the runtime check 'fails' properly.

SwampRabbit commented 3 years ago

@mtwebster wow such a fast response, I'll give it a go first chance I get, thanks!

SwampRabbit commented 3 years ago

@mtwebster so I created a Debian patch that just changed it from true to false... built, installed, and opened fine. Can test more later, but don't think I'll have issues.

Thanks for pointing out the change, I honestly didn't dig at all because this app has been so easy to do for so long.

You probably already know it, but when packaging for Debian in a schroot (sbuild/pbuilder), it by default disables internet access at build time (unless we change that default for a package). I get your choice and reasoning and really easy fix for us package maintainers. Might be worth adding to the README as long as your bundling it at built time.

Thanks again, keep up the great work!

riverside6 commented 3 years ago

@SwampRabbit May you please share that script / workaround? I ran into the same poblem and don't know where to change the boolean etc.

riverside6 commented 3 years ago

Got it:) I downloaded the missing _ init .py: wget https://raw.githubusercontent.com/jstasiak/python-zeroconf/0.29.0/zeroconf/__init__.py ...and replaced the empty init .py in /usr/libexec/warpinator/zeroconf/ with it. Hope this'll be fixed for less techier folks. Thanks for sharing the links @mtwebster

mtwebster commented 3 years ago

I'll change the runtime check to gracefully fail instead of relying on the build flag. I'll also add some additional notes to the readme.

SwampRabbit commented 3 years ago

@mtwebster thanks for taking the time to do some refinement for this.

I guess it could be handled a bunch of different ways too, I was thinking of handling the meson build options in the debian/rules file rather than maintaining a silly patch like this.

@riverside6 it probably won't be needed for long, but in case you're interested in what I did for the sake of it. https://github.com/SwampRabbit/warpinator/tree/master/debian/patches