raysect / source

The main source repository for the Raysect project.
http://www.raysect.org
BSD 3-Clause "New" or "Revised" License
89 stars 23 forks source link

Can't install raysect on mac #432

Open khowarthCFS opened 4 months ago

khowarthCFS commented 4 months ago

Hello,

I have found that I am unable to install raysect on my M3 Mac. As a minimum reproducible example, here is my pyproject.toml file contents:

[tool.poetry]
name = "test"
version = "0.1.0"
description = ""
authors = ["..."]
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.11"
raysect = "0.7.1"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

Running poetry install gives:

 % poetry install  
Updating dependencies
Resolving dependencies... (0.2s)

Package operations: 1 install, 0 updates, 0 removals

  - Installing raysect (0.7.1): Failed

  ChefBuildError

  Backend subprocess exited when trying to invoke get_requires_for_build_wheel

  Traceback (most recent call last):
    File "/opt/homebrew/Cellar/poetry/1.8.2_2/libexec/lib/python3.12/site-packages/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
      main()
    File "/opt/homebrew/Cellar/poetry/1.8.2_2/libexec/lib/python3.12/site-packages/pyproject_hooks/_in_process/_in_process.py", line 335, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/opt/homebrew/Cellar/poetry/1.8.2_2/libexec/lib/python3.12/site-packages/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
      return hook(config_settings)
             ^^^^^^^^^^^^^^^^^^^^^
    File "/var/folders/qt/hq_97ghj60v2p_jyy6p_jl6c0000gp/T/tmprjiyo0jf/.venv/lib/python3.12/site-packages/setuptools/build_meta.py", line 327, in get_requires_for_build_wheel
      return self._get_build_requires(config_settings, requirements=[])
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/var/folders/qt/hq_97ghj60v2p_jyy6p_jl6c0000gp/T/tmprjiyo0jf/.venv/lib/python3.12/site-packages/setuptools/build_meta.py", line 297, in _get_build_requires
      self.run_setup()
    File "/var/folders/qt/hq_97ghj60v2p_jyy6p_jl6c0000gp/T/tmprjiyo0jf/.venv/lib/python3.12/site-packages/setuptools/build_meta.py", line 497, in run_setup
      super().run_setup(setup_script=setup_script)
    File "/var/folders/qt/hq_97ghj60v2p_jyy6p_jl6c0000gp/T/tmprjiyo0jf/.venv/lib/python3.12/site-packages/setuptools/build_meta.py", line 313, in run_setup
      exec(code, locals())
    File "<string>", line 3, in <module>
  ModuleNotFoundError: No module named 'numpy'

  at /opt/homebrew/Cellar/poetry/1.8.2_2/libexec/lib/python3.12/site-packages/poetry/installation/chef.py:164 in _prepare
      160│ 
      161│                 error = ChefBuildError("\n\n".join(message_parts))
      162│ 
      163│             if error is not None:
    → 164│                 raise error from None
      165│ 
      166│             return path
      167│ 
      168│     def _prepare_sdist(self, archive: Path, destination: Path | None = None) -> Path:

Note: This error originates from the build backend, and is likely not a problem with poetry but with raysect (0.7.1) not supporting PEP 517 builds. You can verify this by running 'pip wheel --no-cache-dir --use-pep517 "raysect (==0.7.1)"'.

I am on poetry version 1.8.2.

Running the command given in the error message (pip wheel --no-cache-dir --use-pep517 "raysect (==0.7.1)") also gives the same error.

I do have numpy installed:

% pip list numpy                                
Package Version
------- -------
numpy   1.26.2
pip     24.0

Even from within the poetry environment numpy is installed:

% poetry run pip list
Package                Version
---------------------- -----------
contourpy              1.2.1
cycler                 0.12.1
Cython                 3.0.10
fonttools              4.53.1
kiwisolver             1.4.5
matplotlib             3.9.1
numpy                  2.0.0
oldest-supported-numpy 2023.12.21
packaging              24.1
pillow                 10.4.0
pip                    24.0
pyparsing              3.1.2
python-dateutil        2.9.0.post0
six                    1.16.0

Appreciate any advice!

vsnever commented 4 months ago

Hello, @khowarthCFS

Raysect 0.7.1 does not include pyproject.toml. The file was added later in version 0.8.1. So pip uses the legacy setup.py install method, but setup.py itself requires numpy and Cython pre-installed. I successfully installed Raysect 0.7.1. to an empty virtual environment (also on Mac) by preinstalling both NumPy 1.26 and Cython 0.29:

pip install "numpy<2"
pip install "cython<3"
pip install raysect==0.7.1