From 6acc379e3698130e2e193acb793422f513950c6b Mon Sep 17 00:00:00 2001 From: Vitaly Terentyev Date: Tue, 24 Feb 2026 16:03:26 +0400 Subject: [PATCH 1/3] Fix installing cibuildwheel --- sdks/python/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdks/python/build.gradle b/sdks/python/build.gradle index 6e0786d98553..f443aa28ab1f 100644 --- a/sdks/python/build.gradle +++ b/sdks/python/build.gradle @@ -200,7 +200,7 @@ platform_identifiers_map.each { platform, idsuffix -> } getVersionsAsList('python_versions').each { it -> def pyversion = it.replace('.', '') - def cibuildwheel_version = it == '3.10' ? '2.23.3' : '3.3.1' + def cibuildwheel_version = it == '310' ? '2.23.3' : '3.3.1' project.tasks.register("bdistPy${pyversion}${platform}") { description "Build a Python wheel distribution for Py${pyversion} ${platform}" From b8f710f16a58d587f967af84256fc8ff661a849b Mon Sep 17 00:00:00 2001 From: Vitaly Terentyev Date: Tue, 24 Feb 2026 23:02:15 +0400 Subject: [PATCH 2/3] Use python 3.13 --- .github/workflows/beam_PostCommit_Python_Xlang_IO_Dataflow.yml | 3 ++- sdks/python/build.gradle | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/beam_PostCommit_Python_Xlang_IO_Dataflow.yml b/.github/workflows/beam_PostCommit_Python_Xlang_IO_Dataflow.yml index de06b49cfdaf..e7aa50c73112 100644 --- a/.github/workflows/beam_PostCommit_Python_Xlang_IO_Dataflow.yml +++ b/.github/workflows/beam_PostCommit_Python_Xlang_IO_Dataflow.yml @@ -81,6 +81,7 @@ jobs: with: gradle-command: :sdks:python:test-suites:dataflow:ioCrossLanguagePostCommit arguments: | + -PpythonVersion=3.13 -PuseWheelDistribution \ -PkafkaBootstrapServer=10.128.0.40:9094,10.128.0.28:9094,10.128.0.165:9094 \ - name: Archive Python Test Results @@ -96,4 +97,4 @@ jobs: commit: '${{ env.prsha || env.GITHUB_SHA }}' comment_mode: ${{ github.event_name == 'issue_comment' && 'always' || 'off' }} files: '**/pytest*.xml' - large_files: true \ No newline at end of file + large_files: true diff --git a/sdks/python/build.gradle b/sdks/python/build.gradle index f443aa28ab1f..6e0786d98553 100644 --- a/sdks/python/build.gradle +++ b/sdks/python/build.gradle @@ -200,7 +200,7 @@ platform_identifiers_map.each { platform, idsuffix -> } getVersionsAsList('python_versions').each { it -> def pyversion = it.replace('.', '') - def cibuildwheel_version = it == '310' ? '2.23.3' : '3.3.1' + def cibuildwheel_version = it == '3.10' ? '2.23.3' : '3.3.1' project.tasks.register("bdistPy${pyversion}${platform}") { description "Build a Python wheel distribution for Py${pyversion} ${platform}" From cd8376d1a86b521780a6d6987d2a294a20d2dff8 Mon Sep 17 00:00:00 2001 From: Vitaly Terentyev Date: Wed, 25 Feb 2026 21:30:27 +0400 Subject: [PATCH 3/3] Use cibwEnvdir --- ...am_PostCommit_Python_Xlang_IO_Dataflow.yml | 1 - .../beam/gradle/BeamModulePlugin.groovy | 22 +++++++++++++++++++ sdks/python/build.gradle | 6 ++--- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/.github/workflows/beam_PostCommit_Python_Xlang_IO_Dataflow.yml b/.github/workflows/beam_PostCommit_Python_Xlang_IO_Dataflow.yml index e7aa50c73112..66c820ad0be2 100644 --- a/.github/workflows/beam_PostCommit_Python_Xlang_IO_Dataflow.yml +++ b/.github/workflows/beam_PostCommit_Python_Xlang_IO_Dataflow.yml @@ -81,7 +81,6 @@ jobs: with: gradle-command: :sdks:python:test-suites:dataflow:ioCrossLanguagePostCommit arguments: | - -PpythonVersion=3.13 -PuseWheelDistribution \ -PkafkaBootstrapServer=10.128.0.40:9094,10.128.0.28:9094,10.128.0.165:9094 \ - name: Archive Python Test Results diff --git a/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy b/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy index 76f380c94bb8..b17d5a7e1763 100644 --- a/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy +++ b/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy @@ -3091,6 +3091,7 @@ class BeamModulePlugin implements Plugin { // virtualenv activated properly. So instead of include project name in the path, // we use the hash value. project.ext.envdir = "${project.rootProject.buildDir}/gradleenv/${project.path.hashCode()}" + project.ext.cibwEnvdir = "${project.rootProject.buildDir}/cibwenv/${project.path.hashCode()}" def pythonRootDir = "${project.rootDir}/sdks/python" // Python interpreter version for virtualenv setup and test run. This value can be @@ -3134,6 +3135,27 @@ class BeamModulePlugin implements Plugin { outputs.upToDateWhen { false } } + def setupCibuildwheelVirtualenv = project.tasks.register('setupCibuildwheelVirtualenv') { + doLast { + project.exec { + executable 'sh' + args '-c', [ + "python3.13 -m venv --clear ${project.ext.cibwEnvdir}", + ].join(' ') + } + project.exec { + executable 'sh' + args '-c', ". ${project.ext.cibwEnvdir}/bin/activate && " + + "pip install --pre --retries 10 --upgrade pip==25.0.1 --no-cache-dir && " + + "pip install --retries 10 --upgrade setuptools --no-cache-dir && " + + "pip install --retries 10 cibuildwheel==3.3.1 --no-cache-dir" + } + } + + outputs.dirs(project.ext.cibwEnvdir) + outputs.upToDateWhen { false } + } + project.ext.pythonSdkDeps = project.files( project.fileTree( dir: "${project.rootDir}", diff --git a/sdks/python/build.gradle b/sdks/python/build.gradle index 6e0786d98553..7200b85cbd72 100644 --- a/sdks/python/build.gradle +++ b/sdks/python/build.gradle @@ -200,11 +200,10 @@ platform_identifiers_map.each { platform, idsuffix -> } getVersionsAsList('python_versions').each { it -> def pyversion = it.replace('.', '') - def cibuildwheel_version = it == '3.10' ? '2.23.3' : '3.3.1' project.tasks.register("bdistPy${pyversion}${platform}") { description "Build a Python wheel distribution for Py${pyversion} ${platform}" - dependsOn setupVirtualenv + dependsOn setupCibuildwheelVirtualenv // need sdist task to generate protos dependsOn ':sdks:python:sdist' @@ -218,10 +217,9 @@ platform_identifiers_map.each { platform, idsuffix -> exec { environment CIBW_BUILD: "cp${pyversion}-${idsuffix}" executable 'sh' - args '-c', ". ${envdir}/bin/activate && " + + args '-c', ". ${project.ext.cibwEnvdir}/bin/activate && " + // note: sync cibuildwheel version with GitHub Action // .github/workflows/build_wheel.yml:build_wheels "Install cibuildwheel" step - "pip install cibuildwheel==${cibuildwheel_version} setuptools && " + "cibuildwheel --print-build-identifiers --platform ${platform} --archs ${archs} && " + "cibuildwheel --output-dir ${buildDir} --platform ${platform} --archs ${archs} " }