diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..27c93395 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,120 @@ +name: Build & Release + +on: + push: + branches: + - main + tags: + - '*' + pull_request: + branches: + - main + +jobs: + build_sdist_purepy: + name: Build source/pure python wheels + runs-on: ubuntu-latest + strategy: + fail-fast: false + steps: + - uses: actions/checkout@v4 + with: + submodules: 'recursive' + + - name: Build source/pure python wheels + run: | + python -m pip install build + python -m build --outdir=wheelhouse + env: + INFINIGEN_MINIMAL_INSTALL: "True" + + - name: Upload to github + uses: actions/upload-artifact@v4 + with: + path: wheelhouse/* + if-no-files-found: error + + build_wheels: + name: Build wheel on ${{ matrix.os }} for ${{ matrix.cibw_archs }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + # we skip Windows since that results in pure Python wheels + # anyway; (compile_terrain.sh is not supported on Windows) + - os: ubuntu-latest + cibw_archs: "x86_64" + - os: ubuntu-latest + cibw_archs: "aarch64" + - os: macos-13 + cibw_archs: "x86_64" + - os: macos-latest + cibw_archs: "arm64" + + steps: + - name: Install macOS dependencies + if: runner.os == 'macOS' + run: | + brew install libomp + echo "MACOSX_DEPLOYMENT_TARGET=$(sw_vers -productVersion | cut -d '.' -f 1-2)" >> $GITHUB_ENV + + - name: Set CXXFLAGS and LDFLAGS for macOS + if: matrix.os == 'macos-13' + run: | + echo "CXX=$(brew --prefix llvm@15)/bin/clang++" >> $GITHUB_ENV + echo "CXXFLAGS=-I/usr/local/opt/libomp/include" >> $GITHUB_ENV + echo "LDFLAGS=-Wl,-rpath,/usr/local/opt/libomp/lib -L/usr/local/opt/libomp/lib -lomp" >> $GITHUB_ENV + + - name: Set CXXFLAGS and LDFLAGS for macOS + if: matrix.os == 'macos-latest' + run: | + echo "CXX=$(brew --prefix llvm@15)/bin/clang++" >> $GITHUB_ENV + echo "CXXFLAGS=-I/opt/homebrew/opt/libomp/include" >> $GITHUB_ENV + echo "LDFLAGS=-Wl,-rpath,/opt/homebrew/opt/libomp/lib -L/opt/homebrew/opt/libomp/lib -lomp" >> $GITHUB_ENV + + - uses: actions/checkout@v4 + with: + submodules: 'recursive' + + - name: Build wheels + uses: pypa/cibuildwheel@v2.21 + with: + output-dir: wheelhouse + env: + CIBW_BUILD: "cp311-*" + # `bpy` is not easily pip-installable on manylinux (no sdists either), + # so we skip tests + CIBW_TEST_COMMAND: "" + CIBW_BUILD_VERBOSITY: 1 + CIBW_ENVIRONMENT: + CXXFLAGS="${{ env.CXXFLAGS }}" + LDFLAGS="${{ env.LDFLAGS }}" + + - name: Upload artifacts to github + uses: actions/upload-artifact@v4 + with: + name: wheels-${{ runner.os }}-${{ matrix.cibw_archs }} + path: ./wheelhouse/*.whl + if-no-files-found: error + + publish_to_pypi: + name: Publish wheels to PyPi + if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') + needs: [build_sdist_purepy, build_wheels] + runs-on: ubuntu-latest + steps: + - name: Download packages + uses: actions/download-artifact@v4 + with: + path: dist + merge-multiple: true + + - name: Upload wheels to pypi + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} + TWINE_REPOSITORY: testpypi + run: | + python -m pip install --upgrade twine + twine upload dist/* diff --git a/pyproject.toml b/pyproject.toml index bb2b857b..785bff09 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,7 +15,6 @@ keywords = [ "procedural" ] classifiers = [ - "Framework :: Blender", "Programming Language :: Python :: 3", ] diff --git a/scripts/install/compile_terrain.sh b/scripts/install/compile_terrain.sh index 5f74dc26..d8bab46f 100644 --- a/scripts/install/compile_terrain.sh +++ b/scripts/install/compile_terrain.sh @@ -71,23 +71,26 @@ fi OS=$(uname -s) ARCH=$(uname -m) -if [ "${OS}" = "Linux" ]; then - alias gx1="g++ -O3 -c -fpic -fopenmp " - alias gx2="g++ -O3 -shared -fopenmp " -elif [ "${OS}" = "Darwin" ]; then - if [ "${ARCH}" = "arm64" ]; then - compiler="/opt/homebrew/opt/llvm/bin/clang++" +if [ -n "$CXX" ]; then + compiler="$CXX" +else + if [ "${OS}" = "Linux" ]; then + compiler="g++" + elif [ "${OS}" = "Darwin" ]; then + if [ "${ARCH}" = "arm64" ]; then + compiler="/opt/homebrew/opt/llvm/bin/clang++" + else + compiler="/usr/local/opt/llvm/bin/clang++" + fi else - compiler="/usr/local/opt/llvm/bin/clang++" + echo "Unsupported OS" + exit -1 fi - alias gx1="${compiler} -O3 -c -fpic -fopenmp " - alias gx2="${compiler} -O3 -shared -fopenmp " - alias gx="${compiler} -O3 -fpic -shared -fopenmp " -else - echo "Unsupported OS" - exit -1 fi +alias gx1="${compiler} \$CXXFLAGS -O3 -c -fpic -fopenmp " +alias gx2="${compiler} \$LDFLAGS -O3 -shared -fopenmp " + mkdir -p lib/cpu/utils gx1 -o lib/cpu/utils/FastNoiseLite.o source/cpu/utils/FastNoiseLite.cpp gx2 -o lib/cpu/utils/FastNoiseLite.so lib/cpu/utils/FastNoiseLite.o @@ -121,16 +124,11 @@ gx2 -o lib/cpu/meshing/utils.so lib/cpu/meshing/utils.o echo "compiled lib/cpu/meshing/utils.so" if [ "${OS}" = "Darwin" ]; then - if [ "${ARCH}" = "arm64" ]; then - alias gx1="CPATH=/opt/homebrew/include:${CPATH} g++ -O3 -c -fpic -std=c++17" - alias gx2="CPATH=/opt/homebrew/include:${CPATH} g++ -O3 -shared -std=c++17" - else - alias gx1="CPATH=/usr/local/include:${CPATH} g++ -O3 -c -fpic -std=c++17" - alias gx2="CPATH=/usr/local/include:${CPATH} g++ -O3 -shared -std=c++17" - fi + alias gx1="CPATH=/opt/homebrew/include:${CPATH} ${compiler} -O3 -c -fpic -std=c++17" + alias gx2="CPATH=/opt/homebrew/include:${CPATH} ${compiler} -O3 -shared -std=c++17" fi mkdir -p lib/cpu/soil_machine -gx1 -o lib/cpu/soil_machine/SoilMachine.o source/cpu/soil_machine/SoilMachine.cpp +gx1 -I../datagen/customgt/dependencies/glm -o lib/cpu/soil_machine/SoilMachine.o source/cpu/soil_machine/SoilMachine.cpp gx2 -o lib/cpu/soil_machine/SoilMachine.so lib/cpu/soil_machine/SoilMachine.o echo "compiled lib/cpu/soil_machine/SoilMachine.so" diff --git a/setup.py b/setup.py index d7c7fb75..332cb96e 100644 --- a/setup.py +++ b/setup.py @@ -44,7 +44,8 @@ def ensure_submodules(): ) -ensure_submodules() +if not MINIMAL_INSTALL: + ensure_submodules() # inspired by https://github.com/pytorch/pytorch/blob/161ea463e690dcb91a30faacbf7d100b98524b6b/setup.py#L290 # theirs seems to not exclude dist_info but this causes duplicate compiling in my tests