|
| 1 | +name: Build Voxelization Toolkit OSX |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +jobs: |
| 10 | + build_voxec: |
| 11 | + runs-on: ${{ matrix.runner }} |
| 12 | + strategy: |
| 13 | + fail-fast: false |
| 14 | + matrix: |
| 15 | + include: |
| 16 | + - os: macos |
| 17 | + runner: macos-13 |
| 18 | + arch: x64 |
| 19 | + oldarch: |
| 20 | + cpuarch: x86_64 |
| 21 | + macosx_ver: '10_15' |
| 22 | + - os: macos |
| 23 | + runner: macos-14 |
| 24 | + arch: arm64 |
| 25 | + oldarch: m1 |
| 26 | + cpuarch: arm64 |
| 27 | + macosx_ver: '11_0' |
| 28 | + |
| 29 | + steps: |
| 30 | + - name: Checkout Repository |
| 31 | + uses: actions/checkout@v3 |
| 32 | + with: |
| 33 | + submodules: recursive |
| 34 | + |
| 35 | + - name: Checkout IfcOpenShell |
| 36 | + uses: actions/checkout@v3 |
| 37 | + with: |
| 38 | + repository: IfcOpenShell/IfcOpenShell |
| 39 | + path: IfcOpenShell |
| 40 | + token: ${{ secrets.BUILD_REPO_TOKEN }} |
| 41 | + submodules: recursive |
| 42 | + |
| 43 | + - name: Checkout Build Repository |
| 44 | + uses: actions/checkout@v3 |
| 45 | + with: |
| 46 | + repository: IfcOpenShell/build-outputs |
| 47 | + path: IfcOpenShell/build |
| 48 | + ref: ${{ matrix.os }}-${{ matrix.arch }} |
| 49 | + lfs: true |
| 50 | + token: ${{ secrets.BUILD_REPO_TOKEN }} |
| 51 | + |
| 52 | + - name: Set up Python |
| 53 | + uses: actions/setup-python@v4 |
| 54 | + with: |
| 55 | + python-version: '3.x' |
| 56 | + |
| 57 | + - name: Install Dependencies |
| 58 | + run: | |
| 59 | + brew update |
| 60 | + brew install git bison autoconf automake libffi cmake findutils swig |
| 61 | + echo "$(brew --prefix findutils)/libexec/gnubin" >> $GITHUB_PATH |
| 62 | + |
| 63 | + - name: Unpack IfcOpenShell Dependencies |
| 64 | + run: | |
| 65 | + install_root=$(find ./IfcOpenShell/build -maxdepth 4 -name install) |
| 66 | + find "$install_root" -type f -name 'cache-*.tar.gz' -maxdepth 1 -exec tar -xzf {} -C "$install_root" \; |
| 67 | +
|
| 68 | + - name: Relocate python libraries |
| 69 | + run: | |
| 70 | + base=$(find $PWD/IfcOpenShell/build -maxdepth 4 -name install) |
| 71 | + for pybin in $(find $base -name python3); do |
| 72 | + l="$(ls $(dirname $pybin)/../lib/libpython*.dylib 2>/dev/null | head -n 1)" |
| 73 | + o="$(otool -L "$pybin" | awk '/libpython/ {print $1; exit}')" |
| 74 | + n="@executable_path/../lib/$(basename "$l")" |
| 75 | + install_name_tool -change "$o" "$n" "$pybin" |
| 76 | + otool -L "$pybin" |
| 77 | + done |
| 78 | +
|
| 79 | + - name: Debug |
| 80 | + run: | |
| 81 | + base=$(find $PWD/IfcOpenShell/build -maxdepth 4 -name install) |
| 82 | + $base/python-3.9.11/bin/python3 --version |
| 83 | + $base/python-3.9.11/bin/python3 -c 'import sysconfig; print(sysconfig.get_path("platlib"))' |
| 84 | +
|
| 85 | + - name: Run IfcOpenShell Build Script |
| 86 | + run: | |
| 87 | + if [ "${{ matrix.os }}" == "macos" ]; then |
| 88 | + DARWIN_C_SOURCE=-D_DARWIN_C_SOURCE |
| 89 | + fi |
| 90 | + CXXFLAGS="-O3" CFLAGS="-O3 ${DARWIN_C_SOURCE}" ADD_COMMIT_SHA=1 BUILD_CFG=Release python3 ./IfcOpenShell/nix/build-all.py --diskcleanup IfcConvert python |
| 91 | +
|
| 92 | + - name: Compile voxec |
| 93 | + run: | |
| 94 | + export CFLAGS="-Wl,-flat_namespace,-undefined,suppress" |
| 95 | + export CXXFLAGS="-Wl,-flat_namespace,-undefined,suppress" |
| 96 | + export LDFLAGS="-Wl,-flat_namespace,-undefined,suppress" |
| 97 | + base=$(find $PWD/IfcOpenShell/build -maxdepth 4 -name install) |
| 98 | + mkdir build |
| 99 | + cd build |
| 100 | + for python_root in $base/python-*; do |
| 101 | + [ -f CMakeCache.txt ] && rm CMakeCache.txt |
| 102 | + cmake .. \ |
| 103 | + "-DCMAKE_BUILD_TYPE=Release" \ |
| 104 | + "-DENABLE_PYTHON_WRAPPER=On" \ |
| 105 | + "-DENABLE_TESTS=Off" \ |
| 106 | + "-DUSE_BUILD_SCRIPT_OUTPUT=Off" \ |
| 107 | + "-DBoost_USE_STATIC_LIBS=On" \ |
| 108 | + "-DBoost_NO_BOOST_CMAKE=On" \ |
| 109 | + "-DCMAKE_INSTALL_PREFIX=../install" \ |
| 110 | + "-DIFC_INCLUDE_DIR=$base/ifcopenshell/include" \ |
| 111 | + "-DIFC_LIBRARY_DIR=$base/ifcopenshell/lib" \ |
| 112 | + "-DOCC_INCLUDE_DIR=$base/occt-7.8.1/include/opencascade" \ |
| 113 | + "-DOCC_LIBRARY_DIR=$base/occt-7.8.1/lib" \ |
| 114 | + "-DPython_EXECUTABLE=$python_root/bin/python3" \ |
| 115 | + "-DBOOST_ROOT=$base/boost-1.86.0" \ |
| 116 | + "-DGMP_LIBRARY_DIR=$base/gmp-6.2.1/lib" \ |
| 117 | + "-DMPFR_LIBRARY_DIR=$base/mpfr-3.1.6/lib" |
| 118 | + make -j4 install |
| 119 | + done |
| 120 | +
|
| 121 | + - name: Package .zip archives |
| 122 | + run: | |
| 123 | + base=$(find $PWD/IfcOpenShell/build -maxdepth 4 -name install) |
| 124 | + mkdir -p $GITHUB_WORKSPACE/package |
| 125 | + cd $GITHUB_WORKSPACE/package |
| 126 | + cp $GITHUB_WORKSPACE/pyproject.toml . |
| 127 | +
|
| 128 | + for python_root in $base/python-*; do |
| 129 | + PATH=$python_root/bin:$PATH python3 -m pip install --upgrade pip setuptools wheel |
| 130 | + PATH=$python_root/bin:$PATH python3 -m pip install build delocate |
| 131 | +
|
| 132 | + mm=`$python_root/bin/python3 --version | cut -c8- | cut -d. -f 1,2 | tr -d '.'` |
| 133 | + mdm=`$python_root/bin/python3 --version | cut -c8- | cut -d. -f 1,2` |
| 134 | + cp -R $python_root/lib/python$mdm/site-packages/voxec . |
| 135 | + echo '[bdist_wheel]' > setup.cfg |
| 136 | + echo 'python-tag = cp'$mm >> setup.cfg |
| 137 | +
|
| 138 | + PATH=$python_root/bin:$PATH python3 -m build -w |
| 139 | + PATH=$python_root/bin:$PATH delocate-wheel dist/*.whl -w audited |
| 140 | + mv audited/voxec-0.4.0-cp$mm-none-any.whl audited/voxec-0.4.0-cp$mm-none-macosx_${{ matrix.macosx_ver }}_${{ matrix.cpuarch }}.whl |
| 141 | +
|
| 142 | + rm -r voxec dist/*.whl |
| 143 | + done |
| 144 | +
|
| 145 | + - name: Publish a Python distribution to PyPI |
| 146 | + uses: ortega2247/pypi-upload-action@master |
| 147 | + with: |
| 148 | + user: __token__ |
| 149 | + password: ${{ secrets.PYPI_API_TOKEN }} |
| 150 | + packages_dir: package/audited |
0 commit comments