tefra / xsdata-pydantic

Naive XML & JSON Bindings for python pydantic classes!
https://xsdata-pydantic.readthedocs.io/
MIT License
52 stars 10 forks source link

command line only outputs: Install cli requirements "pip install xsdata[cli]" #24

Closed jorgejesus closed 7 months ago

jorgejesus commented 12 months ago

Tried to install xsdata-pydantic as indicated on the docs (pip install xsdata-pydantic[cli]) when running a xsdata command (xsdata --help) it only outpurs: Install cli requirements "pip install xsdata[cli]"

Even doing first a pip install xsdata[cli] and pip install xsdata-pydantic[cli] it outputs the same error message. This can be tested using this dockerfile:

FROM python:3.8.18-slim-bookworm

RUN pip install xsdata[cli]
RUN pip install xsdata-pydantic[cli]
WORKDIR /data
ENTRYPOINT ["xsdata"]

Running:

docker build --progress=plain --no-cache -t xsdata-pydantic .
docker run  xsdata-pydantic --version
Install cli requirements "pip install xsdata[cli]"
seyhbold commented 11 months ago

I see the same issue.

digging a bit deeper gives me:

python                                                                                                                   ☸ (ceph)
Python 3.11.3 (main, Apr 24 2023, 15:24:08) [Clang 14.0.3 (clang-1403.0.22.14.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from xsdata.cli import cli
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/weissl/.pyenv/versions/stage-ingest/lib/python3.11/site-packages/xsdata/cli.py", line 13, in <module>
    from xsdata.codegen.transformer import SchemaTransformer
  File "/Users/weissl/.pyenv/versions/stage-ingest/lib/python3.11/site-packages/xsdata/codegen/transformer.py", line 17, in <module>
    from xsdata.codegen.analyzer import ClassAnalyzer
  File "/Users/weissl/.pyenv/versions/stage-ingest/lib/python3.11/site-packages/xsdata/codegen/analyzer.py", line 3, in <module>
    from xsdata.codegen.container import ClassContainer
  File "/Users/weissl/.pyenv/versions/stage-ingest/lib/python3.11/site-packages/xsdata/codegen/container.py", line 7, in <module>
    from xsdata.codegen.handlers import AddAttributeSubstitutions
  File "/Users/weissl/.pyenv/versions/stage-ingest/lib/python3.11/site-packages/xsdata/codegen/handlers/__init__.py", line 1, in <module>
    from .add_attribute_substitutions import AddAttributeSubstitutions
  File "/Users/weissl/.pyenv/versions/stage-ingest/lib/python3.11/site-packages/xsdata/codegen/handlers/add_attribute_substitutions.py", line 6, in <module>
    from xsdata.codegen.mixins import ContainerInterface
  File "/Users/weissl/.pyenv/versions/stage-ingest/lib/python3.11/site-packages/xsdata/codegen/mixins.py", line 10, in <module>
    from xsdata.models.config import GeneratorConfig
  File "/Users/weissl/.pyenv/versions/stage-ingest/lib/python3.11/site-packages/xsdata/models/config.py", line 19, in <module>
    from xsdata.formats.dataclass.context import XmlContext
  File "/Users/weissl/.pyenv/versions/stage-ingest/lib/python3.11/site-packages/xsdata/formats/dataclass/context.py", line 13, in <module>
    from xsdata.formats.dataclass.compat import class_types
  File "/Users/weissl/.pyenv/versions/stage-ingest/lib/python3.11/site-packages/xsdata/formats/dataclass/compat.py", line 148, in <module>
    load_entry_points("xsdata.plugins.class_types")
  File "/Users/weissl/.pyenv/versions/stage-ingest/lib/python3.11/site-packages/xsdata/utils/hooks.py", line 13, in load_entry_points
    plugin.load()
  File "/Users/weissl/.pyenv/versions/3.11.3/lib/python3.11/importlib/metadata/__init__.py", line 202, in load
    module = import_module(match.group('module'))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/weissl/.pyenv/versions/3.11.3/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/weissl/.pyenv/versions/stage-ingest/lib/python3.11/site-packages/xsdata_pydantic/hooks/class_type.py", line 3, in <module>
    from xsdata_pydantic.compat import Pydantic
  File "/Users/weissl/.pyenv/versions/stage-ingest/lib/python3.11/site-packages/xsdata_pydantic/compat.py", line 14, in <module>
    from pydantic.validators import _VALIDATORS
ImportError: cannot import name '_VALIDATORS' from 'pydantic.validators' (/Users/weissl/.pyenv/versions/stage-ingest/lib/python3.11/site-packages/pydantic/validators.py)
>>> from pydantic.validators import _VALIDATORS
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name '_VALIDATORS' from 'pydantic.validators' (/Users/weissl/.pyenv/versions/stage-ingest/lib/python3.11/site-packages/pydantic/validators.py)

Which indicates the pydantic.validators package is available in pydantic V1 and not V2

And the member _VALIDATORS is not migrated to V2

I think the only option currently is to use pydantic V1

tefra commented 7 months ago

see #23 for pydantic v2 support, I will publish a new release, for anyone still using this library