diff --git a/.github/workflows/build_and_publish_template.yml b/.github/workflows/build_and_publish_template.yml index ba46a5a63..e2731cdaf 100644 --- a/.github/workflows/build_and_publish_template.yml +++ b/.github/workflows/build_and_publish_template.yml @@ -33,7 +33,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.11", "3.12", "3.13", "3.14"] + python-version: ["3.11", "3.12", "3.13", "3.14", "3.14t"] os: [ubuntu-22.04, ubuntu-22.04-arm, macos-14, windows-2022] is-ci-tests: - ${{ inputs.is_ci_tests }} @@ -48,6 +48,8 @@ jobs: os: windows-2022 - python-version: "3.14" os: ubuntu-22.04-arm + - python-version: "3.14t" + os: ubuntu-22.04 env: USE_BAZEL_VERSION: "7.2.1" diff --git a/CHANGELOG.md b/CHANGELOG.md index e3b3fcccc..53c2f5cff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ changes. Best viewed [here](https://google-grain.readthedocs.io/en/latest/change * New features: * Adds automated batching into shared memory when multiprocess prefetch is used to save one data copy. + * Add Python 3.14 free threaded build. * Breaking changes: diff --git a/grain/oss/Dockerfile b/grain/oss/Dockerfile index fd65009d6..acc4850b9 100644 --- a/grain/oss/Dockerfile +++ b/grain/oss/Dockerfile @@ -7,13 +7,14 @@ FROM quay.io/pypa/${AUDITWHEEL_PLATFORM} LABEL maintainer="Grain team " ARG PYTHON_VERSION +ARG PYTHON_BASE_VERSION ARG BAZEL_VERSION ENV DEBIAN_FRONTEND=noninteractive RUN ulimit -n 1024 && yum install -y rsync -ENV PYTHON_BIN_PATH=/opt/python/cp${PYTHON_VERSION}-cp${PYTHON_VERSION}/bin +ENV PYTHON_BIN_PATH=/opt/python/cp${PYTHON_BASE_VERSION}-cp${PYTHON_VERSION}/bin ENV PATH="${PYTHON_BIN_PATH}:${PATH}" ENV PYTHON_BIN=${PYTHON_BIN_PATH}/python diff --git a/grain/oss/build_whl.sh b/grain/oss/build_whl.sh index 4d3f78e52..cef050907 100644 --- a/grain/oss/build_whl.sh +++ b/grain/oss/build_whl.sh @@ -32,7 +32,17 @@ main() { write_to_bazelrc "build:macos --action_env=CC=clang" write_to_bazelrc "build:macos --action_env=CXX=clang++" - write_to_bazelrc "build --@rules_python//python/config_settings:python_version=${PYTHON_VERSION}" + BAZEL_PYTHON_VERSION="${PYTHON_VERSION}" + case "${PYTHON_VERSION}" in + *t) + BAZEL_PYTHON_VERSION="${PYTHON_VERSION%t}" + write_to_bazelrc "build --@rules_python//python/config_settings:py_freethreaded=yes" + write_to_bazelrc "test --@rules_python//python/config_settings:py_freethreaded=yes" + write_to_bazelrc "test --test_env=PYTHON_GIL=0" + ;; + esac + + write_to_bazelrc "build --@rules_python//python/config_settings:python_version=${BAZEL_PYTHON_VERSION}" # Set platform-wise file extension for extension modules. case "$(uname)" in CYGWIN*|MINGW*|MSYS_NT*) @@ -47,7 +57,7 @@ main() { ;; esac - write_to_bazelrc "test --@rules_python//python/config_settings:python_version=${PYTHON_VERSION}" + write_to_bazelrc "test --@rules_python//python/config_settings:python_version=${BAZEL_PYTHON_VERSION}" write_to_bazelrc "test --action_env PYTHON_VERSION=${PYTHON_VERSION}" write_to_bazelrc "test --test_timeout=300" diff --git a/grain/oss/runner_common.sh b/grain/oss/runner_common.sh index bfa73df15..8c0048bbd 100644 --- a/grain/oss/runner_common.sh +++ b/grain/oss/runner_common.sh @@ -32,9 +32,11 @@ build_and_test_grain() { AUDITWHEEL_PLATFORM='manylinux_2_28_'"$(uname -m)" docker rmi -f grain:${PYTHON_VERSION} docker rm -f grain + PYTHON_BASE_VERSION="${PYTHON_MAJOR_VERSION}${PYTHON_MINOR_VERSION%t}" DOCKER_BUILDKIT=1 docker build --progress=plain --no-cache \ --build-arg AUDITWHEEL_PLATFORM="${AUDITWHEEL_PLATFORM}" \ --build-arg PYTHON_VERSION="${PYTHON_MAJOR_VERSION}""${PYTHON_MINOR_VERSION}" \ + --build-arg PYTHON_BASE_VERSION="${PYTHON_BASE_VERSION}" \ --build-arg BAZEL_VERSION="${BAZEL_VERSION}" \ -t grain:"${PYTHON_VERSION}" "${SOURCE_DIR}"'/grain/oss'