-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: create adaptor packaging artifact script (#109)
* chore: add script to create adaptor packaging artifact Signed-off-by: wonjoel <[email protected]> Signed-off-by: Stephen Crowe <[email protected]> Co-authored-by: Joel Wong <[email protected]>
- Loading branch information
1 parent
f30af42
commit f62298b
Showing
2 changed files
with
159 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
#!/usr/bin/env bash | ||
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
set -xeou pipefail | ||
|
||
APP_LOWERCASE=keyshot | ||
APP_PASCAL_CASE=KeyShot | ||
ADAPTOR_NAME=deadline-cloud-for-$APP_LOWERCASE | ||
|
||
# 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=win-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_LOWERCASE-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 | ||
PACKAGEDIR=$PREFIX/Library/opt/$ADAPTOR_NAME | ||
else | ||
PACKAGEDIR=$PREFIX/opt/$ADAPTOR_NAME | ||
fi | ||
|
||
|
||
mkdir -p $PREFIX | ||
mkdir -p $PACKAGEDIR | ||
|
||
# Install the adaptor into the virtual env | ||
if [ $SOURCE = 1 ]; then | ||
# In source mode, openjd-adaptor-runtime-for-python and deadline-cloud must be alongside this adaptor source | ||
RUNTIME_INSTALLABLE=$SCRIPTDIR/../../openjd-adaptor-runtime-for-python | ||
CLIENT_INSTALLABLE=$SCRIPTDIR/../../deadline-cloud | ||
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 | ||
|
||
# Install these two at the same time otherwise they overwrite eachother | ||
pip install \ | ||
--target $PACKAGEDIR \ | ||
--platform $PYPI_PLATFORM \ | ||
--python-version $PYTHON_VERSION \ | ||
--only-binary=:all: \ | ||
--ignore-installed \ | ||
$ADAPTOR_INSTALLABLE $CLIENT_INSTALLABLE | ||
else | ||
# In PyPI mode, PyPI and/or a CodeArtifact must have these packages | ||
RUNTIME_INSTALLABLE=openjd-adaptor-runtime | ||
CLIENT_INSTALLABLE=deadline | ||
ADAPTOR_INSTALLABLE=$ADAPTOR_NAME | ||
|
||
pip install \ | ||
--target $PACKAGEDIR \ | ||
--platform $PYPI_PLATFORM \ | ||
--python-version $PYTHON_VERSION \ | ||
--ignore-installed \ | ||
--no-deps \ | ||
$RUNTIME_INSTALLABLE | ||
|
||
# Install these two at the same time otherwise they overwrite eachother | ||
pip install \ | ||
--target $PACKAGEDIR \ | ||
--platform $PYPI_PLATFORM \ | ||
--python-version $PYTHON_VERSION \ | ||
--ignore-installed \ | ||
--only-binary=:all: \ | ||
$ADAPTOR_INSTALLABLE $CLIENT_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 | ||
|
||
# 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