From b9d3acf53d67075b1542720157c2daffc18c5c8f Mon Sep 17 00:00:00 2001 From: Jean-Christophe Morin Date: Mon, 10 Apr 2023 13:43:57 -0400 Subject: [PATCH] Add new GH Actions workflow to build the wheels Signed-off-by: Jean-Christophe Morin --- .github/workflows/main.yml | 4 ++ .github/workflows/python.yml | 100 +++++++++++++++++++++++++++++++++++ pyproject.toml | 3 +- 3 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/python.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8e68529175..172cd3aae7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,6 +9,10 @@ on: - '**.md' workflow_dispatch: +concurrency: + cancel-in-progress: true + group: ${{ github.workflow }}-${{ github.ref }} + jobs: build: diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml new file mode 100644 index 0000000000..d05eb83b45 --- /dev/null +++ b/.github/workflows/python.yml @@ -0,0 +1,100 @@ +name: python + +on: + push: + pull_request: + +concurrency: + cancel-in-progress: true + group: ${{ github.workflow }}-${{ github.ref }} + +jobs: + wheels: + name: Generate wheels + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + python-version: ['37', '38', '39', '310', '311'] + os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] + steps: + - uses: actions/checkout@v3 + + - name: Build wheels + uses: pypa/cibuildwheel@v2.12.1 + with: + output-dir: dist + env: + CIBW_BUILD: 'cp${{ matrix.python-version }}-*' + CIBW_SKIP: '*musllinux*' + CIBW_ARCHS: 'auto64' + CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014 + # CIBW_BUILD_FRONTEND: build # https://github.com/pypa/build + CIBW_BUILD_VERBOSITY: 1 + CIBW_ENVIRONMENT: CMAKE_BUILD_PARALLEL_LEVEL=2 + + - name: Store wheels + uses: actions/upload-artifact@v3 + with: + name: wheels + path: ./dist/*.whl + + sdist: + name: Generate sdist + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-python@v4 + with: + python-version: 3.11 + + - name: Install build command + run: python -m pip install build + + - name: Create sdist + run: python -m build -s . --outdir dist + + - name: Store sdist + uses: actions/upload-artifact@v3 + with: + name: sdist + path: ./dist/*.tar.gz + + test: + name: Test wheels + needs: ['wheels'] + runs-on: ${{ matrix.os }} + strategy: + matrix: + python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] + os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] + + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Download wheels + uses: actions/download-artifact@v3 + with: + name: wheels + path: dist + + - name: Install wheel + run: python -m pip install dist/*.whl + + - name: Python tests + run: | + python python/MaterialXTest/main.py + python python/MaterialXTest/genshader.py + python python/Scripts/mxupdate.py resources/Materials/TestSuite/stdlib/upgrade --yes + python python/Scripts/mxvalidate.py resources/Materials/Examples/StandardSurface/standard_surface_marble_solid.mtlx --stdlib --verbose + python python/Scripts/mxdoc.py --docType md libraries/pbrlib/pbrlib_defs.mtlx + python python/Scripts/mxdoc.py --docType html libraries/bxdf/standard_surface.mtlx + python python/Scripts/generateshader.py resources/Materials/Examples/StandardSurface --target glsl + python python/Scripts/generateshader.py resources/Materials/Examples/StandardSurface --target osl + python python/Scripts/generateshader.py resources/Materials/Examples/StandardSurface --target mdl + python python/Scripts/generateshader.py resources/Materials/Examples/StandardSurface --target msl diff --git a/pyproject.toml b/pyproject.toml index c0e279870c..3194fbc8c9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -50,7 +50,7 @@ cmake.build-type = "Release" # Uncoment when developing locally to enable inplace builds. # build-dir = "build/" -logging.level = "INFO" +logging.level = "DEBUG" # Since the python package doesn't live in a standard directory # in the source (i.e ./src or ./), we need to manually specify @@ -73,6 +73,7 @@ MATERIALX_BUILD_SHARED_LIBS = 'OFF' # Be explicit MATERIALX_BUILD_PYTHON = 'ON' MATERIALX_TEST_RENDER = 'OFF' MATERIALX_WARNINGS_AS_ERRORS = 'ON' +MATERIALX_BUILD_RENDER = 'OFF' # TODO: How could we harmonize this variable with SKBUILD? MATERIALX_INSTALL_PYTHON = 'OFF'