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

Add Cython builds to MacOS using universal2 #242

Closed
cdgriffith opened this issue Jan 31, 2023 · 4 comments
Closed

Add Cython builds to MacOS using universal2 #242

cdgriffith opened this issue Jan 31, 2023 · 4 comments

Comments

@cdgriffith
Copy link
Owner

cdgriffith commented Jan 31, 2023

Discovered by @JacobHayes in the 7.0.0 release, the builds for macOS cython version were not working except on latest python 3.11 that was able to build a universal2 package.

I have tried building universal2 with older versions of python with github actions on macos-12 but without luck:

jobs:
  package-checks:
    strategy:
      matrix:
        python-version: ["3.9.15"]
        os: [macos-12]
    runs-on: ${{ matrix.os }}
    steps:

      - uses: actions/checkout@v3

      - name: Install python version
        uses: gabrielfalcao/pyenv-action@v11
        env:
          PYTHON_CONFIGURE_OPTS: "--enable-universalsdk=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk --with-universal-archs=universal2"
          LDFLAGS: "-L/opt/homebrew/lib"
          CPPFLAGS: "-I/opt/homebrew/include"
        with:
          default: "3.9.15"
          command: python -m pip install --upgrade pip  # upgrade pip after installing python


      - name: Install dependencies
        run: |
          pip install -r requirements.txt
          pip install -r requirements-test.txt
          pip install coveralls flake8 flake8-print mypy setuptools wheel twine Cython

      - name: Test packaged wheel on mac
        if: matrix.os == 'macos-12'
        run: |
          pip install Cython
          python setup.py bdist_wheel
          mv box box_og
          ls dist/*
          pip install dist/*universal2.whl
          python -m pytest
      - name: Upload wheel artifact
        uses: actions/upload-artifact@v2
        with:
          name: python_box
          path: dist/*.whl
Run gabrielfalcao/pyenv-action@v11
downloading https://github.com/pyenv/pyenv/archive/v2.3.7.zip
/usr/bin/unzip -o -q /Users/runner/hostedtoolcache/pyenv-archive.zip/2.3.7/x64/pyenv-archive.zip
Extracted /Users/runner/hostedtoolcache/pyenv-archive.zip/2.3.7/x64/pyenv-archive.zip to /Users/runner/work/_temp/0c04652a-33ee-4c46-9c1e-9310f3801b98.
archive_path /Users/runner/hostedtoolcache/pyenv-archive.zip/2.3.7/x64/pyenv-archive.zip
pyenv_root /Users/runner/hostedtoolcache/pyenv_root/2.3.7/x64
export PYENV_ROOT="/Users/runner/hostedtoolcache/pyenv_root/2.3.7/x64"
Patched PATH with "/Users/runner/hostedtoolcache/pyenv_root/2.3.7/x64/bin"
/Users/runner/hostedtoolcache/pyenv_root/2.3.7/x64/bin/pyenv install 3.9.15
python-build: use openssl@1.1 from homebrew
python-build: use readline from homebrew
Downloading Python-3.9.15.tar.xz...
-> https://www.python.org/ftp/python/3.9.15/Python-3.9.15.tar.xz
Installing Python-3.9.15...
python-build: use tcl-tk from homebrew
python-build: use readline from homebrew
python-build: use zlib from xcode sdk

BUILD FAILED (OS X 12.6.2 using python-build 20180424)

Inspect or clean up the working tree at /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/python-build.20230131181520.1577
Results logged to /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/python-build.20230131181520.1577.log

Last 10 log lines:
  "_libintl_textdomain", referenced from:
      _PyIntl_textdomain in libpython3.9.a(_localemodule.o)
      _PyIntl_textdomain in libpython3.9.a(_localemodule.o)
ld: symbol(s) not found for architecture arm64
ld: symbol(s) not found for architecture arm64
clang: clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [Programs/_testembed] Error 1
make: *** Waiting for unfinished jobs....
make: *** [python.exe] Error 1
Failed to install python 3.9.15

It also seems to plague a lot of other people as well:

pyenv/pyenv#1877
https://stackoverflow.com/questions/72218180/ld-symbols-not-found-for-architecture-arm64-when-compile-python

macos build config options for python: https://docs.python.org/3/using/configure.html#macos-options

For now going to remove cython builds entirely for 7.0.0 until someone who owns a mac and can figure this out submits a PR for it!

@JacobHayes
Copy link
Contributor

I wonder if it'd be easy to setup https://github.com/pypa/cibuildwheel

@cdgriffith
Copy link
Owner Author

ouh never seen that before, thank you for the link!

@cdgriffith
Copy link
Owner Author

It looks to be creating x86_64 wheels as well, but it does test/ correct them as part of the process so hopefully in 7.0.0rc3 they are working correctly for mac! https://pypi.org/project/python-box/7.0.0rc3/#files

@JacobHayes
Copy link
Contributor

JacobHayes commented Feb 1, 2023

I was still getting issues, but weirdly updating python (not specifically pip) seemed to fix it:

-        python-version: [3.9.14, 3.10.8, 3.11.0]
+        python-version: [3.9.16, 3.10.9, 3.11.1]

I also noticed the GHA runner version changed between my 3.9/3.10 and 3.11 builds (which is very odd - same workflow run, just in a matrix all using macos-latest). After the py upgrade all are using the same runner version. 🤷

I think it might have to do with the wheels being tagged macosx_12_0 instead of eg: macosx_10_9 or macosx_11_0 as numpy seems to have - so maybe the minor python versions were upgraded to identify _12_0 fine.


I think the poetry config is a bit off though and ruamel and tomli are being marked required - I'll submit a PR here soon to try to fix!

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

No branches or pull requests

2 participants