Build bpy for Linux #46
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build bpy for Linux | |
on: | |
workflow_dispatch: | |
inputs: | |
tag: | |
description: 'Blender Tag to build' | |
required: true | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Blender repository recursively | |
uses: actions/checkout@v2 | |
with: | |
repository: blender/blender | |
ref: ${{ github.event.inputs.tag }} # Checkout the tag specified in the workflow dispatch | |
submodules: 'recursive' # Recursively checkout submodules | |
path: blender | |
- name: Set up Conda | |
uses: conda-incubator/setup-miniconda@v2 | |
with: | |
auto-update-conda: true | |
python-version: 3.10.13 # Specify the Python version you need | |
# environment-file: environment.yml | |
activate-environment: bpy-env | |
channels: conda-forge | |
- name: Install Conda Dependencies | |
run: | | |
conda install -y cuda-toolkit setuptools -c "nvidia/label/cuda-12.3.1" -c conda-forge | |
# find / -name nvcc | |
- name: Add conda subdirectories to PATH | |
run: | | |
for dir in $(find /home/runner/conda_pkgs_dir/ -mindepth 1 -type d); do | |
echo "$dir" >> $GITHUB_PATH | |
done | |
- name: Add CUDA compilation flags | |
run: | | |
nvcc --version | |
echo 'set(WITH_CYCLES_CUDA_BINARIES ON CACHE BOOL "" FORCE)' >> ./blender/build_files/cmake/config/bpy_module.cmake | |
- name: Set CUDA environment variables | |
run: | | |
NVCC_PATH=$(which nvcc) | |
CUDA_HOME=$(dirname $(dirname $NVCC_PATH)) | |
echo "CUDA_HOME=$CUDA_HOME" >> $GITHUB_ENV | |
echo "LD_LIBRARY_PATH=$CUDA_HOME/lib" >> $GITHUB_ENV | |
echo "CPLUS_INCLUDE_PATH=/usr/share/miniconda/include:$CPLUS_INCLUDE_PATH" >> $GITHUB_ENV | |
echo "C_INCLUDE_PATH=/usr/share/miniconda/include:$C_INCLUDE_PATH" >> $GITHUB_ENV | |
echo $CUDA_HOME | |
echo $LD_LIBRARY_PATH | |
# - name: Setup upterm session | |
# uses: lhotari/action-upterm@v1 | |
# with: | |
# ## limits ssh access and adds the ssh public key for the user which triggered the workflow | |
# limit-access-to-actor: true | |
# ## limits ssh access and adds the ssh public keys of the listed GitHub users | |
# limit-access-to-users: michaelgold | |
- name: Cache Blender dependencies | |
uses: actions/cache@v2 | |
with: | |
path: | | |
./lib | |
key: ${{ runner.os }}-blender-deps-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-blender-deps- | |
- name: Get dependencies | |
run: | | |
echo "Building bpy for Linux with tag ${{ github.event.inputs.tag }}" | |
sudo apt update | |
sudo apt-get install -y build-essential git subversion cmake libx11-dev libxxf86vm-dev libxcursor-dev libxi-dev libxrandr-dev libxinerama-dev libegl-dev | |
sudo apt-get install -y libwayland-dev wayland-protocols libxkbcommon-dev libdbus-1-dev linux-libc-dev | |
if [ ! -d "./lib" ]; then | |
mkdir ./lib | |
cd ./lib | |
svn checkout https://svn.blender.org/svnroot/bf-blender/trunk/lib/linux_x86_64_glibc_228 | |
fi | |
# - name: Install Cuda Toolkit | |
# uses: Jimver/[email protected] | |
# id: cuda-toolkit | |
# with: | |
# cuda: '12.1.0' | |
- name: Cache build files (for testing only) | |
uses: actions/cache@v2 | |
with: | |
path: | | |
./build_linux_bpy | |
key: ${{ runner.os }}-blender-build-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-blender-build- | |
- name: Download Blender Python API Stubs | |
id: download-artifact | |
uses: dawidd6/action-download-artifact@v2 | |
with: | |
workflow: generate_stubs.yml | |
# github_token: ${{secrets.GITHUB_TOKEN}} | |
name: blender-python-api-stubs-${{ github.event.inputs.tag }} | |
path: ./build_linux_bpy/bin/ | |
# - name: Build Blender | |
# run: | | |
# cd ./blender | |
# make update | |
# make bpy | |
# # make bpy VERBOSE=1 | |
# - name: Install Blender | |
# run: python -c "import shutil, site; shutil.copytree('./build_linux_bpy/bin/bpy', site.getsitepackages()[0] + '/bpy')" | |
# - name: Install docs prereqs | |
# run: | | |
# pip install bpystubgen | |
# - name: Generate Api Docs and stubs | |
# run: | | |
# cd ./blender | |
# python ./doc/python_api/sphinx_doc_gen.py -- --output=../python_api | |
# python -m bpystubgen ../python_api/sphinx-in ../python_api/output | |
# - name: Copy BPY Stubs to bin folder | |
# run: | | |
# cp -R ./python_api/output/* ./build_linux_bpy/bin/ | |
- name: Make Wheel | |
run: | | |
PYTHON3=$(which python3) | |
PYTHON=$(which python) | |
sudo rm $PYTHON3 | |
ln -s $PYTHON $PYTHON3 | |
python ./blender/build_files/utils/make_bpy_wheel.py ./build_linux_bpy/bin/ | |
- name: Upload Wheel as Artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: bpy-linux | |
path: | | |
./build_linux_bpy/bin/*.whl |