ci: Build python from source in “lint” task #26716

pull hebasto wants to merge 2 commits into bitcoin:master from hebasto:221217-pyenv changing 2 files +24 −10
  1. hebasto commented at 1:39 pm on December 17, 2022: member

    This PR:

    • is an alternative to bitcoin/bitcoin#26581 and bitcoin/bitcoin#26637
    • closes bitcoin/bitcoin#26548

    Key advantages of this PR over others:

    • it uses pyenv’s python-build standalone
    • requires no additional computational resources

    Note for testing. The lint task must success regardless of whether the python_cache is populated or invalidated.

  2. DrahtBot commented at 1:39 pm on December 17, 2022: contributor

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

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK fanquake, MarcoFalke

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

    Conflicts

    No conflicts as of last run.

  3. DrahtBot added the label Tests on Dec 17, 2022
  4. fanquake commented at 2:16 pm on December 17, 2022: member

    it uses pyenv’s python-build standalone; no other tools required

    As far as I can tell, pyenv install is just a wrapper around python-build. You still need the same tools (compiler / linker / all the python build dependencies) to compile Python regardless of how you compile it. I guess the difference here is just not fully installing pyenv?

    requires no additional computational resources

    GIven that pyenv install and python-build are the same thing, why is there a difference in computational resources required?

  5. in ci/lint/04_install.sh:20 in 4184ad4852 outdated
    22+  (
    23+    git clone https://github.com/pyenv/pyenv.git
    24+    cd pyenv/plugins/python-build || exit 1
    25+    ./install.sh
    26+  )
    27+  ${CI_RETRY_EXE} apt-get install -y build-essential clang libbz2-dev liblzma-dev libncursesw5-dev libreadline-dev libssl-dev libsqlite3-dev zlib1g-dev
    


    maflcko commented at 2:50 pm on December 17, 2022:
    might be nice to add a comment where the deps are copy-pasted from

    hebasto commented at 3:46 pm on December 17, 2022:
    Added.
  6. hebasto force-pushed on Dec 17, 2022
  7. hebasto commented at 3:45 pm on December 17, 2022: member

    it uses pyenv’s python-build standalone; no other tools required

    As far as I can tell, pyenv install is just a wrapper around python-build. You still need the same tools (compiler / linker / all the python build dependencies) to compile Python regardless of how you compile it. I guess the difference here is just not fully installing pyenv?

    Correct. Dropped “no other tools required” from the PR description.

    requires no additional computational resources

    GIven that pyenv install and python-build are the same thing, why is there a difference in computational resources required?

    I reckon the lower memory usage is due to using clang instead of gcc.

  8. in .cirrus.yml:78 in 3f602a628b outdated
    75   # For faster CI feedback, immediately schedule the linters
    76   << : *CREDITS_TEMPLATE
    77+  python_cache:
    78+    folder: "/tmp/python"
    79+    fingerprint_script: cat .python-version /etc/os-release
    80+    populate_script: rm -rf /tmp/python
    


    maflcko commented at 12:15 pm on January 9, 2023:
    Is this needed? (If yes, would be good to add a comment, e.g. “Needed by python-build”)

    hebasto commented at 10:59 am on January 14, 2023:

    Is this needed?

    No, it is not. Dropped.

  9. hebasto force-pushed on Jan 14, 2023
  10. hebasto commented at 10:58 am on January 14, 2023: member

    Updated 3f602a628bdb8007c2ebebe58c10f42db787679f -> f99260fdd02453649222bfe4d38d0655ebdbc42c (pr26716.02 -> pr26716.03, diff):

  11. in ci/lint/04_install.sh:20 in f99260fdd0 outdated
    23+    git clone https://github.com/pyenv/pyenv.git
    24+    cd pyenv/plugins/python-build || exit 1
    25+    ./install.sh
    26+  )
    27+  # For dependencies see https://github.com/pyenv/pyenv/wiki#suggested-build-environment
    28+  ${CI_RETRY_EXE} apt-get install -y build-essential clang libbz2-dev liblzma-dev libncursesw5-dev libreadline-dev libssl-dev libsqlite3-dev zlib1g-dev
    


    maflcko commented at 10:06 am on January 16, 2023:
    It doesn’t look like this list is copied from the above link, why?

    maflcko commented at 10:07 am on January 16, 2023:
    Also, it shouldn’t hurt to duplicate xz-utils and curl here for clarity

    hebasto commented at 10:59 am on January 16, 2023:
    Thanks! Updated.
  12. hebasto force-pushed on Jan 16, 2023
  13. hebasto force-pushed on Jan 16, 2023
  14. hebasto commented at 10:59 am on January 16, 2023: member

    Updated f99260fdd02453649222bfe4d38d0655ebdbc42c -> d418803a6a60bfb0d51ed5deb658ffd7639f31d5 (pr26716.03 -> pr26716.05, diff):

  15. hebasto commented at 11:07 am on January 16, 2023: member

    CI tasks with the python cache being:

  16. ci: Use pyenv's `python-build` to install Python in lint task 9b86114058
  17. ci: Bump lint task image to Ubuntu Jammy 123043e99c
  18. in ci/lint/04_install.sh:23 in d418803a6a outdated
    17@@ -18,22 +18,15 @@ if [ ! -d "${PYTHON_PATH}/bin" ]; then
    18   )
    19   # For dependencies see https://github.com/pyenv/pyenv/wiki#suggested-build-environment
    20   ${CI_RETRY_EXE} apt-get install -y build-essential libssl-dev zlib1g-dev \
    21-    libbz2-dev libreadline-dev libsqlite3-dev curl llvm \
    22+    libbz2-dev libreadline-dev libsqlite3-dev curl clang llvm \
    23     libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
    24-  python-build "$(cat "${BASE_ROOT_DIR}/.python-version")" "${PYTHON_PATH}"
    25+  # Using clang to workaround https://github.com/pyenv/pyenv/issues/2359.
    


    fanquake commented at 11:09 am on January 16, 2023:
    How/why does using Clang solve the segmentation fault issue? Also seems unecessary to put this in the second commit, instead of the first.

    hebasto commented at 11:12 am on January 16, 2023:

    How/why does using Clang solve the segmentation fault issue?

    I have no answers, unfortunately. FWIW, #26418 (review).

    Also seems unecessary to put this in the second commit, instead of the first.

    There were no problems with gcc on bionic.


    fanquake commented at 11:28 am on January 16, 2023:

    I have no answers, unfortunately.

    Well linking to this thread, that doesn’t explain anything, and just has a comment with a link to a comment in a different thread, where someone claimed that using Clang magically solved their problem, is more confusing than useful.


    maflcko commented at 11:30 am on January 16, 2023:
    Presumably a gcc compiler bug?

    hebasto commented at 11:44 am on January 16, 2023:

    Presumably a gcc compiler bug?

    Perhaps. But do we really want to dig into gcc bugtracker for the sake of building an old python?


    maflcko commented at 12:54 pm on January 16, 2023:
    We’ll need clang either way, because it uses less memory

    hebasto commented at 1:00 pm on January 16, 2023:

    Does this comment look good

    0# Using clang for less memory footprint and to workaround https://github.com/pyenv/pyenv/issues/2359.
    

    ?


    fanquake commented at 1:11 pm on January 16, 2023:
    I don’t think there is any value in linking to https://github.com/pyenv/pyenv/issues/2359.

    hebasto commented at 1:31 pm on January 16, 2023:

    Also seems unecessary to put this in the second commit, instead of the first.

    Done.

    I don’t think there is any value in linking to pyenv/pyenv#2359.

    Dropped.

  19. hebasto force-pushed on Jan 16, 2023
  20. hebasto commented at 1:32 pm on January 16, 2023: member

    Updated d418803a6a60bfb0d51ed5deb658ffd7639f31d5 -> 123043e99cf3aab9eef7e381b133477b518ac4d0 (pr26716.05 -> pr26716.06, diff):

  21. fanquake approved
  22. fanquake commented at 2:04 pm on January 17, 2023: member
    ACK 123043e99cf3aab9eef7e381b133477b518ac4d0
  23. in ci/lint/04_install.sh:10 in 123043e99c
    13-  # Can be removed once the underlying image is bumped to something that includes git2.34 or later
    14-  sed -i -e 's/bionic/jammy/g' /etc/apt/sources.list
    15-  ${CI_RETRY_EXE} apt-get update
    16-  ${CI_RETRY_EXE} apt-get install -y --reinstall git
    17-)
    18+${CI_RETRY_EXE} apt-get install -y curl git gawk jq xz-utils
    


    maflcko commented at 4:45 pm on January 17, 2023:
    Why add xz-utils here when it is only needed when compiling python?

  24. maflcko commented at 4:48 pm on January 17, 2023: member
    ACK 123043e99cf3aab9eef7e381b133477b518ac4d0
  25. maflcko approved
  26. maflcko merged this on Jan 17, 2023
  27. maflcko closed this on Jan 17, 2023

  28. hebasto deleted the branch on Jan 17, 2023
  29. jamesob commented at 6:29 pm on January 17, 2023: member

    This change points to the wastefulness of our current CI setup as alluded to in the Cirrus docs:

    image

    On every CI run, we’re doing the same apt installs and Python setup. We should probably just specify a Dockerfile, the resulting image of which can be cached on the Cirrus side. I think that would also simplify CI on our end and make it easier to run locally.

    If there’s interest I can create an issue for this.

  30. sidhujag referenced this in commit c4990322a2 on Jan 17, 2023
  31. maflcko commented at 6:35 pm on January 17, 2023: member

    Yeah, I did this because I want to be able to run the stuff easily locally: https://github.com/bitcoin/bitcoin/tree/master/ci#running-a-stage-locally

    I don’t know enough about docker to figure out if there is a more efficient but equally simply way to do this.

    Overall I am thinking that it shouldn’t matter if we download the packages or download a pod layer with the packages installed. (Modulo a slow mirror, which should ideally be solved by using a fast mirror, but there doesn’t seem to be an easy way to do this? Also modulo the time it takes to run the install script)

  32. bitcoin locked this on Jan 17, 2024

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: 2024-11-17 15:12 UTC

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