gvtulder / elasticdeform

Differentiable elastic deformations for N-dimensional images (Python, SciPy, NumPy, TensorFlow, PyTorch).
Other
186 stars 25 forks source link

Handle __builtins__ of type dict #20

Closed gfringeli closed 5 months ago

gfringeli commented 5 months ago

Resolves issue with installing elasticdeform via poetry with Python 3.11.9.

Issue description Environment: python:3.11.9-slim docker container (Debian) Running poetry install for a project that requires elasticdeform (5.0.0) results in the following error message

104.5   ChefBuildError
104.5 
104.5   Backend subprocess exited when trying to invoke build_wheel
104.5   
104.5   running bdist_wheel
104.5   running build
104.5   running build_py
104.5   creating build
104.5   creating build/lib.linux-aarch64-cpython-311
104.5   creating build/lib.linux-aarch64-cpython-311/elasticdeform
104.5   copying elasticdeform/deform_grid.py -> build/lib.linux-aarch64-cpython-311/elasticdeform
104.5   copying elasticdeform/torch.py -> build/lib.linux-aarch64-cpython-311/elasticdeform
104.5   copying elasticdeform/__init__.py -> build/lib.linux-aarch64-cpython-311/elasticdeform
104.5   copying elasticdeform/tf.py -> build/lib.linux-aarch64-cpython-311/elasticdeform
104.5   running build_ext
104.5   Traceback (most recent call last):
104.5     File "/opt/poetry/venv/lib/python3.11/site-packages/pyproject_hooks/_in_process/_in_process.py", line 373, in <module>
104.5       main()
104.5     File "/opt/poetry/venv/lib/python3.11/site-packages/pyproject_hooks/_in_process/_in_process.py", line 357, in main
104.5       json_out["return_val"] = hook(**hook_input["kwargs"])
104.5                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
104.5     File "/opt/poetry/venv/lib/python3.11/site-packages/pyproject_hooks/_in_process/_in_process.py", line 271, in build_wheel
104.5       return _build_backend().build_wheel(
104.5              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
104.5     File "/tmp/tmp9be19hcv/.venv/lib/python3.11/site-packages/setuptools/build_meta.py", line 410, in build_wheel
104.5       return self._build_with_temp_dir(
104.5              ^^^^^^^^^^^^^^^^^^^^^^^^^^
104.5     File "/tmp/tmp9be19hcv/.venv/lib/python3.11/site-packages/setuptools/build_meta.py", line 395, in _build_with_temp_dir
104.5       self.run_setup()
104.5     File "/tmp/tmp9be19hcv/.venv/lib/python3.11/site-packages/setuptools/build_meta.py", line 487, in run_setup
104.5       super().run_setup(setup_script=setup_script)
104.5     File "/tmp/tmp9be19hcv/.venv/lib/python3.11/site-packages/setuptools/build_meta.py", line 311, in run_setup
104.5       exec(code, locals())
104.5     File "<string>", line 16, in <module>
104.5     File "/tmp/tmp9be19hcv/.venv/lib/python3.11/site-packages/setuptools/__init__.py", line 103, in setup
104.5       return distutils.core.setup(**attrs)
104.5              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
104.5     File "/tmp/tmp9be19hcv/.venv/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 184, in setup
104.5       return run_commands(dist)
104.5              ^^^^^^^^^^^^^^^^^^
104.5     File "/tmp/tmp9be19hcv/.venv/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 200, in run_commands
104.5       dist.run_commands()
104.5     File "/tmp/tmp9be19hcv/.venv/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands
104.5       self.run_command(cmd)
104.5     File "/tmp/tmp9be19hcv/.venv/lib/python3.11/site-packages/setuptools/dist.py", line 968, in run_command
104.5       super().run_command(command)
104.5     File "/tmp/tmp9be19hcv/.venv/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
104.5       cmd_obj.run()
104.5     File "/tmp/tmp9be19hcv/.venv/lib/python3.11/site-packages/wheel/bdist_wheel.py", line 368, in run
104.5       self.run_command("build")
104.5     File "/tmp/tmp9be19hcv/.venv/lib/python3.11/site-packages/setuptools/_distutils/cmd.py", line 316, in run_command
104.5       self.distribution.run_command(command)
104.5     File "/tmp/tmp9be19hcv/.venv/lib/python3.11/site-packages/setuptools/dist.py", line 968, in run_command
104.5       super().run_command(command)
104.5     File "/tmp/tmp9be19hcv/.venv/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
104.5       cmd_obj.run()
104.5     File "/tmp/tmp9be19hcv/.venv/lib/python3.11/site-packages/setuptools/_distutils/command/build.py", line 132, in run
104.5       self.run_command(cmd_name)
104.5     File "/tmp/tmp9be19hcv/.venv/lib/python3.11/site-packages/setuptools/_distutils/cmd.py", line 316, in run_command
104.5       self.distribution.run_command(command)
104.5     File "/tmp/tmp9be19hcv/.venv/lib/python3.11/site-packages/setuptools/dist.py", line 968, in run_command
104.5       super().run_command(command)
104.5     File "/tmp/tmp9be19hcv/.venv/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 987, in run_command
104.5       cmd_obj.ensure_finalized()
104.5     File "/tmp/tmp9be19hcv/.venv/lib/python3.11/site-packages/setuptools/_distutils/cmd.py", line 111, in ensure_finalized
104.5       self.finalize_options()
104.5     File "<string>", line 9, in finalize_options
104.5   AttributeError: 'dict' object has no attribute '__NUMPY_SETUP__'
104.5   
104.5 
104.5   at /opt/poetry/venv/lib/python3.11/site-packages/poetry/installation/chef.py:164 in _prepare
104.5       160│ 
104.5       161│                 error = ChefBuildError("\n\n".join(message_parts))
104.5       162│ 
104.5       163│             if error is not None:
104.5     → 164│                 raise error from None
104.5       165│ 
104.5       166│             return path
104.5       167│ 
104.5       168│     def _prepare_sdist(self, archive: Path, destination: Path | None = None) -> Path:
104.5 
104.5 Note: This error originates from the build backend, and is likely not a problem with poetry but with elasticdeform (0.5.0) not supporting PEP 517 builds. You can verify this by running 'pip wheel --no-cache-dir --use-pep517 "elasticdeform (==0.5.0)"'.

See https://github.com/SciTools/cf-units/pull/153 for a reference of an equivalent solution for the same problem.

gvtulder commented 5 months ago

Thanks!

gfringeli commented 5 months ago

Thanks to you!