Skip to content

Commit

Permalink
Merge branch 'main' into libgcc-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
bjia56 committed Mar 13, 2024
2 parents 8151392 + cb1012f commit 813f5cd
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 24 deletions.
59 changes: 46 additions & 13 deletions .github/workflows/build_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -20,6 +27,9 @@ on:
python_version:
required: true
type: string
platforms:
required: true
type: string
run_tests:
required: false
type: boolean
Expand All @@ -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:
Expand All @@ -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: |
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -179,6 +207,7 @@ jobs:
build_macos:
name: MacOS ${{ inputs.python_version }} universal2 (build)
if: ${{ contains(inputs.platforms, 'macos') }}
runs-on: macos-latest

steps:
Expand All @@ -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:
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/build_python_on_branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
verbose: ${{ inputs.verbose || false }}
platforms: "linux-x86_64,linux-aarch64,linux-i386,linux-arm,linux-riscv64,macos,windows"
1 change: 1 addition & 0 deletions .github/workflows/release_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
8 changes: 4 additions & 4 deletions scripts/build_linux_zig.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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::"
Expand All @@ -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::"
Expand Down Expand Up @@ -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
Expand All @@ -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 \
Expand Down Expand Up @@ -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 \
Expand Down
8 changes: 5 additions & 3 deletions scripts/build_macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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::"
###########
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -186,6 +186,8 @@ echo "::endgroup::"
echo "::group::Build"
cd ${BUILDDIR}

# TODO: build TCL

mkdir python-build
mkdir python-install
cd python-build
Expand All @@ -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 \
Expand All @@ -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 \
Expand Down
3 changes: 1 addition & 2 deletions scripts/build_windows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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::"
###########
Expand Down Expand Up @@ -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 \
Expand Down
1 change: 1 addition & 0 deletions scripts/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

set -e

CMAKE_BUILDSYSTEM_BRANCH="portable-python"
SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"

function verify_checksum () {
Expand Down

0 comments on commit 813f5cd

Please sign in to comment.