scikit-hep / iminuit

Jupyter-friendly Python interface for C++ MINUIT2
https://scikit-hep.org/iminuit
Other
285 stars 77 forks source link

`iminuit` fails to build because of `cmake-python-distributions` build dependency #813

Closed nega0 closed 1 year ago

nega0 commented 1 year ago

See scikit-build/cmake-python-distributions#324 which has my example of trying to install iminuit.

The short story is pip install iminuit fails when to build when there's a lack of wheels. It seems the cmake "binary" from cmake-python-distributions fails to import its module, causing the whole build to fail.

When "globally" installing cmake-python-distributions the build works fine, but then you have this problem, cmake-python-distributions/#80 (ie. c-p-d will overwrite CMake binaries).

When doing pip wheel . things obviously fail in the same way. I deleted the cmake dependency in pyproject.toml and relying on the system cmake things built as expected.

HDembinski commented 1 year ago

I answered you in scikit-build/cmake-python-distributions#324, I cannot reproduce this, it is probably an issue with your installation.

You can use your own cmake installation without delete cmake from pyproject.toml. Download the iminuit source, then go to the project folder and do pip install --no-build-isolation .. This will use whatever cmake you have already installed. You also need to install wheel and numpy.

nega0 commented 1 year ago

Yes Hans I'm quite aware of how to build python packages from source, thank you. It certainly doesn't help with pip install -r requirements.txt though.

Since this does seem to be a specific issue with Homebrew's python and no virtual environment, it can be addressed on my end with some user-facing documentation. To head off future issues, it may be helpful to update yours as well.

HDembinski commented 1 year ago

I see the problem with pip install -r requirements.txt.

henryiii commented 1 year ago

There are several problems here.

  1. Pip isolated builds outside of a virtual environment are busted on homebrew with Python 3.10 and 3.11. It's been fixed in pip's main branch, but there hasn't been a release yet. This is true for all packages - flit, hatchling, poetry, meson-python, scikit-build, cmake, ninja, everything. It just happens that virtual environments have setuptools pre-installed when they are created (historical oddity that will eventually be removed), so that one dependency is okay, making it look like it's the fault of the others. Current workaround: use a venv, python@3.9, or avoid source builds.
  2. iMinuit doesn't seem to provide ARM or universal wheels for Python 3.11. Not sure why yet, but I'm guessing you are on Apple Silicon and using Python 3.11.
  3. Older versions of Pip didn't handle universal tags correctly. If you are not on 3.11 + ARM, it's possible you are using an old version of Pip. This is much less likely than problem 2 though. I have a retagging feature in PR for wheel, and scikit-build-core has an option to do this automatically.

I think we need to ship 3.11 ARM or Universal wheels. We should not be building from source on macOS! I just got back from vacation, and just got a new Windows ARM dev kit today, so I'm hoping to add Windows ARM support to all the Scikit-HEP projects very soon. Cibuildwheel has supported cross compiling for a couple of releases now courtesy of a CPython core dev at Microsoft, but I didn't have a way to verify the wheels worked until today.

HDembinski commented 1 year ago

iMinuit doesn't seem to provide ARM or universal wheels for Python 3.11. Not sure why yet, but I'm guessing you are on Apple Silicon and using Python 3.11.

An oversight, universal wheels are now in v2.18.0.

HDembinski commented 1 year ago

My understanding is that OPs issue is not an issue that can be fixed in iminuit (regarding the build from source). The missing universal wheel was provided, so I am closing this. Please reopen if the problem persists.