Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macOS wheel build fails while repairing wheel with delocate.libsana.DelocationError #28

Closed
matthewfeickert opened this issue Jun 18, 2024 · 8 comments

Comments

@matthewfeickert
Copy link
Contributor

Related to Issues:

During

macos-build:
runs-on: macos-13
needs: [linux-test, macos-test, windows-test]
steps:
- uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Compile and install libomp from source
run: ./scripts/install-libomp-macos.sh
- name: Build wheels and upload to PyPI
run: ./scripts/build-wheels-and-upload.sh

python3 -m cibuildwheel --output-dir wheelhouse

the build fails in the "Repairing wheel" stage with a delocate.libsana.DelocationError

Repairing wheel...
  
  + delocate-wheel --require-archs x86_64 -w /private/var/folders/vy/h7r6h43j203gstfh6fj9_tyh0000gn/T/cibw-run-a9vgw6o1/cp37-macosx_x86_64/repaired_wheel -v /private/var/folders/vy/h7r6h43j203gstfh6fj9_tyh0000gn/T/cibw-run-a9vgw6o1/cp37-macosx_x86_64/built_wheel/Wasserstein-1.1.0-cp37-cp37m-macosx_10_9_x86_64.whl
  INFO:delocate.delocating:Copying library /usr/local/lib/libomp.dylib to wasserstein/.dylibs/libomp.dylib
  INFO:delocate.delocating:Modifying install name in wasserstein/_wasserstein_omp.cpython-37m-darwin.so from @rpath/libomp.dylib to @loader_path/.dylibs/libomp.dylib
  Fixing: /private/var/folders/vy/h7r6h43j203gstfh6fj9_tyh0000gn/T/cibw-run-a9vgw6o1/cp37-macosx_x86_64/built_wheel/Wasserstein-1.1.0-cp37-cp37m-macosx_10_9_x86_64.whl
  Traceback (most recent call last):
    File "/private/var/folders/vy/h7r6h43j203gstfh6fj9_tyh0000gn/T/cibw-run-a9vgw6o1/cp37-macosx_x86_64/build/venv/bin/delocate-wheel", line 8, in <module>
      sys.exit(main())
    File "/private/var/folders/vy/h7r6h43j203gstfh6fj9_tyh0000gn/T/cibw-run-a9vgw6o1/cp37-macosx_x86_64/build/venv/lib/python3.7/site-packages/delocate/cmd/delocate_wheel.py", line 116, in main
      **delocate_values(args),
    File "/private/var/folders/vy/h7r6h43j203gstfh6fj9_tyh0000gn/T/cibw-run-a9vgw6o1/cp37-macosx_x86_64/build/venv/lib/python3.7/site-packages/delocate/delocating.py", line 1005, in delocate_wheel
      out_wheel_, Path(wheel_dir), require_target_macos_version
    File "/private/var/folders/vy/h7r6h43j203gstfh6fj9_tyh0000gn/T/cibw-run-a9vgw6o1/cp37-macosx_x86_64/build/venv/lib/python3.7/site-packages/delocate/delocating.py", line 840, in _check_and_update_wheel_name
      "Library dependencies do not satisfy target MacOS"
  delocate.libsana.DelocationError: Library dependencies do not satisfy target MacOS version 10.9:
  /private/var/folders/vy/h7r6h43j203gstfh6fj9_tyh0000gn/T/tmprdp8i5mn/wheel/wasserstein/.dylibs/libomp.dylib has a minimum target of 13.6
  Error: Command delocate-wheel --require-archs x86_64 -w /private/var/folders/vy/h7r6h43j203gstfh6fj9_tyh0000gn/T/cibw-run-a9vgw6o1/cp37-macosx_x86_64/repaired_wheel -v /private/var/folders/vy/h7r6h43j203gstfh6fj9_tyh0000gn/T/cibw-run-a9vgw6o1/cp37-macosx_x86_64/built_wheel/Wasserstein-1.1.0-cp37-cp37m-macosx_10_9_x86_64.whl failed with code 1. 

so it seems the wrong version of libomp is being found even if running on a branch that follows PR #24.

@matthewfeickert
Copy link
Contributor Author

In PR #24 libomp is built and installed under /usr/local/lib/

[100%] Built target omp
-- Install configuration: "Release"
-- Installing: /usr/local/lib/libomp.dylib
-- Installing: /usr/local/include/omp.h
-- Installing: /usr/local/include/ompx.h
-- Installing: /usr/local/include/omp-tools.h
-- Installing: /usr/local/include/ompt.h

and delocate finds it for the copy in the error message

...
INFO:delocate.delocating:Copying library /usr/local/lib/libomp.dylib to wasserstein/.dylibs/libomp.dylib
...

so I don't follow why

      "Library dependencies do not satisfy target MacOS"
  delocate.libsana.DelocationError: Library dependencies do not satisfy target MacOS version 10.9:
  /private/var/folders/vy/h7r6h43j203gstfh6fj9_tyh0000gn/T/tmprdp8i5mn/wheel/wasserstein/.dylibs/libomp.dylib has a minimum target of 13.6

is happening when the llvm omp should be fine. :?

We might need @henryiii to give a debugging direction hint later this week.

@henryiii
Copy link

Are you setting MACOSX_DEPLOYMENT_TARGET when building?

@matthewfeickert
Copy link
Contributor Author

Are you setting MACOSX_DEPLOYMENT_TARGET when building?

No. I'm going to assume that this is just another example of why

echo "Installing cibuildwheel, twine, and numpy ..."
python3 -m pip install cibuildwheel twine numpy
echo "Building wheels ..."
python3 -m cibuildwheel --output-dir wheelhouse

isn't sufficient and #10 should also include migrating the wheel building to something like boost-histogram's.

@matthewfeickert
Copy link
Contributor Author

I didn't know what MACOSX_DEPLOYMENT_TARGET was, but this is covered in macOS and deployment target versions cibuildwheel docs.

From reading there, my understanding is that the default MACOSX_DEPLOYMENT_TARGET value set by cibuildwheel is 10.9 and you need to manually adjust it through setting the MACOSX_DEPLOYMENT_TARGET based on how far backwards compatible you want to be.

Given that the current build has a comparatively high target of 13.6

      "Library dependencies do not satisfy target MacOS"
  delocate.libsana.DelocationError: Library dependencies do not satisfy target MacOS version 10.9:
  /private/var/folders/vy/h7r6h43j203gstfh6fj9_tyh0000gn/T/tmprdp8i5mn/wheel/wasserstein/.dylibs/libomp.dylib has a minimum target of 13.6

I'm going to assume that means that the version of llvm omp in PR #24 built from

      - name: Checkout LLVM on macOS
        uses: actions/checkout@v4
        with:
          repository: llvm/llvm-project
          ref: release/18.x
          path: llvm-project

      - name: Build OpenMP on macOS
        run: |
          cd llvm-project
          cmake \
            -DCMAKE_BUILD_TYPE=Release \
            -DCMAKE_INSTALL_PREFIX=$(brew --prefix) \
            -DCMAKE_C_COMPILER=clang \
            -DCMAKE_CXX_COMPILER=clang++ \
            -DLIBOMP_INSTALL_ALIASES=OFF \
            -S openmp \
            -B build
          cmake \
            --build build \
            --parallel
          cmake --install build
          cd "$GITHUB_WORKSPACE"

is using C++ features that are modern enough to push things up, and so to drop down to a lower target the https://github.com/llvm/llvm-project release branch should be changed to something older than release/18.x.

@matthewfeickert
Copy link
Contributor Author

drop down to a lower target the https://github.com/llvm/llvm-project release branch should be changed to something older than release/18.x.

Through empirical testing release/17.x works for macos-13 with pypa/cibuildwheel@v2.14.

Though with pypa/cibuildwheel@v2.19 everything fails, including release/11.x and

wget https://github.com/llvm/llvm-project/releases/download/llvmorg-11.0.0/openmp-11.0.0.src.tar.xz

previously worked in the past.

So I don't think I understand enough about what cibuildwheel is doing between these releases do know why things are breaking.

@henryiii
Copy link

You are building this outside of cibuildwheel. So you need to set it manually.

@henryiii
Copy link

henryiii commented Jun 19, 2024

      - name: Build OpenMP on macOS
        env:
          MACOSX_DEPLOYMENT_TARGET: "10.9"
        working-directory: llvm-project
        run: |
          cmake -Sopenmp -Bbuild \
            -DCMAKE_BUILD_TYPE=Release \
            -DCMAKE_INSTALL_PREFIX=$(brew --prefix) \
            -DCMAKE_C_COMPILER=clang \
            -DCMAKE_CXX_COMPILER=clang++ \
            -DLIBOMP_INSTALL_ALIASES=OFF \
          cmake --build build --parallel 4
          cmake --install build

@matthewfeickert
Copy link
Contributor Author

Resolved in PR #24, given #28 (comment), so closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants