kvesteri / sqlalchemy-utils

Various utility functions and datatypes for SQLAlchemy.
Other
1.26k stars 321 forks source link

test failure #553

Closed Alessandro-Barbieri closed 2 years ago

Alessandro-Barbieri commented 3 years ago

Gentoo overlay guru CI fail tests with:

>>> Test phase: dev-python/SQLAlchemy-Utils-0.37.8
 * python3_8: running distutils-r1_run_phase python_test
python3.8 -m pytest -vv -ra -l -Wdefault --deselect tests/types/test_timezone.py
============================= test session starts ==============================
platform linux -- Python 3.8.12, pytest-6.2.5, py-1.10.0, pluggy-1.0.0 -- /usr/bin/python3.8
cachedir: .pytest_cache
rootdir: /var/tmp/portage/dev-python/SQLAlchemy-Utils-0.37.8/work/SQLAlchemy-Utils-0.37.8
collecting ... collected 865 items / 1 error / 864 selected

==================================== ERRORS ====================================
________________ ERROR collecting tests/types/test_timezone.py _________________
ImportError while importing test module '/var/tmp/portage/dev-python/SQLAlchemy-Utils-0.37.8/work/SQLAlchemy-Utils-0.37.8/tests/types/test_timezone.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/lib/python3.8/site-packages/_pytest/python.py:578: in _importtestmodule
    mod = import_path(self.fspath, mode=importmode)
/usr/lib/python3.8/site-packages/_pytest/pathlib.py:524: in import_path
    importlib.import_module(module_name)
/usr/lib/python3.8/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
<frozen importlib._bootstrap>:1014: in _gcd_import
    ???
<frozen importlib._bootstrap>:991: in _find_and_load
    ???
<frozen importlib._bootstrap>:975: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:671: in _load_unlocked
    ???
/usr/lib/python3.8/site-packages/_pytest/assertion/rewrite.py:170: in exec_module
    exec(co, module.__dict__)
tests/types/test_timezone.py:4: in <module>
    from dateutil.zoneinfo import getzoneinfofile_stream, tzfile, ZoneInfoFile
E   ImportError: cannot import name 'getzoneinfofile_stream' from 'dateutil.zoneinfo' (/usr/lib/python3.8/site-packages/dateutil/zoneinfo/__init__.py)
=========================== short test summary info ============================
ERROR tests/types/test_timezone.py
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
=============================== 1 error in 2.27s ===============================

See https://bugs.gentoo.org/819021

kurtmckee commented 2 years ago

Is this still an issue with the latest version of sqlalchemy-utils?

Alessandro-Barbieri commented 2 years ago

Same error with latest version

kurtmckee commented 2 years ago

Thanks for the quick response! I'm not familiar with Gentoo's overlay guru CI system but let's try to figure this out!

~The first thing I notice is that sqlalchemy_utils isn't mentioned anywhere in the traceback.~ Whoops, that's not true. Found it. The second thing I notice is that the CI system is using the system-installed dateutil package.

Would you check the dateutil version that's installed at:

/usr/lib/python3.8/site-packages/dateutil/

There should be a ._version.py file at that location that contains the version dateutil version number, if I'm reading the dateutil source code correctly.

Please also confirm that there IS actually a getzoneinfofile_stream() function defined in /usr/lib/python3.8/site-packages/dateutil/zoneinfo/__init__.py. I checked dateutil versions dating back to 2014 and that function has always existed, so I'd like confirmation that dateutil is installed correctly.

Thanks for checking on this!

Alessandro-Barbieri commented 2 years ago

I see that gentoo's dateutil apply a patch that removes that function https://gitweb.gentoo.org/repo/gentoo.git/tree/dev-python/python-dateutil/files/python-dateutil-2.8.2-system-tzdata.patch

kurtmckee commented 2 years ago

That's the root cause. Whoever created that patch ripped out long-standing functionality in dateutil without replacing it.

It looks like sqlalchemy_utils could be modified to rely on dateutil.zoneinfo.get_zonefile_instance(), but I recommend simultaneously working within the Gentoo ecosystem to fix that patch that's ripping out functionality instead of augmenting it for Gentoo systems.

I'll take a stab at a patch for sqlalchemy_utils later.

Alessandro-Barbieri commented 2 years ago

@mgorny since you made that patch

mgorny commented 2 years ago

Restoring the function alone won't help unless we also install the redundant timezone copy which I'm strongly against. I mean, I can restore it but it would fail anyway, so you'd have to handle the failure gracefully.

kurtmckee commented 2 years ago

Thank you both for your time and support! I've created a potential patch for this in PR #585. Would either of you be able to test this in an environment that has a patched dateutil?