scikit-build / cmake-python-distributions

This project provides the infrastructure to build CMake Python wheels.
https://cmake-python-distributions.readthedocs.io
Apache License 2.0
112 stars 34 forks source link

There should be a cmake option to use pre-installed cmake #511

Open yurivict opened 3 months ago

yurivict commented 3 months ago

We already have cmake on FreeBSD. Installing cmake againhas these problems:

  1. It causes conflicts withe cmake package
  2. It wastes CPU to build cmake when it is already present.

Please add a cmake option, for example USE_EXTERNAL_CMAKE, that would just launch 'cmake' assuming that it already installed.

henryiii commented 3 months ago

Could you guarantee that the CMake version exactly matched the package version? How would you ensure that someone wouldn't try to distribute this "empty" wheel? Or that they versions would continue to be in sync, what if you update the system cmake but not this "empty" package?

Opt-in isn't as bad, but it's still problematic. And it's the wrong solution.

The correct solution is simple: don't request the cmake PyPI package if you already have provided CMake via a different mechanism. You wouldn't ask for conda-forge metadata to be included in FreeBSD, so why ask for PyPI metadata?

If it's because people are putting "cmake" in build-system.requires. then just disable verification. And request that they use a proper system like scikit-build-core or a wrapper around get_requries_for_build_wheel that checks for a system cmake before requesting PyPI cmake.

And this is a duplicate of #80.

LecrisUT commented 1 month ago

Other Fedora packagers would still want to investigate packaging python-cmake proper, so I've investigated this approach. Here is what I've tried to implement:

I am not convinced if this is a good approach, so I will keep it open for review. Technically speaking, this still works on Fedora side because the python3dist(*) is populated from the pyproject.toml metadata that is patched to be in sync with the installed CMake

$ rpm -q --provides python3-cmake-3.30.2-1.fc42.noarch.rpm 
python-cmake = 3.30.2-1.fc42
python3-cmake = 3.30.2-1.fc42
python3.13-cmake = 3.30.2-1.fc42
python3.13dist(cmake) = 3.28.3
python3dist(cmake) = 3.28.3

and this resolves rebuild burden when python files are changed and the discrepancy in the version of cmake and python-cmake. But still I am not sure that we are not overlooking something in this approach, so feel free to comment on this.

You can check the spec and srpm for the patch and steps above. I am not sure how readily the srpm can be decompressed on non-linux systems, but I am able to simply open it with Ark (KDE archive manager) and I can navigate the files within, and similary for the final binary rpm.

henryiii commented 1 month ago

As a maintainer of this package, I strongly advise against this. This has come up numerous times, and the answer has always been redistributing a redistribution is wrong. See the extensive discussions on the ninja redistribution at https://github.com/scikit-build/ninja-python-distributions/issues/127 for more context. A few quick points:

LecrisUT commented 1 month ago

I'm all up for recommending downstream distros against packaging this, and I try to link the conversations back-and-forth on this topic. This part came up on the matrix channel w.r.t. to the topic of "But wouldn't packaging the python files be a good enough solution", so I've done it in a way that would take into consideration as many nuances as possible so that most topics can be explored. Try to bear with it a little longer.

It creates links between the cmake package and the various Python packages those provide.

Indeed I believe that is generally a problem. In Fedora there is only one python version for packages, so technically that is not a concern, but I also don't like it because it triggers unnecessary rebuildsdown the chain. How I've tried to address this is to keep cmake and python-cmake as completely independent packages, except for the python-cmake being dependent on cmake and it masking the python metadata version with the imported cmake ones (the python3dist in the snippet of my last comment).

This should not be done for every package that has a PyPI redistribution - and there are a lot of them!

Agreed, and in most cases it is even not possible to do so. We do agree that creating the metadata package was unnecessary, and it will likely not happen for other such packages.

If we made a change for cmake 3.21.3, then a user of this package should be able to rely on that change happening in 3.21.3.

Understandable, I mostly wanted to show the workflow and how the versioning works. If it were in production the versioning dependency would be inverted, i.e. python-cmake == cmake (i.e. we download the source of python-cmake that matches current cmake version), except for the additional patch versions in python-cmake, and if rc cmake lands in Fedora, than python-cmake will pretend to be that higher version since pypi version does not distribute it.

don't validate build-system.requires!

That we can't do, because it we use it to dynamically import the distro package dependencies. Instead what should be done is to just patch out the requirement from pyproject.toml.

This will hurt efforts to standardize declaring system dependencies in Python, namely PEP 725. This is trying to add a way to describe these sorts of dependencies.

Perfect point, hopefully this would be a convincing argument for removing the current fake package. Also I believe there are no voices from Fedora packagers on that thread? I will try to get some people to chime in on that one.