-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: Create a script to build adaptor packaging artifacts
The breaking change is due to updating the adaptor runtime dependency to 0.4 - Also deprecate the binary name MayaAdaptor, and add the name maya-openjd - Update the adaptor runtime dependency to 0.4, and fix up socket path into server path - Update the submitter to provide both Rez and Conda packages metadata. The Rez package names are the same for now to keep backwards compatibility. - Reduce code coverage requirement from 45 to 44, CI on one of the Python versions was a smidgeon below. Signed-off-by: Mark Wiebe <[email protected]>
- Loading branch information
Showing
8 changed files
with
261 additions
and
45 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,190 @@ | ||
#!/usr/bin/env bash | ||
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
set -xeou pipefail | ||
|
||
APP=maya | ||
ADAPTOR_NAME=deadline-cloud-for-$APP | ||
|
||
# This script generates an tar.gz artifact from $ADAPTOR_NAME and its dependencies | ||
# that can be used to create a package for running the adaptor. | ||
|
||
SCRIPTDIR=$(realpath $(dirname $0)) | ||
|
||
SOURCE=0 | ||
# Python 3.11 is for https://vfxplatform.com/ CY2024 | ||
PYTHON_VERSION=3.11 | ||
CONDA_PLATFORM=linux-64 | ||
TAR_BASE= | ||
|
||
while [ $# -gt 0 ]; do | ||
case "${1}" in | ||
--source) SOURCE=1 ; shift ;; | ||
--platform) CONDA_PLATFORM="$2" ; shift 2 ;; | ||
--python) PYTHON_VERSION="$2" ; shift 2 ;; | ||
--tar-base) TAR_BASE="$2" ; shift 2 ;; | ||
*) echo "Unexpected option: $1"; exit 1 ;; | ||
esac | ||
done | ||
|
||
if [ "$CONDA_PLATFORM" = "linux-64" ]; then | ||
PYPI_PLATFORM=manylinux2014_x86_64 | ||
elif [ "$CONDA_PLATFORM" = "win-64" ]; then | ||
PYPI_PLATFORM=win_amd64 | ||
elif [ "$CONDA_PLATFORM" = "osx-64" ]; then | ||
PYPI_PLATFORM=macosx_10_9_x86_64 | ||
else | ||
echo "Unknown Conda operating system option --platform $CONDA_PLATFORM" | ||
exit 1 | ||
fi | ||
|
||
if [ "$TAR_BASE" = "" ]; then | ||
TAR_BASE=$SCRIPTDIR/../$APP-openjd-py$PYTHON_VERSION-$CONDA_PLATFORM | ||
fi | ||
|
||
# Create a temporary prefix | ||
WORKDIR=$(mktemp -d adaptor-pkg.XXXXXXXXXX) | ||
function cleanup_workdir { | ||
echo "Cleaning up $WORKDIR" | ||
rm -rf $WORKDIR | ||
} | ||
trap cleanup_workdir EXIT | ||
|
||
PREFIX=$WORKDIR/prefix | ||
|
||
if [ "$CONDA_PLATFORM" = "win-64" ]; then | ||
BINDIR=$PREFIX/Library/bin | ||
PACKAGEDIR=$PREFIX/Library/opt/$ADAPTOR_NAME | ||
else | ||
BINDIR=$PREFIX/bin | ||
PACKAGEDIR=$PREFIX/opt/$ADAPTOR_NAME | ||
fi | ||
|
||
|
||
mkdir -p $PREFIX | ||
mkdir -p $PACKAGEDIR | ||
mkdir -p $BINDIR | ||
|
||
# Install the adaptor into the virtual env | ||
if [ $SOURCE = 1 ]; then | ||
# In source mode, openjd-adaptor-runtime-for-python must be alongside this adaptor source | ||
RUNTIME_INSTALLABLE=$SCRIPTDIR/../../openjd-adaptor-runtime-for-python | ||
ADAPTOR_INSTALLABLE=$SCRIPTDIR/.. | ||
|
||
if [ "$CONDA_PLATFORM" = "win-64" ]; then | ||
DEPS="pyyaml jsonschema pywin32" | ||
else | ||
DEPS="pyyaml jsonschema" | ||
fi | ||
|
||
for DEP in $DEPS; do | ||
pip install \ | ||
--target $PACKAGEDIR \ | ||
--platform $PYPI_PLATFORM \ | ||
--python-version $PYTHON_VERSION \ | ||
--ignore-installed \ | ||
--only-binary=:all: \ | ||
$DEP | ||
done | ||
|
||
pip install \ | ||
--target $PACKAGEDIR \ | ||
--platform $PYPI_PLATFORM \ | ||
--python-version $PYTHON_VERSION \ | ||
--ignore-installed \ | ||
--no-deps \ | ||
$RUNTIME_INSTALLABLE | ||
pip install \ | ||
--target $PACKAGEDIR \ | ||
--platform $PYPI_PLATFORM \ | ||
--python-version $PYTHON_VERSION \ | ||
--ignore-installed \ | ||
--no-deps \ | ||
$ADAPTOR_INSTALLABLE | ||
else | ||
# In PyPI mode, PyPI and/or a CodeArtifact must have these packages | ||
RUNTIME_INSTALLABLE=openjd-adaptor-runtime-for-python | ||
ADAPTOR_INSTALLABLE=$ADAPTOR_NAME | ||
|
||
pip install \ | ||
--target $PACKAGEDIR \ | ||
--platform $PYPI_PLATFORM \ | ||
--python-version $PYTHON_VERSION \ | ||
--ignore-installed \ | ||
--only-binary=:all: \ | ||
$RUNTIME_INSTALLABLE | ||
pip install \ | ||
--target $PACKAGEDIR \ | ||
--platform $PYPI_PLATFORM \ | ||
--python-version $PYTHON_VERSION \ | ||
--ignore-installed \ | ||
--no-deps \ | ||
$ADAPTOR_INSTALLABLE | ||
fi | ||
|
||
|
||
# Remove the submitter code | ||
rm -r $PACKAGEDIR/deadline/*_submitter | ||
|
||
# Remove the bin dir if there is one | ||
if [ -d $PACKAGEDIR/bin ]; then | ||
rm -r $PACKAGEDIR/bin | ||
fi | ||
|
||
PYSCRIPT="from pathlib import Path | ||
import sys | ||
reentry_exe = Path(sys.argv[0]).absolute() | ||
sys.path.append(str(reentry_exe.parent.parent / \"opt\" / \"$ADAPTOR_NAME\")) | ||
from deadline.${APP}_adaptor.${APP^}Adaptor.__main__ import main | ||
sys.exit(main(reentry_exe=reentry_exe)) | ||
" | ||
|
||
cat <<EOF > $BINDIR/$APP-openjd | ||
#!/usr/bin/env python3.11 | ||
$PYSCRIPT | ||
EOF | ||
|
||
# Temporary | ||
cp $BINDIR/$APP-openjd $BINDIR/${APP^}Adaptor | ||
|
||
chmod u+x $BINDIR/$APP-openjd $BINDIR/${APP^}Adaptor | ||
|
||
if [ $CONDA_PLATFORM = "win-64" ]; then | ||
# Install setuptools to get cli-64.exe | ||
mkdir -p $WORKDIR/tmp | ||
pip install \ | ||
--target $WORKDIR/tmp \ | ||
--platform $PYPI_PLATFORM \ | ||
--python-version $PYTHON_VERSION \ | ||
--ignore-installed \ | ||
--no-deps \ | ||
setuptools | ||
|
||
# Use setuptools' cli-64.exe to define the entry point | ||
cat <<EOF > $BINDIR/$APP-openjd-script.py | ||
#!C:\\Path\\To\\Python.exe | ||
$PYSCRIPT | ||
EOF | ||
cp $WORKDIR/tmp/setuptools/cli-64.exe $BINDIR/$APP-openjd.exe | ||
fi | ||
|
||
# Everything between the first "-" and the next "+" is the package version number | ||
PACKAGEVER=$(cd $PACKAGEDIR; echo deadline_cloud_for*) | ||
PACKAGEVER=${PACKAGEVER#*-} | ||
PACKAGEVER=${PACKAGEVER%+*} | ||
echo "Package version number is $PACKAGEVER" | ||
|
||
# Create the tar artifact | ||
GIT_TIMESTAMP="$(env TZ=UTC git log -1 --date=iso-strict-local --format="%ad")" | ||
pushd $PREFIX | ||
# See https://reproducible-builds.org/docs/archives/ for information about | ||
# these options | ||
#tar --mtime=$GIT_TIMESTAMP \ | ||
# --sort=name \ | ||
# --pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime \ | ||
# --owner=0 --group=0 --numeric-owner \ | ||
# -cf $TAR_BASE . | ||
# TODO Switch to the above command once the build environment has tar version > 1.28 | ||
tar --owner=0 --group=0 --numeric-owner \ | ||
-cf $TAR_BASE-$PACKAGEVER.tar.gz . | ||
sha256sum $TAR_BASE-$PACKAGEVER.tar.gz | ||
popd |
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
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
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
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
Oops, something went wrong.