diff --git a/.github/workflows/fake-bpy-module-ci.yml b/.github/workflows/fake-bpy-module-ci.yml index a84ade832..111a43715 100644 --- a/.github/workflows/fake-bpy-module-ci.yml +++ b/.github/workflows/fake-bpy-module-ci.yml @@ -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 diff --git a/.github/workflows/fake-bpy-module-latest-build.yml b/.github/workflows/fake-bpy-module-latest-build.yml index 5e2ddced1..8d2be6c97 100644 --- a/.github/workflows/fake-bpy-module-latest-build.yml +++ b/.github/workflows/fake-bpy-module-latest-build.yml @@ -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 diff --git a/tools/pip_package/build_pip_package.sh b/tools/pip_package/build_pip_package.sh index 6e10d7ad5..42b05139a 100755 --- a/tools/pip_package/build_pip_package.sh +++ b/tools/pip_package/build_pip_package.sh @@ -58,16 +58,15 @@ PYTHON_BIN=${PYTHON_BIN:-python} # check arguments if [ $# -ne 5 ] && [ $# -ne 6 ]; then - echo "Usage: bash build_pip_package.sh []" + echo "Usage: bash build_pip_package.sh []" 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 @@ -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 @@ -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}" diff --git a/tools/pip_package/setup_blender.py b/tools/pip_package/setup.py similarity index 100% rename from tools/pip_package/setup_blender.py rename to tools/pip_package/setup.py diff --git a/tools/pip_package/setup_upbge.py b/tools/pip_package/setup_upbge.py deleted file mode 100644 index 84612a466..000000000 --- a/tools/pip_package/setup_upbge.py +++ /dev/null @@ -1,73 +0,0 @@ -import os -import glob -import datetime -from setuptools import setup, find_packages - -# module name -cur_dir = os.getcwd().replace("\\", "/") -blender_version = cur_dir.split('/')[-1].split('-')[-1] -module_name = f"fake-bge-module-{blender_version}" -if "NON_VERSION_PACKAGE" in os.environ: - if os.environ["NON_VERSION_PACKAGE"] == "true": - module_name = "fake-bge-module" # pylint: disable=C0103 - -# release version -if "RELEASE_VERSION" in os.environ: - print("Environment variable 'RELEASE_VERSION' exists, " - "so use it as release version") - release_version = os.environ["RELEASE_VERSION"] -else: - print("Environment variable 'RELEASE_VERSION' does not exist, " - "so use date as release version") - release_version = datetime.datetime.today().strftime("%Y%m%d") - -# long_description -try: - readme_path = "{}/README.rst".format( - os.path.dirname(os.path.abspath(__file__)).replace("\\", "/")) - with open(readme_path, "r", encoding="utf-8") as f: - long_description = f.read() -except IOError: - long_description = "" # pylint: disable=C0103 - -# find python module. -py_modules = list(set(glob.glob("*.py")) - {"setup.py"}) -py_modules = [os.path.splitext(m)[0] for m in py_modules] - -# find python packages and setup package data -packages = find_packages() -package_data = {pkg: ["py.typed"] for pkg in packages} - -setup( - name=module_name, - version=release_version, - url="https://github.com/nutti/fake-bge-module", - author="nutti", - author_email="nutti.metro@gmail.com", - maintainer="nutti", - maintainer_email="nutti.metro@gmail.com", - description="Collection of the fake Blender Game Engine (BGE) Python API " - "module for the code completion.", - long_description=long_description, - project_urls={ - "Bug Tracker": "https://github.com/nutti/fake-bge-module/issues", - "Documentation": "https://github.com/nutti/fake-bge-module/blob/" - "master/README.md", - "Source Code": "https://github.com/nutti/fake-bge-module", - }, - platforms=["Windows", "Linux", "Mac OS-X"], - py_modules=py_modules, - package_data=package_data, - packages=packages, - zip_safe=False, - python_requires=">=3.7", - license="MIT", - classifiers=[ - "Topic :: Multimedia :: Graphics :: 3D Modeling", - "Topic :: Multimedia :: Graphics :: 3D Rendering", - "Topic :: Text Editors :: Integrated Development Environments (IDE)", - "Programming Language :: Python", - "Programming Language :: Python :: 3", - "License :: OSI Approved :: MIT License", - ] -)