Skip to content

Conflicting versions for uritemplate library #299

Description

@mesemus

Package version (if known): 2.1.1

Describe the bug

Parts of Invenio use uritemplate library which provides python package uritemplate.
This library (and invenio-github as well) have dependency to uritemplate.py that provides the
same package - thus the one used is determined by the order in which libraries are installed (not deterministic).

For python 3.9 it seems that Invenio works with both implementations, but for python 3.10
uritemplate.py<2 is broken.

Steps to Reproduce

Install Invenio and reinstall uritemplate.py. Then run any test that uses uri template (for example service.scan):

/invenio_records_resources/services/records/results.py:199: in hits
    projection["links"] = self._links_item_tpl.expand(
....
/opt/hostedtoolcache/Python/3.10.10/x64/lib/python3.10/site-packages/uritemplate/variable.py:278: in _string_expansion
    if dict_test(value) or tuples:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

value = 'as9k9-0nr40'

    def dict_test(value):
>       return isinstance(value, (dict, collections.MutableMapping))
E       AttributeError: module 'collections' has no attribute 'MutableMapping'

Expected behavior

If possible, only uritemplate library should be used throughout invenio.

Workaround

We currently use the following workaround:

pip install -e '.[tests]'
pip install -e 'tests/records2'
pip uninstall -y uritemplate
pip install uritemplate
export PYTHONPATH=.

pytest tests

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions