Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
nutti committed Nov 23, 2023
1 parent 9a1b718 commit 3fc4815
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 186 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/fake-bpy-module-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ jobs:
- name: Generate pip Packages
env:
RELEASE_VERSION: ${{ needs.set_versions.outputs.module_version }}
run: bash tools/pip_package/build_pip_package.sh release blender ${{ matrix.blender_version }} ./blender ./blender-bin/blender-v${{ matrix.blender_version }}-bin ${{ matrix.blender_version }}
run: bash tools/pip_package/build_pip_package.sh blender ${{ matrix.blender_version }} ./blender ./blender-bin/blender-v${{ matrix.blender_version }}-bin ${{ matrix.blender_version }}

- name: Archive pip packages
uses: actions/upload-artifact@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/fake-bpy-module-latest-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jobs:
- name: Generate pip Packages
env:
RELEASE_VERSION: ${{ needs.set_versions.outputs.module_version }}
run: bash tools/pip_package/build_pip_package.sh release blender latest ./blender ./blender-bin/blender-latest-bin
run: bash tools/pip_package/build_pip_package.sh blender latest ./blender ./blender-bin/blender-latest-bin

- name: Archive pip packages
uses: actions/upload-artifact@v2
Expand Down
166 changes: 55 additions & 111 deletions tools/pip_package/build_pip_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,15 @@ PYTHON_BIN=${PYTHON_BIN:-python}

# check arguments
if [ $# -ne 5 ] && [ $# -ne 6 ]; then
echo "Usage: bash build_pip_package.sh <develop|release> <target> <target-version> <source-dir> <blender-dir> [<mod-version>]"
echo "Usage: bash build_pip_package.sh <target> <target-version> <source-dir> <blender-dir> [<mod-version>]"
exit 1
fi

deploy_stage=${1}
target=${2}
target_version=${3}
source_dir=${4}
blender_dir=${5}
mod_version=${6:-not-specified}
target=${1}
target_version=${2}
source_dir=${3}
blender_dir=${4}
mod_version=${5:-not-specified}

# check if PYTHON_BIN binary is availble
if ! command -v "${PYTHON_BIN}" > /dev/null; then
Expand Down Expand Up @@ -98,13 +97,6 @@ if ! ${python_bin} -c "from setuptools._vendor.packaging.version import Version;
exit 1
fi

# check if the deploy_stage is develop or release
if [ ! "${deploy_stage}" = "release" ] && [ ! "${deploy_stage}" = "develop" ]; then
echo "deploy_stage must be release or develop"
exit 1
fi


# check if the specified version is supported
supported=0
if [ "${target}" = "blender" ]; then
Expand Down Expand Up @@ -143,110 +135,62 @@ if [ -e "${tmp_dir}" ]; then
exit 1
fi

# setup pre-generated-modules/release/temp directories
mkdir -p "${raw_modules_dir}"
mkdir -p "${release_dir}"
mkdir -p "${tmp_dir}" && cd "${tmp_dir}"

if [ "${deploy_stage}" = "release" ]; then
# setup pre-generated-modules/release/temp directories
mkdir -p "${raw_modules_dir}"
mkdir -p "${release_dir}"
mkdir -p "${tmp_dir}" && cd "${tmp_dir}"

# generate fake module
fake_module_dir="out"
ver=v${target_version}
if [ "${target}" = "blender" ]; then
if [ "${mod_version}" = "not-specified" ]; then
bash "${SCRIPT_DIR}/../../src/gen_module.sh" "${CURRENT_DIR}/${source_dir}" "${CURRENT_DIR}/${blender_dir}" "${target}" "${BLENDER_TAG_NAME[${ver}]}" "${target_version}" "${fake_module_dir}"
else
bash "${SCRIPT_DIR}/../../src/gen_module.sh" "${CURRENT_DIR}/${source_dir}" "${CURRENT_DIR}/${blender_dir}" "${target}" "${BLENDER_TAG_NAME[${ver}]}" "${target_version}" "${fake_module_dir}" "${mod_version}"
fi
elif [ "${target}" = "upbge" ]; then
if [ "${mod_version}" = "not-specified" ]; then
bash "${SCRIPT_DIR}/../../src/gen_module.sh" "${CURRENT_DIR}/${source_dir}" "${CURRENT_DIR}/${blender_dir}" "${target}" "${UPBGE_TAG_NAME[${ver}]}" "${target_version}" "${fake_module_dir}"
else
bash "${SCRIPT_DIR}/../../src/gen_module.sh" "${CURRENT_DIR}/${source_dir}" "${CURRENT_DIR}/${blender_dir}" "${target}" "${UPBGE_TAG_NAME[${ver}]}" "${target_version}" "${fake_module_dir}" "${mod_version}"
fi
# generate fake module
fake_module_dir="out"
ver=v${target_version}
if [ "${target}" = "blender" ]; then
if [ "${mod_version}" = "not-specified" ]; then
bash "${SCRIPT_DIR}/../../src/gen_module.sh" "${CURRENT_DIR}/${source_dir}" "${CURRENT_DIR}/${blender_dir}" "${target}" "${BLENDER_TAG_NAME[${ver}]}" "${target_version}" "${fake_module_dir}"
else
echo "${target} is not supported."
exit 1
bash "${SCRIPT_DIR}/../../src/gen_module.sh" "${CURRENT_DIR}/${source_dir}" "${CURRENT_DIR}/${blender_dir}" "${target}" "${BLENDER_TAG_NAME[${ver}]}" "${target_version}" "${fake_module_dir}" "${mod_version}"
fi
elif [ "${target}" = "upbge" ]; then
if [ "${mod_version}" = "not-specified" ]; then
bash "${SCRIPT_DIR}/../../src/gen_module.sh" "${CURRENT_DIR}/${source_dir}" "${CURRENT_DIR}/${blender_dir}" "${target}" "${UPBGE_TAG_NAME[${ver}]}" "${target_version}" "${fake_module_dir}"
else
bash "${SCRIPT_DIR}/../../src/gen_module.sh" "${CURRENT_DIR}/${source_dir}" "${CURRENT_DIR}/${blender_dir}" "${target}" "${UPBGE_TAG_NAME[${ver}]}" "${target_version}" "${fake_module_dir}" "${mod_version}"
fi
else
echo "${target} is not supported."
exit 1
fi

# Install package build tool.
${python_bin} -m pip install build

# Build standalone (.zip) package.
zip_dir="fake_${PACKAGE_NAME[$target]}_modules_${target_version}-${release_version}"
cp -r ${fake_module_dir} "${zip_dir}"
zip_file_name="fake_${PACKAGE_NAME[$target]}_modules_${target_version}-${release_version}.zip"
zip -r "${zip_file_name}" "${zip_dir}"
mv "${zip_file_name}" "${raw_modules_dir}"
rm -r "${zip_dir}"

# Build pip (.whl) package.
mv ${fake_module_dir}/* .
rm -r ${fake_module_dir}
cp "${SCRIPT_DIR}/setup_${target}.py" ./setup.py
cp "${SCRIPT_DIR}/../../README.md" .
# Install package build tool.
${python_bin} -m pip install build

# Build standalone (.zip) package.
zip_dir="fake_${PACKAGE_NAME[$target]}_modules_${target_version}-${release_version}"
cp -r ${fake_module_dir} "${zip_dir}"
zip_file_name="fake_${PACKAGE_NAME[$target]}_modules_${target_version}-${release_version}.zip"
zip -r "${zip_file_name}" "${zip_dir}"
mv "${zip_file_name}" "${raw_modules_dir}"
rm -r "${zip_dir}"

# Build pip (.whl) package.
mv ${fake_module_dir}/* .
rm -r ${fake_module_dir}
cp "${SCRIPT_DIR}/../../README.md" .
cp "${SCRIPT_DIR}/../../pyproject.toml" .
sed -i -e "s/^name = \"fake-${PACKAGE_NAME[$target]}-module\"$/name = \"fake-${PACKAGE_NAME[$target]}-module-${target_version}\"/g" pyproject.toml
rm -rf fake_"${PACKAGE_NAME[$target]}"_module*.egg-info/ dist/ build/
ls -R .
${python_bin} -m build
mv dist "${release_dir}/${target_version}"

# Create non-versioned package for latest release
if [ "${target_version}" = "latest" ]; then
cp "${SCRIPT_DIR}/../../pyproject.toml" .
sed -i -e "s/^name = \"fake-bpy-module\"$/name = \"fake-bpy-module-${target_version}\"/g" pyproject.toml
rm -rf fake_"${PACKAGE_NAME[$target]}"_module*.egg-info/ dist/ build/
ls -R .
${python_bin} -m build
mv dist "${release_dir}/${target_version}"

# Create non-versioned package for latest release
if [ "${target_version}" = "latest" ]; then
cp "${SCRIPT_DIR}/../../pyproject.toml" .
${python_bin} -m build
mv dist "${release_dir}/non-version"
fi

# clean up
cd "${CURRENT_DIR}"
rm -rf "${tmp_dir}"

elif [ "${deploy_stage}" = "develop" ]; then
# setup pre-generated-modules/release/temp directories
mkdir -p "${raw_modules_dir}"
mkdir -p "${release_dir}" && cd "${release_dir}"
cp "${SCRIPT_DIR}/setup_${target}.py" ./setup.py

# generate fake module
fake_module_dir="out"
ver=v${target_version}
if [ "${target}" = "blender" ]; then
if [ "${mod_version}" = "not-specified" ]; then
bash "${SCRIPT_DIR}/../../src/gen_module.sh" "${CURRENT_DIR}/${source_dir}" "${CURRENT_DIR}/${blender_dir}" "${target}" "${BLENDER_TAG_NAME[${ver}]}" "${target_version}" "${fake_module_dir}"
else
bash "${SCRIPT_DIR}/../../src/gen_module.sh" "${CURRENT_DIR}/${source_dir}" "${CURRENT_DIR}/${blender_dir}" "${target}" "${BLENDER_TAG_NAME[${ver}]}" "${target_version}" "${fake_module_dir}" "${mod_version}"
fi
elif [ "${target}" = "upbge" ]; then
if [ "${mod_version}" = "not-specified" ]; then
bash "${SCRIPT_DIR}/../../src/gen_module.sh" "${CURRENT_DIR}/${source_dir}" "${CURRENT_DIR}/${blender_dir}" "${target}" "${UPBGE_TAG_NAME[${ver}]}" "${target_version}" "${fake_module_dir}"
else
bash "${SCRIPT_DIR}/../../src/gen_module.sh" "${CURRENT_DIR}/${source_dir}" "${CURRENT_DIR}/${blender_dir}" "${target}" "${UPBGE_TAG_NAME[${ver}]}" "${target_version}" "${fake_module_dir}" "${mod_version}"
fi
else
echo "${target} is not supported."
exit 1
fi

# Build standalone (.zip) package.
zip_dir="fake_${PACKAGE_NAME[$target]}_modules_${target_version}-${release_version}"
cp -r ${fake_module_dir} "${zip_dir}"
zip_file_name="fake_${PACKAGE_NAME[$target]}_modules_${target_version}-${release_version}.zip"
zip -r "${zip_file_name}" ${fake_module_dir}
mv "${zip_file_name}" "${raw_modules_dir}"
rm -r "${zip_dir}"

# Build pip (.whl) package.
mv ${fake_module_dir}/* .
rm -r ${fake_module_dir}
ls -R .
${python_bin} setup.py develop

# clean up
cd "${CURRENT_DIR}"
rm -rf "${tmp_dir}"
mv dist "${release_dir}/non-version"
fi

exit 0
# clean up
cd "${CURRENT_DIR}"
rm -rf "${tmp_dir}"
File renamed without changes.
73 changes: 0 additions & 73 deletions tools/pip_package/setup_upbge.py

This file was deleted.

0 comments on commit 3fc4815

Please sign in to comment.