Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,8 @@ bazel_dep(name = "rules_proto", version = "7.1.0")
# https://registry.bazel.build/modules/rules_python
bazel_dep(name = "rules_python", version = "1.7.0")

python = use_extension("@pybind11_bazel//:python/python.bzl", "python")
python.toolchain(python_version = "3.11")
python_rules = use_extension("@rules_python//python/extensions:python.bzl", "python")
python_rules.toolchain(
is_default = True,
python_version = "3.11",
)
13 changes: 9 additions & 4 deletions release/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,22 @@ To build the py_cel wheel locally for testing:
- Update release version
Edit `release/build_wheel.sh`: update `VERSION`

- Run `cibuildwheel`
- Run `release/build_wheel.sh`

```
cibuildwheel
release/build_wheel.sh
```

Optionally, provide the signature of a specific target configuration, e.g.

```
release/build_wheel.sh --only "cp311-manylinux_x86_64"
```

- Install the resulting wheel:

```
pip uninstall py-cel
pip install wheelhouse/py_cel-*.whl
pip install --force-reinstall wheelhouse/py_cel-*.whl
```

- Verify that the wheel is working correctly
Expand Down
2 changes: 1 addition & 1 deletion release/build_wheel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ cp "${SRC_DIR}"/release/* .
sed -i "s/\$VERSION/${VERSION}/g" pyproject.toml

echo "Running cibuildwheel: ${CIBWHEEL_BIN}"
"${CIBWHEEL_BIN}"
"${CIBWHEEL_BIN}" "$@"

echo "Copying generated wheels to ${SRC_DIR}/wheelhouse"
mkdir -p "${SRC_DIR}"/wheelhouse
Expand Down
6 changes: 4 additions & 2 deletions release/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ where = ["."]
exclude = ["wheelhouse*", "conformance*", "custom_ext*"]

[tool.cibuildwheel]
build = "cp311-*"
build = "cp311-* cp312-* cp313-*"
skip = "*musllinux*"
before-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"
test-command = "python {project}/py_cel_basic_test.py"

[tool.cibuildwheel.linux]
before-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"
19 changes: 19 additions & 0 deletions release/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import os
import shutil
import subprocess
import sys
import setuptools
import setuptools.command.build_ext

Expand All @@ -40,6 +41,24 @@ def run(self):
self.build_extension(ext)

def build_extension(self, ext):
# cibuildwheel executes setup.py using the target Python version.
# Thus, we can use the current Python version as the target version for
# the bazel build.
python_version = f'{sys.version_info.major}.{sys.version_info.minor}'
print(f'Building for target Python version: {python_version}')

module_bazel_path = os.path.join(os.path.dirname(__file__), 'MODULE.bazel')
if os.path.exists(module_bazel_path):
sed_command = (
"sed -i 's/python_version\\s*=\\s*\".*\"/"
f"python_version = \"{python_version}\"/' {module_bazel_path}"
)
subprocess.check_call(sed_command, shell=True)
else:
raise RuntimeError(
f'MODULE.bazel not found at {module_bazel_path}'
)

dest_path = self.get_ext_fullpath(ext.name)
dest_dir = os.path.dirname(dest_path)
os.makedirs(dest_dir, exist_ok=True)
Expand Down