diff --git a/.github/workflows/fake-bge-module-ci.yml b/.github/workflows/fake-bge-module-ci.yml new file mode 100644 index 00000000..e5222e7f --- /dev/null +++ b/.github/workflows/fake-bge-module-ci.yml @@ -0,0 +1,251 @@ +--- +# yamllint disable rule:line-length +name: fake-bge-module CI + +on: # yamllint disable-line rule:truthy + push: + branches: + - main + - 'run-ci/**' + pull_request: + release: + types: + - released + +jobs: + set_versions: + name: Set build versions + runs-on: ubuntu-latest + outputs: + module_version: ${{ steps.set_module_version.outputs.module_version }} + file_version: ${{ steps.set_file_version.outputs.file_version }} + steps: + # Use ISO 8601 date (in UTC) + timestamp (in UTC) + - name: Create generic module version + run: echo "MODULE_VERSION=$(date -u +%Y%m%d).dev$(date -u +%H%M%S)" >> $GITHUB_ENV + + # Use the tag name for a release + - name: Override release module version + if: github.event_name == 'release' + run: echo "MODULE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + + # Add addtional git sha ref + - name: Override PR module version + if: github.event_name == 'pull_request' + run: echo "MODULE_VERSION=${MODULE_VERSION}+${GITHUB_SHA::8}" >> $GITHUB_ENV + + # Set module version output + - name: Set module version + id: set_module_version + run: echo ::set-output name=module_version::${MODULE_VERSION} + + # Use ISO 8601 timestamps (in UTC) for output/file version + - name: Set file version + id: set_file_version + run: echo ::set-output name=file_version::$(date -u +%Y%m%dT%H%M%SZ) + + build_modules: + name: Build modules + runs-on: ubuntu-latest + needs: [set_versions] + strategy: + fail-fast: false + matrix: + upbge_version: + [ + "0.2.5", + "0.30", "0.36" + ] + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.12" + cache: "pip" + cache-dependency-path: 'src/requirements.txt' + + - name: Install python dependencies + run: | + pip install -r src/requirements.txt + + - name: UPBGE downloads cache + uses: actions/cache@v3 + id: upbge-bin-cache + with: + path: upbge-bin + key: upbge-binaries-${{ runner.os }}-${{ matrix.upbge_version }}-${{ hashFiles('**/tools/utils/download_upbge.sh') }} + + - name: Test fake_bpy_module core module + run: bash tests/run_pre_tests.sh src + + - name: Install UPBGE binary dependencies + run: | + sudo apt update + sudo apt install --no-install-recommends -y libglu1-mesa libegl1 libxxf86vm1 libxfixes3 libxi6 libxkbcommon0 libgl1 libjack0 libopenimageio-dev libpulse-dev + + - name: Install fake-bge-module tools + run: sudo apt install --no-install-recommends -y pandoc + + - name: Download UPBGE files + if: steps.upbge-bin-cache.outputs.cache-hit != 'true' + run: bash tools/utils/download_upbge.sh ${{ matrix.upbge_version }} upbge-bin + + - name: Checkout UPBGE from Github + uses: actions/checkout@v4 + with: + repository: "upbge/upbge" + path: upbge + + - name: Generate pip Packages + if: contains(github.ref, 'run-ci/') + env: + RELEASE_VERSION: ${{ needs.set_versions.outputs.module_version }} + GEN_MODULE_CODE_FORMAT: "ruff" + GEN_MODULE_OUTPUT_LOG_LEVEL: "debug" + ENABLE_PYTHON_PROFILER: false + run: bash tools/pip_package/build_pip_package.sh upbge ${{ matrix.upbge_version }} ./upbge ./upbge-bin/upbge-v${{ matrix.upbge_version }}-bin ${{ matrix.upbge_version }} + + - name: Generate pip Packages + if: "!contains(github.ref, 'run-ci/')" + env: + RELEASE_VERSION: ${{ needs.set_versions.outputs.module_version }} + GEN_MODULE_CODE_FORMAT: "ruff" + GEN_MODULE_OUTPUT_LOG_LEVEL: "warn" + ENABLE_PYTHON_PROFILER: false + run: bash tools/pip_package/build_pip_package.sh upbge ${{ matrix.upbge_version }} ./upbge ./upbge-bin/upbge-v${{ matrix.upbge_version }}-bin ${{ matrix.upbge_version }} + + - name: Archive pip packages + uses: actions/upload-artifact@v3 + with: + name: fake_bge_modules_${{ matrix.upbge_version}}_pip_${{ needs.set_versions.outputs.file_version }} + path: release + + - name: Archive raw modules + uses: actions/upload-artifact@v3 + with: + name: fake_bge_modules_${{ matrix.upbge_version}}_raw_${{ needs.set_versions.outputs.file_version }} + path: "raw_modules/fake_bge_module*" + + - name: Run Ruff flake8-pyi checks + run: bash tools/pip_package/run_ruff_flake8_pyi.sh upbge ${{ matrix.upbge_version }} + + - name: Test Generated Modules + run: bash tests/run_tests.sh raw_modules + + - name: Test generated pip module against Cycles addon + # Using a wildcard instead of + # ${{ needs.set_versions.outputs.module_version }} below, because the + # pip filenames do not respect leading zeros: + # + # For example: 00:29:45 UTC will create a file version + # "...dev2945-py3-none..." and not use {{ module_version }} + # "...dev002945-py3-none..." + run: bash tests/pylint_cycles.sh upbge ${{ matrix.upbge_version }} ./upbge/ ./release/${{ matrix.upbge_version }}/fake_bge_module_${{ matrix.upbge_version }}-*-py3-none-any.whl + + - name: Collect failure state + if: failure() + run: bash tools/collect_failure_state/collect_failure_state.sh /tmp/failure_state_${{ matrix.upbge_version}} + + - name: Store failure state + if: failure() + uses: actions/upload-artifact@v3 + with: + name: failure_state_${{ matrix.upbge_version}} + path: /tmp/failure_state_${{ matrix.upbge_version}} + + pypi_release_test: + name: PyPI Release test + needs: [build_modules] + if: | + github.repository == 'nutti/fake-bge-module' && + github.event_name != 'pull_request' + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + upbge_version: + [ + "0.2.5", + "0.30", "0.36" + ] + steps: + - name: Fetch artifacts + uses: actions/download-artifact@v3 + with: + path: dist + + # Publish to TestPyPi on each merge to main + - name: Publish distribution 📦 to Test PyPI + uses: pypa/gh-action-pypi-publish@v1.3.1 + with: + password: ${{ secrets.test_pypi_token }} + repository_url: https://test.pypi.org/legacy/ + packages_dir: "dist/fake_bge_modules_${{ matrix.upbge_version }}_pip_*/*/" + + pypi_release: + name: PyPI Release fake-bge-module + needs: [pypi_release_test] + if: | + github.repository == 'nutti/fake-bge-module' && + github.event_name == 'release' + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + upbge_version: + [ + "0.2.5", + "0.30", "0.36" + ] + steps: + - name: Fetch Artifacts + uses: actions/download-artifact@v3 + with: + path: dist + + - name: Publish distribution 📦 to PyPI + uses: pypa/gh-action-pypi-publish@v1.3.1 + with: + password: ${{ secrets.pypi_token }} + packages_dir: "dist/fake_bge_modules_${{ matrix.upbge_version }}_pip_*/*/" + + upload_github_release_assets: + name: Upload Artifacts to GitHub Release + needs: [pypi_release_test] + if: | + github.repository == 'nutti/fake-bge-module' && + github.event_name == 'release' + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + upbge_version: + [ + "0.2.5", + "0.30", "0.36" + ] + steps: + - name: Fetch Artifacts + uses: actions/download-artifact@v3 + with: + path: dist + + - name: Store Asset Information + run: | + export FAKE_BGE_MODULE_FILEPATH=$(ls -1 dist/fake_bge_modules_${{ matrix.upbge_version }}_raw_*/*.zip | head -n 1) && echo ${FAKE_BGE_MODULE_FILEPATH} + echo "FAKE_BGE_MODULE_FILEPATH=${FAKE_BGE_MODULE_FILEPATH}" >> $GITHUB_ENV + echo "FAKE_BGE_MODULE_FILENAME=$(basename "${FAKE_BGE_MODULE_FILEPATH}")" >> $GITHUB_ENV + echo "MIME_TYPE=$(file --mime-type -b "${FAKE_BGE_MODULE_FILEPATH}")" >> $GITHUB_ENV + + - name: Upload ${{ matrix.upbge_version }} + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.TOKEN_FOR_ACTIONS }} + with: + upload_url: ${{ github.event.release.upload_url }} + asset_path: ${{ env.FAKE_BGE_MODULE_FILEPATH }} + asset_name: ${{ env.FAKE_BGE_MODULE_FILENAME }} + asset_content_type: ${{ env.MIME_TYPE }} diff --git a/.github/workflows/fake-bge-module-latest-build.yml b/.github/workflows/fake-bge-module-latest-build.yml new file mode 100644 index 00000000..6fe62a3b --- /dev/null +++ b/.github/workflows/fake-bge-module-latest-build.yml @@ -0,0 +1,218 @@ +--- +# yamllint disable rule:line-length +name: fake-bge-module Latest Build + +on: # yamllint disable-line rule:truthy + workflow_dispatch: + schedule: + - cron: "0 6 * * *" + push: + branches: + - main + - 'perf/**' + - 'run-ci/**' + pull_request: + +jobs: + set_versions: + name: Set build versions + runs-on: ubuntu-latest + if: | + github.repository == 'nutti/fake-bge-module' || + github.event_name != 'schedule' + outputs: + module_version: ${{ steps.set_module_version.outputs.module_version }} + file_version: ${{ steps.set_file_version.outputs.file_version }} + steps: + # Use ISO 8601 date (in UTC) + timestamp (in UTC) + - name: Create generic module version + run: echo "MODULE_VERSION=$(date -u +%Y%m%d).dev$(date -u +%H%M%S)" >> $GITHUB_ENV + + # Use ISO 8601 date (in UTC) for a scheduled release + - name: Create generic module version + if: github.event_name == 'schedule' + run: echo "MODULE_VERSION=$(date -u +%Y%m%d)" >> $GITHUB_ENV + + # Set module version output + - name: Set module version + id: set_module_version + run: echo ::set-output name=module_version::${MODULE_VERSION} + + # Use ISO 8601 timestamps (in UTC) for output/file version + - name: Set file version + id: set_file_version + run: echo ::set-output name=file_version::$(date -u +%Y%m%dT%H%M%SZ) + + build_modules: + name: Build modules + runs-on: ubuntu-22.04 + if: | + github.repository == 'nutti/fake-bge-module' || + github.event_name != 'schedule' + needs: [set_versions] + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.12" + cache: "pip" + cache-dependency-path: 'src/requirements.txt' + + - name: Install python dependencies + run: | + pip install -r src/requirements.txt + + - name: Test fake_bpy_module core module + run: bash tests/run_pre_tests.sh src + + - name: Install UPBGE binary dependencies + run: | + sudo apt update + sudo apt install --no-install-recommends -y libglu1-mesa libegl1 libxxf86vm1 libxfixes3 libxi6 libxkbcommon0 libgl1 + + - name: Install fake-bge-module tools + run: sudo apt install --no-install-recommends -y pandoc + + - name: Get UPBGE artifact URL + id: get_upbge_artifact_url + run: echo ::set-output name=artifact_url::$(bash tools/utils/get_latest_artifacts_url.sh nutti upbge-daily-build "UPBGE daily build") + + - name: Cache UPBGE binary + id: cache-upbge-bin + uses: actions/cache@v3 + with: + path: upbge-bin/upbge-latest-bin + key: ${{ runner.os }}-upbge-${{ steps.get_upbge_artifact_url.outputs.artifact_url }} + + - name: Download latest UPBGE files from nutti/upbge-daily-build artifacts + if: steps.cache-upbge-bin.outputs.cache-hit != 'true' + run: bash tools/utils/download_latest_upbge.sh nutti upbge-daily-build "UPBGE daily build" ./upbge-bin ${{ secrets.TOKEN_FOR_ACTION_UPBGE_DAILY_BUILD }} + + - name: Checkout UPBGE from Github + uses: actions/checkout@v4 + with: + repository: "upbge/upbge" + path: upbge + + - name: Generate pip Packages + if: contains(github.ref, 'run-ci/') + env: + RELEASE_VERSION: ${{ needs.set_versions.outputs.module_version }} + GEN_MODULE_CODE_FORMAT: "ruff" + GEN_MODULE_OUTPUT_LOG_LEVEL: "debug" + ENABLE_PYTHON_PROFILER: false + run: bash tools/pip_package/build_pip_package.sh upbge latest ./upbge ./upbge-bin/upbge-latest-bin + + - name: Generate pip Packages + if: contains(github.ref, 'perf/') + env: + RELEASE_VERSION: ${{ needs.set_versions.outputs.module_version }} + GEN_MODULE_CODE_FORMAT: "ruff" + GEN_MODULE_OUTPUT_LOG_LEVEL: "warn" + ENABLE_PYTHON_PROFILER: true + run: bash tools/pip_package/build_pip_package.sh upbge latest ./upbge ./upbge-bin/upbge-latest-bin + + - name: Generate pip Packages + if: "!contains(github.ref, 'run-ci/') && !contains(github.ref, 'perf/')" + env: + RELEASE_VERSION: ${{ needs.set_versions.outputs.module_version }} + GEN_MODULE_CODE_FORMAT: "ruff" + GEN_MODULE_OUTPUT_LOG_LEVEL: "warn" + ENABLE_PYTHON_PROFILER: false + run: bash tools/pip_package/build_pip_package.sh upbge latest ./upbge ./upbge-bin/upbge-latest-bin + + - name: Archive pip packages + uses: actions/upload-artifact@v3 + with: + name: fake_bge_modules_latest_pip_${{ needs.set_versions.outputs.file_version }} + path: release + + - name: Archive raw modules + uses: actions/upload-artifact@v3 + with: + name: fake_bge_modules_latest_raw_${{ needs.set_versions.outputs.file_version }} + path: "raw_modules/fake_bge_module*" + + - name: Run Ruff flake8-pyi checks + run: bash tools/pip_package/run_ruff_flake8_pyi.sh upbge latest + + - name: Test Generated Modules + run: bash tests/run_tests.sh raw_modules + + - name: Test generated pip module against Cycles addon + run: bash tests/pylint_cycles.sh upbge latest ./upbge/ ./release/latest/fake_bge_module_latest-*-py3-none-any.whl + + - name: Collect profiler result + if: contains(github.ref, 'perf/') + run: cp profiler_result.prof /tmp/profiler_result.prof + + - name: Store profiler result + if: contains(github.ref, 'perf/') + uses: actions/upload-artifact@v3 + with: + name: profiler_result + path: /tmp/profiler_result.prof + + - name: Collect failure state + if: failure() + run: bash tools/collect_failure_state/collect_failure_state.sh /tmp/failure_state + + - name: Store failure state + if: failure() + uses: actions/upload-artifact@v3 + with: + name: failure_state + path: /tmp/failure_state + + pypi_release_test: + name: PyPI Release test + needs: [build_modules] + if: | + github.repository == 'nutti/fake-bge-module' && + github.event_name != 'pull_request' + runs-on: ubuntu-latest + steps: + - name: Fetch artifacts + uses: actions/download-artifact@v3 + with: + path: dist + + # Publish to TestPyPi on each merge to main + - name: Publish distribution 📦 to Test PyPI (Versioned Package) + uses: pypa/gh-action-pypi-publish@v1.3.1 + with: + password: ${{ secrets.test_pypi_token }} + repository_url: https://test.pypi.org/legacy/ + packages_dir: "dist/fake_bge_modules_latest_pip_*/latest/" + - name: Publish distribution 📦 to Test PyPI (Non-versioned Package) + uses: pypa/gh-action-pypi-publish@v1.3.1 + with: + password: ${{ secrets.test_pypi_token }} + repository_url: https://test.pypi.org/legacy/ + packages_dir: "dist/fake_bge_modules_latest_pip_*/non-version/" + + pypi_release: + name: PyPI Release fake-bge-module + needs: [pypi_release_test] + if: | + github.repository == 'nutti/fake-bge-module' && + github.event_name == 'schedule' + runs-on: ubuntu-latest + steps: + - name: Fetch Artifacts + uses: actions/download-artifact@v3 + with: + path: dist + - name: Publish distribution 📦 to PyPI (Versioned Package) + uses: pypa/gh-action-pypi-publish@v1.3.1 + with: + password: ${{ secrets.pypi_token }} + packages_dir: "dist/fake_bge_modules_latest_pip_*/latest/" + - name: Publish distribution 📦 to PyPI (Non-versioned Package) + uses: pypa/gh-action-pypi-publish@v1.3.1 + with: + password: ${{ secrets.pypi_token }} + packages_dir: "dist/fake_bge_modules_latest_pip_*/non-version/" diff --git a/.github/workflows/fake-bpy-module-ci.yml b/.github/workflows/fake-bpy-module-ci.yml index ae00ef44..fb642bd5 100644 --- a/.github/workflows/fake-bpy-module-ci.yml +++ b/.github/workflows/fake-bpy-module-ci.yml @@ -16,6 +16,7 @@ jobs: set_versions: name: Set build versions runs-on: ubuntu-latest + if: github.repository == 'nutti/fake-bpy-module' outputs: module_version: ${{ steps.set_module_version.outputs.module_version }} file_version: ${{ steps.set_file_version.outputs.file_version }} @@ -47,6 +48,7 @@ jobs: build_modules: name: Build modules runs-on: ubuntu-latest + if: github.repository == 'nutti/fake-bpy-module' needs: [set_versions] strategy: fail-fast: false @@ -135,7 +137,7 @@ jobs: path: "raw_modules/fake_bpy_module*" - name: Run Ruff flake8-pyi checks - run: bash tools/pip_package/run_ruff_flake8_pyi.sh ${{ matrix.blender_version }} + run: bash tools/pip_package/run_ruff_flake8_pyi.sh blender ${{ matrix.blender_version }} - name: Test Generated Modules run: bash tests/run_tests.sh raw_modules @@ -164,7 +166,9 @@ jobs: pypi_release_test: name: PyPI Release test needs: [build_modules] - if: github.event_name != 'pull_request' + if: | + github.repository == 'nutti/fake-bpy-module' && + github.event_name != 'pull_request' runs-on: ubuntu-latest strategy: fail-fast: false @@ -194,7 +198,9 @@ jobs: pypi_release: name: PyPI Release fake-bpy-module needs: [pypi_release_test] - if: github.event_name == 'release' + if: | + github.repository == 'nutti/fake-bpy-module' && + github.event_name == 'release' runs-on: ubuntu-latest strategy: fail-fast: false @@ -222,7 +228,9 @@ jobs: upload_github_release_assets: name: Upload Artifacts to GitHub Release needs: [pypi_release_test] - if: github.event_name == 'release' + if: | + github.repository == 'nutti/fake-bpy-module' && + github.event_name == 'release' runs-on: ubuntu-latest strategy: fail-fast: false diff --git a/.github/workflows/fake-bpy-module-latest-build.yml b/.github/workflows/fake-bpy-module-latest-build.yml index 3fde9d95..50b5ef55 100644 --- a/.github/workflows/fake-bpy-module-latest-build.yml +++ b/.github/workflows/fake-bpy-module-latest-build.yml @@ -17,6 +17,7 @@ jobs: set_versions: name: Set build versions runs-on: ubuntu-latest + if: github.repository == 'nutti/fake-bpy-module' outputs: module_version: ${{ steps.set_module_version.outputs.module_version }} file_version: ${{ steps.set_file_version.outputs.file_version }} @@ -43,6 +44,7 @@ jobs: build_modules: name: Build modules runs-on: ubuntu-22.04 + if: github.repository == 'nutti/fake-bpy-module' needs: [set_versions] steps: - name: Checkout repo @@ -132,7 +134,7 @@ jobs: path: "raw_modules/fake_bpy_module*" - name: Run Ruff flake8-pyi checks - run: bash tools/pip_package/run_ruff_flake8_pyi.sh latest + run: bash tools/pip_package/run_ruff_flake8_pyi.sh blender latest - name: Test Generated Modules run: bash tests/run_tests.sh raw_modules @@ -165,7 +167,9 @@ jobs: pypi_release_test: name: PyPI Release test needs: [build_modules] - if: github.event_name != 'pull_request' + if: | + github.repository == 'nutti/fake-bpy-module' && + github.event_name != 'pull_request' runs-on: ubuntu-latest steps: - name: Fetch artifacts @@ -190,7 +194,9 @@ jobs: pypi_release: name: PyPI Release fake-bpy-module needs: [pypi_release_test] - if: github.event_name == 'schedule' + if: | + github.repository == 'nutti/fake-bpy-module' && + github.event_name == 'schedule' runs-on: ubuntu-latest steps: - name: Fetch Artifacts diff --git a/docs/generate_modules.md b/docs/generate_modules.md index 63bb85a9..9a1e2031 100644 --- a/docs/generate_modules.md +++ b/docs/generate_modules.md @@ -22,12 +22,22 @@ The generating script uses the packages listed on [requirements.txt](../src/requirements.txt). Execute below command to install requirement packages. +For fake-bpy-module: + ```bash git clone https://github.com/nutti/fake-bpy-module.git cd fake-bpy-module pip install -r src/requirements.txt ``` +For fake-bge-module: + +```bash +git clone https://github.com/nutti/fake-bge-module.git +cd fake-bge-module +pip install -r src/requirements.txt +``` + ### Setup IDE After generating modules, you need to setup IDE to enable a code completion. @@ -38,47 +48,70 @@ After generating modules, you need to setup IDE to enable a code completion. ## Case 1: Use utility script -### 1. Download Blender binary +### 1. Download Blender/UPBGE binary + +From below sites, download Blender or UPBGE binary whose version is the +version you try to generate modules. + +* Blender: [https://download.blender.org/release/](https://download.blender.org/release/) +* UPBGE: [https://upbge.org/](https://upbge.org/) -Download Blender binary from [Blender official download site](https://download.blender.org/release/). -Download Blender whose version is the version you try to generate modules. +### 2. Download Blender/UPBGE sources -### 2. Download Blender sources +For fake-bpy-module: ```bash git clone https://projects.blender.org/blender/blender.git ``` -### 3. Download fake-bpy-module sources +For fake-bge-module: -Download the fake-bpy-module sources from GitHub. +```bash +git clone https://github.com/UPBGE/upbge.git +``` -Use Git and clone fake-bpy-module repository. +### 3. Download fake-bpy-module/fake-bge-module sources + +Download the fake-bpy-module/fake-bge-module sources from GitHub. +Use Git to clone repository. + +For fake-bpy-module: ```bash -git clone https://github.com/nutti/fake-bpy-module.git +export TARGET=bpy +``` + +For fake-bge-module: + +```bash +export TARGET=bge +``` + +```bash +git clone https://github.com/nutti/fake-${TARGET}-module.git ``` Or, you can download .zip file from GitHub. -[https://github.com/nutti/fake-bpy-module/archive/main.zip](https://github.com/nutti/fake-bpy-module/archive/main.zip) +* fake-bpy-module: [https://github.com/nutti/fake-bpy-module/archive/main.zip](https://github.com/nutti/fake-bpy-module/archive/main.zip) +* fake-bge-module: [https://github.com/nutti/fake-bge-module/archive/main.zip](https://github.com/nutti/fake-bge-module/archive/main.zip) ### 4. Run script ```bash -cd fake-bpy-module/src +cd fake-${TARGET}-module/src bash gen_module.sh [] ``` -* ``: Specify Blender sources directory. -* ``: Specify Blender binary directory. +* ``: Specify Blender/UPBGE sources directory. +* ``: Specify Blender/UPBGE binary directory. * ``: `blender` or `upbge`. -* ``: Specify target Blender source's branch for the +* ``: Specify target Blender/UPBGE source's branch for the generating modules. * If you want to generate modules for 2.79, specify `v2.79` - * If you want to generate modules for newest Blender version, specify `main` + * If you want to generate modules for newest Blender/UPBGE version, specify `main` * ``: Specify target version. * ``: Specify directory where generated modules are output. * ``: Modify APIs by using patch files located in `mods` directory. @@ -99,13 +132,16 @@ PYTHON_BIN=/path/to/python3.12 bash gen_module.sh ```bash -cd fake-bpy-module/src +cd fake-${TARGET}-module/src mkdir -p mods/generated_mods ${BLENDER_BIN}/blender --background --factory-startup -noaudio --python-exit-code 1 --python gen_modfile/gen_external_modules_modfile.py -- -m addon_utils -o mods/generated_mods/gen_modules_modfile -f json @@ -206,7 +261,7 @@ bash tools/gen_module/run_gen_module_in_docker.sh ``` -* ``: Specify blender version. +* ``: Specify Blender/UPBGE version. `` is automatically determined by `` version. @@ -214,10 +269,10 @@ bash tools/gen_module/run_gen_module_in_docker.sh | Directory | Contents | |----|----| -| `build/blender-bin` | Blender binaries | -| `build/blender-src` | Blender source code | -| `build/examples` | Blender Python API sample code | +| `build/blender-bin` | Blender/UPBGE binaries | +| `build/blender-src` | Blender/UPBGE source code | +| `build/examples` | Blender/UPBGE Python API sample code | | `build/results` | Result `*.pyi` files | -| `build/sphinx-in` | Blender Python API documents | +| `build/sphinx-in` | Blender/UPBGE Python API documents | | `build/sphinx-in-tmp` | ??? | -| `downloads` | Blender archives | +| `downloads` | Blender/UPBGE archives | diff --git a/docs/github_actions_tests.md b/docs/github_actions_tests.md index 7573ed2f..ccc4f948 100644 --- a/docs/github_actions_tests.md +++ b/docs/github_actions_tests.md @@ -28,7 +28,8 @@ You can run GitHub Actions using the following commands: * Lint * `bash tools/github_actions_tests/run_github_actions_tests.sh --workflows .github/workflows/lint.yml push` * Latest bulid test - * `bash tools/github_actions_tests/run_github_actions_tests.sh --workflows .github/workflows/fake-bpy-module-latest-build.yml --job build_modules` + * For fake-bpy-module: `bash tools/github_actions_tests/run_github_actions_tests.sh --workflows .github/workflows/fake-bpy-module-latest-build.yml --job build_modules` + * For fake-bge-module: `bash tools/github_actions_tests/run_github_actions_tests.sh --workflows .github/workflows/fake-bge-module-latest-build.yml --job build_modules` * All push test * `bash tools/github_actions_tests/run_github_actions_tests.sh push` * Show help diff --git a/docs/setup_pycharm.md b/docs/setup_pycharm.md index e8892d0e..5d11c8fa 100644 --- a/docs/setup_pycharm.md +++ b/docs/setup_pycharm.md @@ -29,7 +29,7 @@ Launch PyCharm and do all below procedures. 7. Select the path where generated modules are located, and click *OK*. 8. Click *OK* repeatedly until *Settings* (Windows) or *Preferences* (macOS) window is closed. -9. Now, you can complete the code related to the Blender Python API. +9. Now, you can complete the code related to the Blender/UPBGE Python API. diff --git a/src/fake_bpy_module/analyzer/directives.py b/src/fake_bpy_module/analyzer/directives.py index 80f2ff7f..7335110c 100644 --- a/src/fake_bpy_module/analyzer/directives.py +++ b/src/fake_bpy_module/analyzer/directives.py @@ -275,7 +275,7 @@ def run(self) -> list[ModuleNode]: if module_name == "bpy.data": module_name = "bpy" elif config.get_target() == "upbge": - if config.get_target_version() in ["latest"]: + if config.get_target_version() in ["0.30", "0.36", "latest"]: if module_name == "bpy.data": module_name = "bpy" module_node.element(NameNode).add_text(module_name) diff --git a/src/fake_bpy_module/support.py b/src/fake_bpy_module/support.py index 22a66483..3b6aff3e 100644 --- a/src/fake_bpy_module/support.py +++ b/src/fake_bpy_module/support.py @@ -20,6 +20,7 @@ SUPPORTED_MOD_UPBGE_VERSION: list[str] = [ "0.2.5", + "0.30", "0.36", "latest" ] @@ -34,5 +35,6 @@ SUPPORTED_UPBGE_VERSION: list[str] = [ "0.2.5", + "0.30", "0.36", "latest" ] diff --git a/src/gen_module.sh b/src/gen_module.sh index efa64944..68d4b3e1 100755 --- a/src/gen_module.sh +++ b/src/gen_module.sh @@ -194,19 +194,17 @@ if [ "${target}" = "blender" ]; then done fi elif [ "${target}" = "upbge" ]; then - if [ "${git_ref}" = "v0.2.5" ] || [ "${git_ref}" = "master" ]; then - # .. code-block:: none -> .. code-block:: python - echo " Fix: Invalid code-block argument" - # shellcheck disable=SC2044 - for rst_file in $(find "${tmp_dir}/sphinx-in" -name "*.rst"); do - search_str=".. code-block:: none" - replace_str=".. code-block:: python" - if grep -q "${search_str}" "${rst_file}"; then - echo " ${rst_file}" - sed -i "s/${search_str}/${replace_str}/g" "${rst_file}" - fi - done - fi + # .. code-block:: none -> .. code-block:: python + echo " Fix: Invalid code-block argument" + # shellcheck disable=SC2044 + for rst_file in $(find "${tmp_dir}/sphinx-in" -name "*.rst"); do + search_str=".. code-block:: none" + replace_str=".. code-block:: python" + if grep -q "${search_str}" "${rst_file}"; then + echo " ${rst_file}" + sed -i "s/${search_str}/${replace_str}/g" "${rst_file}" + fi + done if [ "${git_ref}" = "v0.2.5" ]; then echo " Fix: Inconsistent title levels." diff --git a/src/patches/upbge/0.30/sphinx-in/bge.types.KX_GameObject.rst.patch b/src/patches/upbge/0.30/sphinx-in/bge.types.KX_GameObject.rst.patch new file mode 100644 index 00000000..3cd642af --- /dev/null +++ b/src/patches/upbge/0.30/sphinx-in/bge.types.KX_GameObject.rst.patch @@ -0,0 +1,11 @@ +--- gen_module-tmp/sphinx-in.orig/bge.types.KX_GameObject.rst 2024-10-12 07:22:38.000000000 +0900 ++++ gen_module-tmp/sphinx-in/bge.types.KX_GameObject.rst 2024-10-12 17:10:27.365835300 +0900 +@@ -1099,7 +1099,7 @@ base class --- :class:`~bge.types.SCA_IO + :arg dupli: optional argument, duplicate the physics shape. + :type dupli: boolean + :arg evaluated: optional argument, use evaluated object physics shape (Object with modifiers applied). +- :type dupli: boolean ++ :type evaluated: boolean + + :return: True if reinstance succeeded, False if it failed. + :rtype: boolean diff --git a/src/patches/upbge/0.30/sphinx-in/bpy.types.Bone.rst.patch b/src/patches/upbge/0.30/sphinx-in/bpy.types.Bone.rst.patch new file mode 100644 index 00000000..f6ab7628 --- /dev/null +++ b/src/patches/upbge/0.30/sphinx-in/bpy.types.Bone.rst.patch @@ -0,0 +1,15 @@ +--- gen_module-tmp/sphinx-in.orig/bpy.types.Bone.rst 2024-10-12 07:22:44.000000000 +0900 ++++ gen_module-tmp/sphinx-in/bpy.types.Bone.rst 2024-10-12 16:29:57.288812600 +0900 +@@ -469,9 +469,9 @@ base class --- :class:`bpy_struct` + The transformed matrix + + :rtype: float multi-dimensional array of 4 * 4 items in [-inf, inf] +- This method enables conversions between Local and Pose space for bones in +- the middle of updating the armature without having to update dependencies +- after each change, by manually carrying updated matrices in a recursive walk. ++ This method enables conversions between Local and Pose space for bones in ++ the middle of updating the armature without having to update dependencies ++ after each change, by manually carrying updated matrices in a recursive walk. + + .. literalinclude:: ../examples/bpy.types.Bone.convert_local_to_pose.py + :lines: 7- diff --git a/src/patches/upbge/0.36/sphinx-in/bge.types.KX_GameObject.rst.patch b/src/patches/upbge/0.36/sphinx-in/bge.types.KX_GameObject.rst.patch new file mode 100644 index 00000000..f219e18e --- /dev/null +++ b/src/patches/upbge/0.36/sphinx-in/bge.types.KX_GameObject.rst.patch @@ -0,0 +1,11 @@ +--- gen_module-tmp/sphinx-in.orig/bge.types.KX_GameObject.rst 2024-10-12 07:25:06.000000000 +0900 ++++ gen_module-tmp/sphinx-in/bge.types.KX_GameObject.rst 2024-10-12 16:36:06.532563100 +0900 +@@ -1112,7 +1112,7 @@ base class --- :class:`~bge.types.SCA_IO + :arg dupli: optional argument, duplicate the physics shape. + :type dupli: boolean + :arg evaluated: optional argument, use evaluated object physics shape (Object with modifiers applied). +- :type dupli: boolean ++ :type evaluated: boolean + + :return: True if reinstance succeeded, False if it failed. + :rtype: boolean diff --git a/tests/pylint_cycles.sh b/tests/pylint_cycles.sh index abbd8204..dfe99621 100755 --- a/tests/pylint_cycles.sh +++ b/tests/pylint_cycles.sh @@ -24,6 +24,7 @@ declare -r SUPPORTED_BLENDER_VERSIONS=( ) declare -r SUPPORTED_UPBGE_VERSIONS=( "0.2.5" + "0.30" "0.36" "latest" ) @@ -52,6 +53,8 @@ declare -A BLENDER_TAG_NAME=( ) declare -A UPBGE_TAG_NAME=( ["v0.2.5"]="v0.2.5" + ["v0.30"]="v0.30" + ["v0.36"]="v0.36" ["vlatest"]="master" ) diff --git a/tools/pip_package/build_pip_package.sh b/tools/pip_package/build_pip_package.sh index db5247a5..9e624b74 100755 --- a/tools/pip_package/build_pip_package.sh +++ b/tools/pip_package/build_pip_package.sh @@ -12,6 +12,7 @@ SUPPORTED_BLENDER_VERSIONS=( ) SUPPORTED_UPBGE_VERSIONS=( "0.2.5" + "0.30" "0.36" "latest" ) @@ -40,6 +41,8 @@ declare -A BLENDER_TAG_NAME=( ) declare -A UPBGE_TAG_NAME=( ["v0.2.5"]="v0.2.5" + ["v0.30"]="v0.30" + ["v0.36"]="v0.36" ["vlatest"]="master" ) @@ -179,6 +182,13 @@ rm -r ${fake_module_dir} cp "${SCRIPT_DIR}/../../README.md" . cp "${SCRIPT_DIR}/../../pyproject.toml" . cp "${SCRIPT_DIR}/../../setup.py" . + +# To test against fake-bge-module in fake-bpy-module repository, we need to +# mimic package name to fake-bge-module. +if [ "${target}" = "upbge" ]; then + sed -i -e "s/^name = \"fake-bpy-module/name = \"fake-bge-module/g" pyproject.toml +fi + 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 . diff --git a/tools/pip_package/run_ruff_flake8_pyi.sh b/tools/pip_package/run_ruff_flake8_pyi.sh index 6de502da..aecd2675 100644 --- a/tools/pip_package/run_ruff_flake8_pyi.sh +++ b/tools/pip_package/run_ruff_flake8_pyi.sh @@ -1,14 +1,20 @@ #!/bin/bash set -eEu +declare -A PACKAGE_NAME=( + ["blender"]="bpy" + ["upbge"]="bge" +) + # Check if a Blender version argument is provided -if [ $# -eq 0 ]; then - echo "No Blender version provided. Usage: $0 " +if [ $# -ne 2 ]; then + echo "No Blender version provided. Usage: $0 " exit 1 fi -BLENDER_VERSION=$1 -ZIP_FILE="fake_bpy_modules_${BLENDER_VERSION}-*.zip" +target=$1 +BLENDER_VERSION=$2 +ZIP_FILE="fake_${PACKAGE_NAME[$target]}_modules_${BLENDER_VERSION}-*.zip" EXTRACT_DIR="extracted_modules" # Find and unzip the correct file diff --git a/tools/utils/download_upbge.sh b/tools/utils/download_upbge.sh index d160bc32..5339c3d3 100644 --- a/tools/utils/download_upbge.sh +++ b/tools/utils/download_upbge.sh @@ -5,19 +5,26 @@ set -eEu SUPPORTED_VERSIONS=( "0.2.5" + "0.30" "0.36" "all" ) declare -A UPBGE_DOWNLOAD_URL_LINUX=( ["v0.2.5"]="https://github.com/UPBGE/upbge/releases/download/v0.2.5/UPBGEv0.2.5b2.79Linux64.tar.xz" + ["v0.30"]="https://github.com/UPBGE/upbge/releases/download/v0.30/UPBGE-0.30-linux-x86_64.tar.xz" + ["v0.36"]="https://github.com/UPBGE/upbge/releases/download/v0.36.1/upbge-0.36.1-linux-x86_64.tar.xz" ) declare -A NEED_MOVE_LINUX=( ["v0.2.5"]="UPBGEv0.2.5b2.79Linux64" + ["v0.30"]="UPBGE-0.30-linux-x86_64" + ["v0.36"]="upbge-0.36.1-linux-x86_64" ) declare -A UPBGE_CHECKSUM_URL=( - ["v0.2.5"]="https://raw.githubusercontent.com/nutti/fake-bge-module/ci_testing/tools/utils/md5sum/0.2.5.md5" + ["v0.2.5"]="https://raw.githubusercontent.com/nutti/fake-bge-module/main/tools/utils/md5sum/upbge/0.2.5.md5" + ["v0.30"]="https://github.com/UPBGE/upbge/releases/download/v0.30/UPBGE-0.30-Release.md5" + ["v0.36"]="https://github.com/UPBGE/upbge/releases/download/v0.36.1/upbge-0.36.1-Release.md5" ) function get_extractor() { @@ -50,7 +57,7 @@ function verify_download_integrity() { pushd "${download_dir}" 1> /dev/null - curl --fail -s "${checksum_url}" -o "${checksum_filename}" + curl --fail -L -s "${checksum_url}" -o "${checksum_filename}" if ! grep -q "${target_filename}" "${checksum_filename}"; then echo "Error: Unable to find \"${target_filename}\" in \"${checksum_filename}\"" @@ -58,6 +65,10 @@ function verify_download_integrity() { return 1 fi + # Official md5sum files does not follow correct format. + # To suppress an error, modify the checksum file. + sed -i -E 's/\r//g' "${checksum_filename}" + local checksum checksum="$(grep "${target_filename}" "${checksum_filename}")" diff --git a/tools/utils/md5sum/0.2.5.md5 b/tools/utils/md5sum/upbge/0.2.5.md5 similarity index 100% rename from tools/utils/md5sum/0.2.5.md5 rename to tools/utils/md5sum/upbge/0.2.5.md5