Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-build python wheels #119

Merged
merged 6 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
219 changes: 163 additions & 56 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ env:
BUILD_TYPE: Release

jobs:

#
# MAYA
#

maya-win:
runs-on: windows-2019

Expand All @@ -23,12 +28,6 @@ jobs:

matrix:
include:
- maya: "2018"
devkit: "https://autodesk-adn-transfer.s3-us-west-2.amazonaws.com/ADN+Extranet/M%26E/Maya/devkit+2018/Autodesk_Maya_2018_7_Update_DEVKIT_Windows.zip"
- maya: "2019"
devkit: "https://autodesk-adn-transfer.s3-us-west-2.amazonaws.com/ADN+Extranet/M%26E/Maya/devkit+2019/Autodesk_Maya_2019_3_Update_DEVKIT_Windows.zip"
- maya: "2020"
devkit: "https://autodesk-adn-transfer.s3-us-west-2.amazonaws.com/ADN+Extranet/M%26E/Maya/devkit+2020/Autodesk_Maya_2020_4_Update_DEVKIT_Windows.zip"
- maya: "2022"
devkit: "https://autodesk-adn-transfer.s3-us-west-2.amazonaws.com/ADN+Extranet/M%26E/Maya/devkit+2022/Autodesk_Maya_2022_3_Update_DEVKIT_Windows.zip"
- maya: "2023"
Expand Down Expand Up @@ -78,12 +77,6 @@ jobs:

matrix:
include:
- maya: "2018"
devkit: "https://autodesk-adn-transfer.s3-us-west-2.amazonaws.com/ADN+Extranet/M%26E/Maya/devkit+2018/Autodesk_Maya_2018_7_Update_DEVKIT_Mac.dmg"
- maya: "2019"
devkit: "https://autodesk-adn-transfer.s3-us-west-2.amazonaws.com/ADN+Extranet/M%26E/Maya/devkit+2019/Autodesk_Maya_2019_3_Update_DEVKIT_Mac.dmg"
- maya: "2020"
devkit: "https://autodesk-adn-transfer.s3-us-west-2.amazonaws.com/ADN+Extranet/M%26E/Maya/devkit+2020/Autodesk_Maya_2020_4_Update_DEVKIT_Mac.dmg"
- maya: "2022"
devkit: "https://autodesk-adn-transfer.s3-us-west-2.amazonaws.com/ADN+Extranet/M%26E/Maya/devkit+2022/Autodesk_Maya_2022_3_Update_DEVKIT_Mac.dmg"
- maya: "2023"
Expand Down Expand Up @@ -126,8 +119,6 @@ jobs:
artifacts/plug-ins/simplex_maya.bundle
artifacts/pyModules/py*simplex.so



maya-macos-12:
runs-on: macos-12

Expand Down Expand Up @@ -186,15 +177,6 @@ jobs:

matrix:
include:
# The 2018 and 2019 containers use cmake 3.9, and I'm using functions introduced in 3.16
#- maya: "2018.7"
# year: "2018"
#- maya: "2019.3"
# year: "2019"
- maya: "2020.4"
year: "2020"
- maya: "2022.3"
year: "2022"
- maya: "2023"
year: "2023"
- maya: "2024"
Expand All @@ -206,6 +188,10 @@ jobs:
with:
submodules: true

- name: Install latest cmake
run: |
python3 -m pip install cmake

- name: Configure CMake
run: |
mkdir build
Expand All @@ -231,69 +217,179 @@ jobs:
artifacts/pyModules/py*simplex.so

#
# Shipping
# PYTHON
#
# _________
# |\ _ _ _ _\
# | \________\
# | | |
# | | |
# \|________|

python-win:
runs-on: windows-2019

strategy:
fail-fast: false

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0

- name: Configure CMake
run: |
cmake -B ${{github.workspace}}/pybuild -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_MAYA=NO -DMAYA_PYTHON=NO -DSYSTEM_PY_VERSION=3

- name: Build
run: |
cmake --build ${{github.workspace}}/pybuild --config ${{env.BUILD_TYPE}}
cp ./pybuild/src/python/${{env.BUILD_TYPE}}/pysimplex.pyd .

- name: Build Wheel
run: |
py -3 -m pip install -U pip
py -3 -m pip install -U build wheel hatch
py -3 -m hatch version $(git describe --tags --abbrev=0)
py -3 -m build --wheel
$PY_WHEEL = Get-ChildItem -Name dist/*.whl
py -3 -m wheel tags --remove --python-tag cp3 --abi-tag abi3 --platform-tag win_amd64 dist/$PY_WHEEL

- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: wheels
path: dist/*.whl

python-macos:
runs-on: macos-12

strategy:
fail-fast: false

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0

- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '13.4'

- name: Configure CMake
run: |
cmake -G Xcode -B ${{github.workspace}}/pybuild -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_MAYA=NO -DMAYA_PYTHON=NO -DSYSTEM_PY_VERSION=3

- name: Build
run: |
cmake --build ${{github.workspace}}/pybuild --config ${{env.BUILD_TYPE}}
cp ./pybuild/src/python/${{env.BUILD_TYPE}}/pysimplex.so .

- name: Build Wheel
run: |
python3 -m pip install -U pip
python3 -m pip install -U build wheel hatch
python3 -m hatch version $(git describe --tags --abbrev=0)
python3 -m build --wheel
for PY_WHEEL in dist/*.whl
do
python3 -m wheel tags --remove --python-tag cp3 --abi-tag abi3 --platform-tag macosx_10_9_x86_64 ${PY_WHEEL}
done

- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: wheels
path: dist/*.whl

python-linux:
runs-on: ubuntu-latest

strategy:
fail-fast: false

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0

- name: Configure CMake
run: |
cmake -B ${{github.workspace}}/pybuild -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_MAYA=NO -DMAYA_PYTHON=NO -DSYSTEM_PY_VERSION=3

- name: Build
run: |
cmake --build ${{github.workspace}}/pybuild --config ${{env.BUILD_TYPE}}
cp ./pybuild/src/python/pysimplex.so .

- name: Build Wheel
run: |
python3 -m pip install -U pip
python3 -m pip install -U build wheel hatch
python3 -m hatch version $(git describe --tags --abbrev=0)
python3 -m build --wheel
for PY_WHEEL in dist/*.whl
do
python3 -m wheel tags --remove --python-tag cp3 --abi-tag abi3 --platform-tag linux_x86_64 ${PY_WHEEL}
done

- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: wheels
path: dist/*.whl

#
# SHIPPING
#

upload_release:
name: Upload release
needs: [maya-win, maya-linux, maya-macos-11, maya-macos-12]
needs: [maya-win, maya-linux, maya-macos-11, maya-macos-12, python-win, python-macos, python-linux]
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Download artifacts
uses: actions/download-artifact@v3

# Omitting name: means "download all artifacts"
# Destination directory structure:
# ~/modules
# /simplex
# /<os_name>-<maya_major_version>
# /plug-ins
# simplex_maya.mll
# /py2Modules
# py2simplex.pyd
# /py3Modules
# py3simplex.pyd
# /simplex.mod

with:
path: modules/simplex

- name: Move Wheels
run: |
mv modules/simplex/wheels/*.whl .
rm -rf modules/simplex/wheels

#- name: Display structure of working directory
# run: ls -R

- name: Build Modfile
run: |
python buildmodfile.py modules/simplex.mod --name simplex --path modules/simplex

- name: Set env
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
run: |
LATEST_TAG=$(git describe --tags --abbrev=0)
echo "LatestTag: ${LATEST_TAG}"
echo "RELEASE_VERSION=${LATEST_TAG}" >> $GITHUB_ENV

- name: Create distribution
run: |
mkdir -p modules/simplex/scripts
cp -r ./scripts/simplexui modules/simplex/scripts
cp -r ./simplexui modules/simplex/scripts
cd modules
zip -r ../simplex.zip .
zip -r ../simplex-${{ env.RELEASE_VERSION }}.zip .
cd ..

- name: Upload Artifacts
if: ${{ ! startsWith(github.ref, 'refs/tags/v') }}
uses: actions/upload-artifact@v3
with:
name: simplex-module
path: simplex.zip

- name: Rename Zip
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
run: mv simplex.zip simplex-${{env.RELEASE_VERSION}}.zip
path: simplex-${{ env.RELEASE_VERSION }}.zip

- name: Upload distribution
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
Expand All @@ -302,4 +398,15 @@ jobs:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
files: |
simplex-*.zip
*.zip
*.whl

- name: Publish To PyPI
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python3 -m pip install -U pip
python3 -m pip install -U twine
python3 -m twine upload --verbose *.whl
3 changes: 2 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[submodule "include/eigen"]
path = include/eigen
url = https://github.com/eigenteam/eigen-git-mirror.git
url = https://gitlab.com/libeigen/eigen.git
branch = 3.4
[submodule "include/rapidjson"]
path = include/rapidjson
url = https://github.com/Tencent/rapidjson.git
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
cmake_minimum_required(VERSION 3.16)
cmake_minimum_required(VERSION 3.26)

project(simplex VERSION 1.0 DESCRIPTION "Blur Studio's Simplex Blendshape Combination System" LANGUAGES CXX)

set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 20)

# (defined in FindMaya.cmake, copied here for reference)
# set(MAYA_INSTALL_BASE_PATH "" CACHE STRING
# "Root path containing your maya installations, e.g. /usr/autodesk or /Applications/Autodesk/"
# )
set(MAYA_VERSION 2020 CACHE STRING "Maya version")
set(MAYA_PYTHON YES CACHE STRING "Link the python module to mayapy")
set(MAYA_2022_PYTHON 2 CACHE STRING "Major Version of python when compiling for Maya 2022")
set(MAYA_2022_PYTHON 3 CACHE STRING "Major Version of python when compiling for Maya 2022")
set(SYSTEM_PY_VERSON 3 CACHE STRING "If Not linking to mayapy, the installed version of python to use")
set(BUILD_MAYA YES CACHE STRING "Build the maya plugin")
set(BUILD_PYTHON YES CACHE STRING "Build the python module")
Expand Down
3 changes: 3 additions & 0 deletions buildmodfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ def main(outpath, modname, modver, modpath):
f"+ PLATFORM:{plat} MAYAVERSION:{year} {modname} {modver} {modrel}"
)
lines.append(f"plug-ins: {rel}")

pypath = str(rel).replace('plug-ins', 'pyModules')
lines.append(f"PYTHONPATH +:= {pypath}")
lines.append("")

if not os.path.isdir(basepath):
Expand Down
2 changes: 1 addition & 1 deletion include/eigen
Submodule eigen updated from c36efc to e7248b
2 changes: 1 addition & 1 deletion include/rapidjson
Submodule rapidjson updated 125 files
2 changes: 1 addition & 1 deletion mayaConfigure.bat
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
setlocal

SET MAYA_VERSION=2024
SET MAYA_VERSION=2022
SET BUILD=mayabuild_%MAYA_VERSION%
SET COMPILER=Visual Studio 17 2022

Expand Down
21 changes: 21 additions & 0 deletions pyConfigure.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
setlocal

SET PY_VERSION=3
SET BUILD=pybuild
SET COMPILER=Visual Studio 17 2022

SET PFX=%~dp0
cd %PFX%
rmdir %BUILD% /s /q
mkdir %BUILD%
cd %BUILD%

cmake ^
-DBUILD_MAYA=NO ^
-DMAYA_PYTHON=NO ^
-DSYSTEM_PY_VERSION=%PY_VERSION% ^
-G "%COMPILER%" ..\

cmake --build . --config RelWithDebInfo --target ALL_BUILD

pause
Loading