ismrmrd / ismrmrd-python

Python API for the ISMRMRD file format
Other
51 stars 27 forks source link

Incompatibility with xsdata >=23 #71

Open kspaceKelvin opened 8 months ago

kspaceKelvin commented 8 months ago

xsdata version >= 23 seems to be incompatible with error:

× Building wheel for ismrmrd (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [5 lines of output]
      INFO:root:running bdist_wheel
      INFO:root:running build
      INFO:root:running build_py
      Install cli requirements "pip install xsdata[cli]"
      error: [Errno 2] No such file or directory: 'ismrmrdschema/__init__.py'
      [end of output]

meta.yaml is temporarily modified to limit the version in #70 until a proper fix is made.

gabuzi commented 6 months ago

The conda-forge package 1.14.0 build 0 suffers from probably a related error. Header.to_XML() fails.

Trying to fix the package constraints on conda-forge, I noticed rather curious behavior.

Building the package fails with xsdata <23 (e.g. 22.12) with the same error as stated above, but oddly it fails with the old versions of xsdata, and newers work fine.

Error building conda-forge pkg with xsdata 22.12 ``` Building wheels for collected packages: ismrmrd Created temporary directory: /private/tmp/pip-wheel-c9_xhzq6 Destination directory: /private/tmp/pip-wheel-c9_xhzq6 Building wheel for ismrmrd (pyproject.toml): started Running command Building wheel for ismrmrd (pyproject.toml) INFO:root:running bdist_wheel INFO:root:running build INFO:root:running build_py Install cli requirements "pip install xsdata[cli]" error: [Errno 2] No such file or directory: 'ismrmrdschema/__init__.py' error: subprocess-exited-with-error × Building wheel for ismrmrd (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> See above for output. note: This error originates from a subprocess, and is likely not a problem with pip. full command: /opt/homebrew/Caskroom/miniconda/base/conda-bld/ismrmrd-python_1712836032761/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_p/bin/python /opt/homebrew/Caskroom/miniconda/base/conda-bld/ismrmrd-python_1712836032761/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_p/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py build_wheel /tmp/tmpl4odyb24 cwd: /opt/homebrew/Caskroom/miniconda/base/conda-bld/ismrmrd-python_1712836032761/work Building wheel for ismrmrd (pyproject.toml): finished with status 'error' ERROR: Failed building wheel for ismrmrd Failed to build ismrmrd ERROR: Could not build wheels for ismrmrd, which is required to install pyproject.toml-based projects Exception information: Traceback (most recent call last): File "$PREFIX/lib/python3.11/site-packages/pip/_internal/cli/base_command.py", line 180, in exc_logging_wrapper status = run_func(*args) ^^^^^^^^^^^^^^^ File "$PREFIX/lib/python3.11/site-packages/pip/_internal/cli/req_command.py", line 245, in wrapper return func(self, options, args) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "$PREFIX/lib/python3.11/site-packages/pip/_internal/commands/install.py", line 429, in run raise InstallationError( pip._internal.exceptions.InstallationError: Could not build wheels for ismrmrd, which is required to install pyproject.toml-based projects Removed build tracker: '/private/tmp/pip-build-tracker-0dtc1puw' # >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<< ```

But building with xsdata 23.8 and 24.4 both works fine.

However, running the package and tests only works with 22.12 and 23.8. Running test suite with 24.4 fails serializing XML.

Error running tests for conda-forge pkg with xsdata 24.4 ``` ====================================================================== ERROR: test_file.test_file_can_read_and_write_headers ---------------------------------------------------------------------- Traceback (most recent call last): {% set name = "ismrmrd-python" %} File "/opt/homebrew/Caskroom/miniconda/base/conda-bld/ismrmrd-python_1712835503884/_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeh/lib/python3.11/site-packages/nose/case.py", line 197, in runTest self.test(*self.arg) File "/opt/homebrew/Caskroom/miniconda/base/conda-bld/ismrmrd-python_1712835503884/test_tmp/tests/test_file.py", line 451, in test_file_can_read_and_write_headers dataset.header = header ^^^^^^^^^^^^^^ File "/opt/homebrew/Caskroom/miniconda/base/conda-bld/ismrmrd-python_1712835503884/_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeh/lib/python3.11/site-packages/ismrmrd/file.py", line 331, in __set_header self._contents['xml'][0] = ToXML(header) ^^^^^^^^^^^^^ File "/opt/homebrew/Caskroom/miniconda/base/conda-bld/ismrmrd-python_1712835503884/_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeh/lib/python3.11/site-packages/ismrmrd/xsd/pyxb_compat.py", line 20, in ToXML return serializer.render(header,ns_map={"":"http://www.ismrm.org/ISMRMRD"}) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Caskroom/miniconda/base/conda-bld/ismrmrd-python_1712835503884/_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeh/lib/python3.11/site-packages/xsdata/formats/dataclass/serializers/xml.py", line 42, in render self.write(output, obj, ns_map) File "/opt/homebrew/Caskroom/miniconda/base/conda-bld/ismrmrd-python_1712835503884/_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeh/lib/python3.11/site-packages/xsdata/formats/dataclass/serializers/xml.py", line 59, in write handler.write(events) File "/opt/homebrew/Caskroom/miniconda/base/conda-bld/ismrmrd-python_1712835503884/_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeh/lib/python3.11/site-packages/xsdata/formats/dataclass/serializers/writers/lxml.py", line 51, in write super().write(events) File "/opt/homebrew/Caskroom/miniconda/base/conda-bld/ismrmrd-python_1712835503884/_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeh/lib/python3.11/site-packages/xsdata/formats/dataclass/serializers/mixins.py", line 138, in write for name, *args in events: File "/opt/homebrew/Caskroom/miniconda/base/conda-bld/ismrmrd-python_1712835503884/_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeh/lib/python3.11/site-packages/xsdata/formats/dataclass/serializers/mixins.py", line 366, in generate if isinstance(obj, self.context.class_type.derived_element): ^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'SerializerConfig' object has no attribute 'class_type' ---------------------------------------------------------------------- ```

The build error is puzzling to me, and it could be due to some unfortunate interaction with build dependencies between conda and pip.

I have fixed the dependency versions for the conda-forge package and created a fixed build (see https://github.com/conda-forge/ismrmrd-python-feedstock/pull/1). While the running with xsdata 23 seems to work for the conda-forge package, I constrained it to < 23 to be consistent with the change in #70.

dchansen commented 6 months ago

Fixed in #73