cmake: Introduce WITH_PYTHON build option #31669

pull hebasto wants to merge 1 commits into bitcoin:master from hebasto:250116-python changing 1 files +11 −10
  1. hebasto commented at 9:29 am on January 16, 2025: member

    This was suggested in #31476 (comment):

    An alternative would be to require python to be disabled explicitly. Otherwise, it seems odd that every setting in cmake has a static default that can only be overridden explicitly, except for some, which are silently downgraded?

    This PR updates the build system to fail by default on systems where the minimum required Python version is unavailable. It introduces an option that allows users to explicitly disable the Python requirement.

  2. DrahtBot commented at 9:29 am on January 16, 2025: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/31669.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    Concept NACK fanquake

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #31233 (cmake: Improve robustness and usability by hebasto)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  3. DrahtBot added the label Build system on Jan 16, 2025
  4. hebasto force-pushed on Jan 16, 2025
  5. hebasto force-pushed on Jan 16, 2025
  6. hebasto added this to the milestone 29.0 on Jan 16, 2025
  7. fanquake commented at 10:03 am on January 16, 2025: member

    Not sure. Why does this need another build option? Given that this is just for working around silent CMake warnings in the CI, couldn’t this just be fixed by using explicit *_TEST options that otherwise fail if Python is missing?

    It also doesn’t solve #31476 generically, because every time a similar case comes up, we’ll have to add even more code and/or options.

  8. maflcko commented at 1:25 pm on January 16, 2025: member
    Yeah, I suggested this for reasons other than the CI fix, because it could be useful outside the CI as well. But no strong opinion.
  9. DrahtBot added the label Needs rebase on Jan 17, 2025
  10. hebasto force-pushed on Jan 17, 2025
  11. hebasto commented at 1:21 pm on January 17, 2025: member
    Rebased due to the conflict with the merged #31651.
  12. fanquake commented at 1:21 pm on January 17, 2025: member
    NACK - based on the reasoning above.
  13. hebasto commented at 1:25 pm on January 17, 2025: member

    NACK - based on the reasoning above.

    Not sure. Why does this need another build option? Given that this is just for working around silent CMake warnings in the CI, couldn’t this just be fixed by using explicit *_TEST options that otherwise fail if Python is missing?

    What “explicit *_TEST options” do you mean?

  14. fanquake commented at 1:35 pm on January 17, 2025: member

    What “explicit *_TEST” do you mean?

    (Introducing) An option that does anything test related, that also requires Python, but I don’t think this solution is better than #31665, because it forces builders to start opting out of things, and doesn’t solve #31476 generically, compared to #31665.

  15. DrahtBot removed the label Needs rebase on Jan 17, 2025
  16. fanquake removed this from the milestone 29.0 on Jan 20, 2025
  17. DrahtBot added the label Needs rebase on Jan 20, 2025
  18. hebasto force-pushed on Feb 6, 2025
  19. DrahtBot removed the label Needs rebase on Feb 6, 2025
  20. DrahtBot added the label Needs rebase on Feb 14, 2025
  21. cmake: Introduce `WITH_PYTHON` build option
    By default, the build system generation will fail on systems where the
    minimum required Python version is unavailable. This option allows
    users to explicitly disable the Python requirement.
    5155dbd5f8
  22. hebasto force-pushed on Feb 16, 2025
  23. DrahtBot added the label CI failed on Feb 16, 2025
  24. DrahtBot removed the label Needs rebase on Feb 16, 2025
  25. in CMakeLists.txt:567 in 5155dbd5f8
    571+  set(Python3_FIND_UNVERSIONED_NAMES FIRST CACHE STRING "")
    572+  mark_as_advanced(Python3_FIND_FRAMEWORK Python3_FIND_UNVERSIONED_NAMES)
    573+  find_package(Python3 3.10 REQUIRED COMPONENTS Interpreter)
    574   set(PYTHON_COMMAND ${Python3_EXECUTABLE})
    575 else()
    576   list(APPEND configure_warnings
    


    maflcko commented at 7:16 am on February 17, 2025:
    shouldn’t this be an error now?

    hebasto commented at 11:59 am on February 17, 2025:

    shouldn’t this be an error now?

    Why? It precisely mirrors the scenario “I don’t have python and I don’t care about the tests” and simply serves as a reminder to the user of the consequences:

     0$ cmake -B build -DWITH_PYTHON=OFF
     1...
     2Use ccache for compiling .............. ON
     3
     4
     5  ******
     6
     7CMake Warning at CMakeLists.txt:680 (message):
     8  Utils and rpcauth tests are disabled.
     9
    10  Use "-DWITH_PYTHON=ON" to enable them.
    11
    12
    13  ******
    14
    15-- Configuring done (12.8s)
    16-- Generating done (0.0s)
    17-- Build files have been written to: /home/hebasto/dev/bitcoin/build
    

    An error happens when WITH_PYTHON=ON is set, which is the default, but Python has not been found.


    maflcko commented at 12:26 pm on February 17, 2025:

    I see. I guess I wanted to say the opposite: Can’t this be removed, because it seems a bit odd to print a warning that something is disabled, when the users explicitly asked it to be disabled? There is also no warning when a user sets BUILD_TESTS=OFF.

    Another alternative would be to just require python3, without a way to disable it. Thus, the option WITH_PYTHON can be removed.

    I am just wondering: Was there ever a single user (compiling from source) to ask for the python dependency to be optional, or can such a user practically exist? Normally, when compiling from source, someone should at a minimum run all tests. Also, python is so widely packaged, that installing it to compile Bitcoin Core should not be an obstacle?

  26. maflcko approved
  27. maflcko commented at 7:17 am on February 17, 2025: member
    lgtm. Seems fine to add an option to say “I don’t have python and I don’t care about the tests”
  28. DrahtBot removed the label CI failed on Feb 17, 2025
  29. hebasto closed this on Feb 17, 2025


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-02-22 06:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me