python-jsonschema / jsonschema

An implementation of the JSON Schema specification for Python
https://python-jsonschema.readthedocs.io
MIT License
4.6k stars 580 forks source link

PyO3 error #1176

Closed LukasJerabek closed 1 year ago

LukasJerabek commented 1 year ago

I had to downgrade back to 4.17.3 version because in newer versions I got these errors when running tests with pytest. Is PyO3 some sub dependency?

   BROKEN  .tests.integ.iadmin.modules.test_validators
ImportError while importing test module '/home/vagrant/pack/tests/integ/iadmin/modules/test_validators.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
../.pyenv/versions/3.8.18/lib/python3.8/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/integ/iadmin/modules/test_validators.py:2: in <module>
    from jsonschema import ValidationError
../venv/pack/lib/python3.8/site-packages/jsonschema/__init__.py:13: in <module>
    from jsonschema._format import FormatChecker
../venv/pack/lib/python3.8/site-packages/jsonschema/_format.py:11: in <module>
    from jsonschema.exceptions import FormatError
../venv/pack/lib/python3.8/site-packages/jsonschema/exceptions.py:15: in <module>
    from referencing.exceptions import Unresolvable as _Unresolvable
../venv/pack/lib/python3.8/site-packages/referencing/__init__.py:4: in <module>
    from referencing._core import Anchor, Registry, Resource, Specification
../venv/pack/lib/python3.8/site-packages/referencing/_core.py:8: in <module>
    from rpds import HashTrieMap, HashTrieSet, List
../venv/pack/lib/python3.8/site-packages/rpds/__init__.py:1: in <module>
    from .rpds import *
E   ImportError: PyO3 modules may only be initialized once per interpreter process
Julian commented 1 year ago

Yes, it's used by rpds. Please provide something which reproduces the behavior you're seeing.

Julian commented 1 year ago

Closing but happy to look into this if you can share something which reproduces.

LukasJerabek commented 1 year ago

I am still investigating this little bit deeper, because it seems to be caused by how our tests are run, couldnt reproduce it outside our tests run script yet.

LukasJerabek commented 1 year ago

My suspicion has turned to python-cov package now. In case you are interested, since I am still not sure, which package exactly causes it (python-cov or both jsonschema and cryptography), you can check out the reproducer here https://github.com/pytest-dev/pytest-cov/issues/614

Julian commented 1 year ago

Thanks, will perhaps have a look there.