diff --git a/.github/workflows/beam_PostCommit_Python_Xlang_IO_Dataflow.yml b/.github/workflows/beam_PostCommit_Python_Xlang_IO_Dataflow.yml index de06b49cfdaf..66c820ad0be2 100644 --- a/.github/workflows/beam_PostCommit_Python_Xlang_IO_Dataflow.yml +++ b/.github/workflows/beam_PostCommit_Python_Xlang_IO_Dataflow.yml @@ -96,4 +96,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/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} " }