diff --git a/.github/actions/build-ifcwrap-python/action.yml b/.github/actions/build-ifcwrap-python/action.yml new file mode 100644 index 0000000000..e518bf261c --- /dev/null +++ b/.github/actions/build-ifcwrap-python/action.yml @@ -0,0 +1,53 @@ +name: Build and install standalone IfcPython +description: Configure, build and smoke-test src/ifcwrap against an already-installed IfcOpenShell for a given Python version. + +inputs: + python-version: + description: Python version to build the wrapper for (e.g. "3.11") + required: true + ifcopenshell-prefix: + description: CMAKE_PREFIX_PATH entry pointing at the installed IfcOpenShell + required: true + +runs: + using: composite + steps: + - name: Set up Python ${{ inputs.python-version }} + uses: actions/setup-python@v7 + with: + python-version: ${{ inputs.python-version }} + + - name: Install Python import dependencies + shell: bash + run: | + python -m pip install --upgrade pip + python -m pip install numpy typing_extensions + + - name: Configure standalone IfcPython + shell: bash + run: | + PYTHON_EXECUTABLE="$(python -c 'import sys; print(sys.executable)')" + PYTHON_INCLUDE_DIR="$(python -c 'import sysconfig; print(sysconfig.get_path("include"))')" + + cmake -S src/ifcwrap -B "build-ifcwrap-${{ inputs.python-version }}" \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_PREFIX_PATH="${{ inputs.ifcopenshell-prefix }};/usr" \ + -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ + -DPython_EXECUTABLE:FILEPATH="${PYTHON_EXECUTABLE}" \ + -DPython_INCLUDE_DIR:PATH="${PYTHON_INCLUDE_DIR}" \ + -DPYTHON_EXECUTABLE:FILEPATH="${PYTHON_EXECUTABLE}" \ + -DPYTHON_INCLUDE_DIR:PATH="${PYTHON_INCLUDE_DIR}" + + - name: Build and install standalone IfcPython + shell: bash + run: | + cmake --build "build-ifcwrap-${{ inputs.python-version }}" --target install -j "$(nproc)" + + - name: Import installed IfcPython + shell: bash + run: | + PYTHONPATH="${RUNNER_TEMP}/ifcopenshell-python" python - <<'PY' + import ifcopenshell + + print("IfcOpenShell import ok:", ifcopenshell.version) + PY diff --git a/.github/workflows/ci-ifcwrap-standalone.yml b/.github/workflows/ci-ifcwrap-standalone.yml index 30ad34182d..076660eccc 100644 --- a/.github/workflows/ci-ifcwrap-standalone.yml +++ b/.github/workflows/ci-ifcwrap-standalone.yml @@ -94,74 +94,14 @@ jobs: run: | cmake --build build-ifcopenshell --target install -j "$(nproc)" - - name: Set up Python 3.11 - uses: actions/setup-python@v7 + - name: Build and install standalone IfcPython for Python 3.11 + uses: ./.github/actions/build-ifcwrap-python with: - python-version: 3.11 + python-version: "3.11" + ifcopenshell-prefix: ${{ env.IFCOPENSHELL_PREFIX }} - - name: Install Python import dependencies - run: | - python -m pip install --upgrade pip - python -m pip install numpy typing_extensions - - - name: Configure standalone IfcPython - run: | - PYTHON_EXECUTABLE="$(python -c 'import sys; print(sys.executable)')" - PYTHON_INCLUDE_DIR="$(python -c 'import sysconfig; print(sysconfig.get_path("include"))')" - - cmake -S src/ifcwrap -B "build-ifcwrap-311" \ - -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_PREFIX_PATH="${IFCOPENSHELL_PREFIX};/usr" \ - -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ - -DPython_EXECUTABLE:FILEPATH="${PYTHON_EXECUTABLE}" \ - -DPython_INCLUDE_DIR:PATH="${PYTHON_INCLUDE_DIR}" \ - -DPYTHON_EXECUTABLE:FILEPATH="${PYTHON_EXECUTABLE}" \ - -DPYTHON_INCLUDE_DIR:PATH="${PYTHON_INCLUDE_DIR}" - - - name: Build and install standalone IfcPython - run: | - cmake --build "build-ifcwrap-311" --target install -j "$(nproc)" - - - name: Import installed IfcPython - run: | - PYTHONPATH="${RUNNER_TEMP}/ifcopenshell-python" python - <<'PY' - import ifcopenshell - - print("IfcOpenShell import ok:", ifcopenshell.version) - PY - - - name: Set up Python 3.12 - uses: actions/setup-python@v7 + - name: Build and install standalone IfcPython for Python 3.12 + uses: ./.github/actions/build-ifcwrap-python with: - python-version: 3.12 - - - name: Install Python import dependencies - run: | - python -m pip install --upgrade pip - python -m pip install numpy typing_extensions - - - name: Configure standalone IfcPython - run: | - PYTHON_EXECUTABLE="$(python -c 'import sys; print(sys.executable)')" - PYTHON_INCLUDE_DIR="$(python -c 'import sysconfig; print(sysconfig.get_path("include"))')" - - cmake -S src/ifcwrap -B "build-ifcwrap-312" \ - -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_PREFIX_PATH="${IFCOPENSHELL_PREFIX};/usr" \ - -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ - -DPython_EXECUTABLE:FILEPATH="${PYTHON_EXECUTABLE}" \ - -DPython_INCLUDE_DIR:PATH="${PYTHON_INCLUDE_DIR}" \ - -DPYTHON_EXECUTABLE:FILEPATH="${PYTHON_EXECUTABLE}" \ - -DPYTHON_INCLUDE_DIR:PATH="${PYTHON_INCLUDE_DIR}" - - - name: Build and install standalone IfcPython - run: | - cmake --build "build-ifcwrap-312" --target install -j "$(nproc)" - - - name: Import installed IfcPython - run: | - PYTHONPATH="${RUNNER_TEMP}/ifcopenshell-python" python - <<'PY' - import ifcopenshell - - print("IfcOpenShell import ok:", ifcopenshell.version) - PY + python-version: "3.12" + ifcopenshell-prefix: ${{ env.IFCOPENSHELL_PREFIX }}