jelmer/xandikos

xandikos script fails on python 3.8

tobixen opened this issue · 7 comments

Another total weirdness ...

$ xandikos
Traceback (most recent call last):
  File "/usr/local/bin/xandikos", line 11, in <module>
    load_entry_point('xandikos==0.2.8', 'console_scripts', 'xandikos')()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 490, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2854, in load_entry_point
    return ep.load()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2445, in load
    return self.resolve()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2451, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/local/lib/python3.8/dist-packages/xandikos-0.2.8-py3.8.egg/xandikos/__main__.py", line 22, in <module>
    import asyncio
  File "/usr/local/lib/python3.8/dist-packages/asyncio/__init__.py", line 21, in <module>
    from .base_events import *
  File "/usr/local/lib/python3.8/dist-packages/asyncio/base_events.py", line 296
    future = tasks.async(future, loop=self)
                   ^
SyntaxError: invalid syntax

I tested to run a simple "import asyncio" from python shell, no problems. I tried running ./bin/xandikos, no problems. But the xandikos script that is installed by setup.py fails when installing master. Installing efe4370 and it works fine. I will do a bisect again ...

10248 [Thu Nov 17 20:41:27] tobias@broxbox02:~/xandikos
$ git bisect good
62b6140ad195fd6f9863a33b6e34f3a2504670e6 is the first bad commit
commit 62b6140ad195fd6f9863a33b6e34f3a2504670e6
Author: Jelmer Vernooij <jelmer@jelmer.uk>
Date:   Sun Oct 30 16:00:38 2022 +0000

    Depend on new icalendar.

 setup.cfg | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

$ git show 62b6140ad195fd6f9863a33b6e34f3a2504670e6
commit 62b6140ad195fd6f9863a33b6e34f3a2504670e6 (refs/bisect/bad)
Author: Jelmer Vernooij <jelmer@jelmer.uk>
Date:   Sun Oct 30 16:00:38 2022 +0000

    Depend on new icalendar.

diff --git a/setup.cfg b/setup.cfg
index 6984f74..ef69f64 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -19,7 +19,7 @@ classifiers =
 [options]
 install_requires =
     aiohttp
-    icalendar
+    icalendar>=5.0.0
     dulwich>=0.19.1
     defusedxml
     jinja2

This is weird, very weird.

Forgot to say that this bug is not reproducible on my arch linux installation with python 3.10. Anyway, I'm doing a bit more research ... I had a icalendar version 4 under /usr/local/lib/python/site-packages, removed it, setup.py installed icalendar 5 under that directory, but still same problem. Tried importing icalendar and than asyncio from python shell, no problems with that.

I will try to see if I can reproduce on a relatively clean ubuntu VM.

It feels like I'm falling down a rabbit hole ...

274 [Thu Nov 17 20:54:14] tobias@test-focal:~/xandikos
$ sudo python ./setup.py install
Traceback (most recent call last):
  File "./setup.py", line 4, in <module>
    setup()
  File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 144, in setup
    return distutils.core.setup(**attrs)
  File "/usr/lib/python3.8/distutils/core.py", line 121, in setup
    dist.parse_config_files()
  File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 701, in parse_config_files
    parse_configuration(self, self.command_options,
  File "/usr/lib/python3/dist-packages/setuptools/config.py", line 121, in parse_configuration
    meta.parse()
  File "/usr/lib/python3/dist-packages/setuptools/config.py", line 426, in parse
    section_parser_method(section_options)
  File "/usr/lib/python3/dist-packages/setuptools/config.py", line 399, in parse_section
    self[name] = value
  File "/usr/lib/python3/dist-packages/setuptools/config.py", line 184, in __setitem__
    value = parser(value)
  File "/usr/lib/python3/dist-packages/setuptools/config.py", line 515, in _parse_version
    version = self._parse_attr(value, self.package_dir)
  File "/usr/lib/python3/dist-packages/setuptools/config.py", line 349, in _parse_attr
    module = import_module(module_name)
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 848, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/tobias/xandikos/xandikos/__init__.py", line 27, in <module>
    import defusedxml.ElementTree  # noqa: This does some monkey-patching on-load
ModuleNotFoundError: No module named 'defusedxml'

Finally, after installing all the dependencies, I was not able to reproduce this behaviour on a relatively clean focal-VM, so I assume there is some local problem at my side. Closing the issue (but hope it will be found if someone else experiences the same).

I upgraded aiohttp to the latest version, and problem disappeared. Perhaps you need to put a version requirement on aiohttp.

(Or perhaps icalendar needs to put a version requirement on aiohttp)

Downgraded aiohttp again, but could not reproduce the problem. Let's just say that this was a local issue. Doing a "sudo pip install -U" on arbitrary packages solved the problem.