Closed jayvdb closed 2 years ago
At the moment DCP the underlying Compat-Patcher-Core have no utilities to edit module bytecode on import ; i don't kow how hard it is to do like Pytest and other "magic" modules.
However, since it's a very old version you're targetting, you could probably just vendor a fixed copy of libgeos.py (or one for py27 and one for py3K), and make this an optional fixer which only applies when specifically selected (like the optparse/argparse one). The fixer would inject this module in sys.modules at the right place, using compat-patcher-core utilities.
It might be necessary to also inject the name "libgeos" in django/contrib/gis/geos package, since the import system normally does that.
I'm closing this as it looks quite complicated, and Django 2&3 are the main retrocompatibility targets for DCP now ^^
https://gist.github.com/jams2/11a60020a1ada897d79fc4c77fb587eb is about a defect in Django 1.11 preventing usage of GIS on newer distros, such as Ubuntu focus.
https://code.djangoproject.com/ticket/31838 is wontfix, but it looks like the fix is on the branch, unreleased. https://github.com/django/django/commit/a49764dd9daa11c4e24bad84423f71711b3e0de0
Patching the module after import doesnt work, because loading the module causes the version checker to be used, so chicken/egg problem.
https://travis-ci.org/github/jayvdb/bluebottle/jobs/749482856 for the above backtrace.
It can be fixed by injecting the modified
version_regex
symbol during module loading. I dont recall whethercompat-patcher-core
has the ability to patch modules after loading yet before the module level code in them is executed. I do have a fairly advanced set of routines to do that, and it would be sensible to add it to CPC if it is missing.