File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -53,5 +53,8 @@ bazel_dep(name = "rules_proto", version = "7.1.0")
5353# https://registry.bazel.build/modules/rules_python
5454bazel_dep (name = "rules_python" , version = "1.7.0" )
5555
56- python = use_extension ("@pybind11_bazel//:python/python.bzl" , "python" )
57- python .toolchain (python_version = "3.11" )
56+ python_rules = use_extension ("@rules_python//python/extensions:python.bzl" , "python" )
57+ python_rules .toolchain (
58+ is_default = True ,
59+ python_version = "3.11" ,
60+ )
Original file line number Diff line number Diff line change @@ -25,17 +25,22 @@ To build the py_cel wheel locally for testing:
2525- Update release version
2626 Edit ` release/build_wheel.sh ` : update ` VERSION `
2727
28- - Run ` cibuildwheel `
28+ - Run ` release/build_wheel.sh `
2929
3030 ```
31- cibuildwheel
31+ release/build_wheel.sh
32+ ```
33+
34+ Optionally, provide the signature of a specific target configuration, e.g.
35+
36+ ```
37+ release/build_wheel.sh --only "cp311-manylinux_x86_64"
3238 ```
3339
3440- Install the resulting wheel:
3541
3642 ```
37- pip uninstall py-cel
38- pip install wheelhouse/py_cel-*.whl
43+ pip install --force-reinstall wheelhouse/py_cel-*.whl
3944 ```
4045
4146- Verify that the wheel is working correctly
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ cp "${SRC_DIR}"/release/* .
2727sed -i " s/\$ VERSION/${VERSION} /g" pyproject.toml
2828
2929echo " Running cibuildwheel: ${CIBWHEEL_BIN} "
30- " ${CIBWHEEL_BIN} "
30+ " ${CIBWHEEL_BIN} " " $@ "
3131
3232echo " Copying generated wheels to ${SRC_DIR} /wheelhouse"
3333mkdir -p " ${SRC_DIR} " /wheelhouse
Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ where = ["."]
2929exclude = [" wheelhouse*" , " conformance*" , " custom_ext*" ]
3030
3131[tool .cibuildwheel ]
32- build = " cp311-*"
32+ build = " cp311-* cp312-* cp313-* "
3333skip = " *musllinux*"
3434before-all = " echo 'Installing bazelisk'; curl -LO https://github.com/bazelbuild/bazelisk/releases/download/v1.19.0/bazelisk-linux-amd64 && chmod +x bazelisk-linux-amd64 && mv bazelisk-linux-amd64 /usr/local/bin/bazel"
3535test-command = " python {project}/py_cel_basic_test.py"
Original file line number Diff line number Diff line change 1717import os
1818import shutil
1919import subprocess
20+ import sys
2021import setuptools
2122import setuptools .command .build_ext
2223
@@ -40,6 +41,24 @@ def run(self):
4041 self .build_extension (ext )
4142
4243 def build_extension (self , ext ):
44+ # cibuildwheel executes setup.py using the target Python version.
45+ # Thus, we can use the current Python version as the target version for
46+ # the bazel build.
47+ python_version = f'{ sys .version_info .major } .{ sys .version_info .minor } '
48+ print (f'Building for target Python version: { python_version } ' )
49+
50+ module_bazel_path = os .path .join (os .path .dirname (__file__ ), 'MODULE.bazel' )
51+ if os .path .exists (module_bazel_path ):
52+ sed_command = (
53+ f"sed -i 's/python_version\\ s*=\\ s*\" .*\" /"
54+ f"python_version = \" { python_version } \" /' { module_bazel_path } "
55+ )
56+ subprocess .check_call (sed_command , shell = True )
57+ else :
58+ raise RuntimeError (
59+ f'MODULE.bazel not found at { module_bazel_path } '
60+ )
61+
4362 dest_path = self .get_ext_fullpath (ext .name )
4463 dest_dir = os .path .dirname (dest_path )
4564 os .makedirs (dest_dir , exist_ok = True )
You can’t perform that action at this time.
0 commit comments