diff --git a/.github/workflows/build_python.yml b/.github/workflows/build_python.yml index 5e0e3de5..c57b3567 100644 --- a/.github/workflows/build_python.yml +++ b/.github/workflows/build_python.yml @@ -6,12 +6,19 @@ on: python_version: required: true type: string + platforms: + required: true + type: string + default: "linux-x86_64,linux-aarch64,linux-i386,linux-arm,linux-riscv64,macos,windows" run_tests: required: false type: boolean debug: required: false type: boolean + debug_interactive: + required: false + type: boolean verbose: required: false type: boolean @@ -20,6 +27,9 @@ on: python_version: required: true type: string + platforms: + required: true + type: string run_tests: required: false type: boolean @@ -34,6 +44,7 @@ env: RUN_TESTS: ${{ inputs.run_tests }} DEBUG_CI: ${{ inputs.debug }} VERBOSE_CI: ${{ inputs.verbose }} + image_map: '{"x86_64": "amd64/centos:7", "i386": "i386/centos:7", "aarch64": "arm64v8/centos:7", "arm": "arm32v7/debian:bullseye", "riscv64": "riscv64/debian:sid"}' jobs: build_linux: @@ -42,48 +53,60 @@ jobs: strategy: fail-fast: false matrix: - include: - - arch: x86_64 - image: amd64/centos:7 - - arch: i386 - image: i386/centos:7 - - arch: aarch64 - image: arm64v8/centos:7 - - arch: arm - image: arm32v7/debian:bullseye - - arch: riscv64 - image: riscv64/debian:sid + arch: [x86_64, i386, aarch64, arm, riscv64] + exclude: + - arch: ${{ !contains(inputs.platforms, 'linux-x86_64') && 'x86_64' || '' }} + - arch: ${{ !contains(inputs.platforms, 'linux-i386') && 'i386' || '' }} + - arch: ${{ !contains(inputs.platforms, 'linux-aarch64') && 'aarch64' || '' }} + - arch: ${{ !contains(inputs.platforms, 'linux-arm') && 'arm' || '' }} + - arch: ${{ !contains(inputs.platforms, 'linux-riscv64') && 'riscv64' || '' }} steps: + - name: Parse image + if: ${{ matrix.arch }} + id: parse_image + run: | + IMAGE=$(echo ${{ toJSON(env.image_map) }} | jq -r '.["${{ matrix.arch }}"]') + echo "image=$IMAGE" >> "$GITHUB_OUTPUT" + - name: Set up zig + if: ${{ matrix.arch }} uses: goto-bus-stop/setup-zig@v2 with: version: 0.12.0-dev.3097+5c0766b6c - name: Checkout + if: ${{ matrix.arch }} uses: actions/checkout@v4 - name: Build + if: ${{ matrix.arch }} run: | ./scripts/build_linux_zig.sh ${{ matrix.arch }} ${{ inputs.python_version }} + - name: Interactive debugging + if: ${{ always() && matrix.arch && inputs.debug_interactive }} + uses: fawazahmed0/action-debug@v2 + - name: Upload artifacts + if: ${{ matrix.arch }} uses: actions/upload-artifact@v4 with: name: python-linux-${{ matrix.arch }}-${{ inputs.python_version }} path: ./python*.zip - name: Upload artifacts + if: ${{ always() && matrix.arch && inputs.debug }} uses: actions/upload-artifact@v4 - if: ${{ always() && inputs.debug }} with: name: build-python-linux-${{ matrix.arch }}-${{ inputs.python_version }} path: ./*python*.tar.gz - name: Test python in clean environment + if: ${{ matrix.arch }} uses: addnab/docker-run-action@v3 with: - image: ${{ matrix.image }} + image: ${{ steps.parse_image.outputs.image }} options: -v ${{ github.workspace }}:/work --workdir /tmp shell: bash run: | @@ -113,6 +136,7 @@ jobs: build_windows: name: Windows ${{ inputs.python_version }} x86_64 (build) + if: ${{ contains(inputs.platforms, 'windows') }} runs-on: windows-latest steps: @@ -138,6 +162,10 @@ jobs: set -ex ./scripts/build_windows.sh x86_64 ${{ inputs.python_version }} + - name: Interactive debugging + uses: fawazahmed0/action-debug@v2 + if: ${{ always() && inputs.debug_interactive }} + - name: Upload artifacts uses: actions/upload-artifact@v4 with: @@ -179,6 +207,7 @@ jobs: build_macos: name: MacOS ${{ inputs.python_version }} universal2 (build) + if: ${{ contains(inputs.platforms, 'macos') }} runs-on: macos-latest steps: @@ -197,6 +226,10 @@ jobs: set -ex ./scripts/build_macos.sh universal2 ${{ inputs.python_version }} + - name: Interactive debugging + uses: fawazahmed0/action-debug@v2 + if: ${{ always() && inputs.debug_interactive }} + - name: Upload artifacts uses: actions/upload-artifact@v4 with: diff --git a/.github/workflows/build_python_on_branch.yml b/.github/workflows/build_python_on_branch.yml index 7de63c03..6d688792 100644 --- a/.github/workflows/build_python_on_branch.yml +++ b/.github/workflows/build_python_on_branch.yml @@ -24,10 +24,11 @@ jobs: strategy: fail-fast: false matrix: - python_version: [ 3.9.18, 3.10.13 ] + python_version: [ 3.9.18, 3.10.13, 3.11.7 ] uses: ./.github/workflows/build_python.yml with: python_version: ${{ matrix.python_version }} run_tests: ${{ inputs.run_tests || false }} debug: ${{ inputs.debug || false }} - verbose: ${{ inputs.verbose || false }} \ No newline at end of file + verbose: ${{ inputs.verbose || false }} + platforms: "linux-x86_64,linux-aarch64,linux-i386,linux-arm,linux-riscv64,macos,windows" diff --git a/.github/workflows/release_python.yml b/.github/workflows/release_python.yml index 5dbd1bf4..8013e40c 100644 --- a/.github/workflows/release_python.yml +++ b/.github/workflows/release_python.yml @@ -26,6 +26,7 @@ jobs: uses: ./.github/workflows/build_python.yml with: python_version: ${{ inputs.python_version }} + platforms: "linux-x86_64,linux-aarch64,linux-i386,linux-arm,linux-riscv64,macos,windows" publish: name: Publish ${{ inputs.python_version }} diff --git a/scripts/build_linux_zig.sh b/scripts/build_linux_zig.sh index 6b0f7e4d..5b9607cd 100755 --- a/scripts/build_linux_zig.sh +++ b/scripts/build_linux_zig.sh @@ -449,7 +449,7 @@ cd tcl*/unix LDFLAGS="${LDFLAGS} -lxml2" ./configure --disable-shared --host=${CHOST} --prefix=${DEPSDIR} make -j4 make install -cd .. +cd .. install_license ./license.terms echo "::endgroup::" @@ -464,7 +464,7 @@ cd tk*/unix LDFLAGS="${LDFLAGS} -lxml2" ./configure --disable-shared --host=${CHOST} --prefix=${DEPSDIR} make -j4 make install -cd .. +cd .. install_license ./license.terms echo "::endgroup::" @@ -501,7 +501,7 @@ if [[ "${ARCH}" == "arm" || "${ARCH}" == "aarch64" || "${ARCH}" == "riscv64" ]]; CFLAGS="-static-libgcc" fi -wget --no-verbose -O portable-python-cmake-buildsystem.tar.gz https://github.com/bjia56/portable-python-cmake-buildsystem/tarball/portable-python +wget --no-verbose -O portable-python-cmake-buildsystem.tar.gz https://github.com/bjia56/portable-python-cmake-buildsystem/tarball/${CMAKE_BUILDSYSTEM_BRANCH} tar -xf portable-python-cmake-buildsystem.tar.gz rm *.tar.gz mv *portable-python-cmake-buildsystem* portable-python-cmake-buildsystem @@ -513,7 +513,6 @@ LDFLAGS="${LDFLAGS} -lfontconfig -lfreetype" CFLAGS="${CFLAGS}" cmake \ -DCMAKE_SYSTEM_PROCESSOR=${ARCH} \ -DCMAKE_CROSSCOMPILING_EMULATOR=${WORKDIR}/scripts/qemu_${ARCH}_interpreter \ -DCMAKE_IGNORE_PATH=/usr/include \ - -DCMAKE_C_STANDARD=99 \ -DPYTHON_VERSION=${PYTHON_FULL_VER} \ -DCMAKE_BUILD_TYPE:STRING=Release \ -DCMAKE_INSTALL_PREFIX:PATH=${BUILDDIR}/python-install \ @@ -545,6 +544,7 @@ LDFLAGS="${LDFLAGS} -lfontconfig -lfreetype" CFLAGS="${CFLAGS}" cmake \ -DGDBM_LIBRARY:FILEPATH=${DEPSDIR}/lib/libgdbm.a \ -DGDBM_COMPAT_LIBRARY:FILEPATH=${DEPSDIR}/lib/libgdbm_compat.a \ -DNDBM_TAG=NDBM \ + -DNDBM_USE=NDBM \ -DTK_INCLUDE_PATH:FILEPATH=${DEPSDIR}/include/tk.h \ -DTK_LIBRARY:FILEPATH=${DEPSDIR}/lib/libtk8.6.a \ -DTCL_INCLUDE_PATH:FILEPATH=${DEPSDIR}/include/tcl.h \ diff --git a/scripts/build_macos.sh b/scripts/build_macos.sh index d187f25b..b09603e3 100755 --- a/scripts/build_macos.sh +++ b/scripts/build_macos.sh @@ -16,7 +16,7 @@ cd ${BUILDDIR} export MACOSX_DEPLOYMENT_TARGET=10.5 -git clone https://github.com/bjia56/portable-python-cmake-buildsystem.git --branch portable-python --single-branch --depth 1 +git clone https://github.com/bjia56/portable-python-cmake-buildsystem.git --branch ${CMAKE_BUILDSYSTEM_BRANCH} --single-branch --depth 1 echo "::endgroup::" ########### @@ -144,7 +144,7 @@ download_verify_extract expat-2.5.0.tar.gz mkdir ${DEPSDIR}/expat cd expat* CC=clang CFLAGS="-arch x86_64 -arch arm64" ./configure --disable-shared --prefix=${DEPSDIR}/expat -make -j4 +make -j${NPROC} make install install_license @@ -186,6 +186,8 @@ echo "::endgroup::" echo "::group::Build" cd ${BUILDDIR} +# TODO: build TCL + mkdir python-build mkdir python-install cd python-build @@ -194,7 +196,6 @@ cmake \ -G "Unix Makefiles" \ "-DCMAKE_OSX_ARCHITECTURES=arm64;x86_64" \ -DCMAKE_OSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET} \ - -DCMAKE_C_STANDARD=99 \ -DPYTHON_VERSION=${PYTHON_FULL_VER} \ -DCMAKE_BUILD_TYPE:STRING=Release \ -DCMAKE_INSTALL_PREFIX:PATH=${BUILDDIR}/python-install \ @@ -205,6 +206,7 @@ cmake \ -DINSTALL_MANUAL=OFF \ -DOPENSSL_ROOT_DIR:PATH=${DEPSDIR}/openssl \ -DUSE_SYSTEM_EXPAT=OFF \ + -DUSE_SYSTEM_TCL=OFF \ -DEXPAT_INCLUDE_DIRS:PATH=${DEPSDIR}/expat/include \ -DEXPAT_LIBRARIES:FILEPATH=${DEPSDIR}/expat/lib/libexpat.a \ -DSQLite3_INCLUDE_DIR:PATH=${DEPSDIR}/sqlite3/include \ diff --git a/scripts/build_windows.sh b/scripts/build_windows.sh index 36b21cb6..23f94af4 100755 --- a/scripts/build_windows.sh +++ b/scripts/build_windows.sh @@ -10,7 +10,7 @@ source ${SCRIPT_DIR}/utils.sh echo "::group::Initialize" cd ${BUILDDIR} -git clone https://github.com/bjia56/portable-python-cmake-buildsystem.git --branch portable-python --single-branch --depth 1 +git clone https://github.com/bjia56/portable-python-cmake-buildsystem.git --branch ${CMAKE_BUILDSYSTEM_BRANCH} --single-branch --depth 1 echo "::endgroup::" ########### @@ -138,7 +138,6 @@ cd python-build cmake \ "${cmake_verbose_flags[@]}" \ -G "Visual Studio 17 2022" -A x64 \ - -DCMAKE_C_STANDARD=99 \ -DPYTHON_VERSION=${PYTHON_FULL_VER} \ -DCMAKE_BUILD_TYPE:STRING=Release \ -DCMAKE_INSTALL_PREFIX:PATH=${BUILDDIR}/python-install \ diff --git a/scripts/utils.sh b/scripts/utils.sh index 2187d3d8..ffa0bbf9 100644 --- a/scripts/utils.sh +++ b/scripts/utils.sh @@ -2,6 +2,7 @@ set -e +CMAKE_BUILDSYSTEM_BRANCH="portable-python" SCRIPT_DIR="$(dirname "$(readlink -f "$0")")" function verify_checksum () {