Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for macOS #118

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
15 changes: 8 additions & 7 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
build -c opt
common --enable_bzlmod
build -c dbg
build --cxxopt=-std=c++17
build --host_cxxopt=-std=c++17
build --experimental_repo_remote_exec

# TODO(fchern): Use non-hardcode path.
build --action_env=PYTHON_BIN_PATH="/usr/bin/python3"
build --action_env=PYTHON_LIB_PATH="/usr/lib/python3"
build --repo_env=PYTHON_BIN_PATH="/usr/bin/python3"
build --python_path="/usr/bin/python3"
build --copt=-pthread
build --features=debug_prefix_map_pwd_is_dot
build --apple_generate_dsym
build --strip=never
build --features=oso_prefix_is_pwd
build --spawn_strategy=local
74 changes: 74 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Build and Save Python Wheel

on:
push:
branches:
- '**' # Build on all branches
tags:
- 'v*' # Trigger the release workflow only when a tag is pushed (e.g., v1.0.0)

jobs:
build:
strategy:
matrix:
os: [macos-latest, ubuntu-latest] # Specify both macOS and Linux environments
runs-on: ${{ matrix.os }}

steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0 # Ensures that the full history is cloned to handle any branch-specific build needs

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install setuptools wheel

# Run the build script and capture the output directory
- name: Run build script
id: build
run: |
bazel build ...

- name: Run Bazel Tests
run: |
bazel test ...

- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: built-wheels-${{ matrix.os }}
path: bazel-bin/*.whl

release:
runs-on: ubuntu-latest
needs: build
if: startsWith(github.ref, 'refs/tags/v') # Only run this job if a tag starting with "v" is pushed
steps:
- name: Download Artifacts from macOS
uses: actions/download-artifact@v3
with:
name: built-wheels-macos-latest
path: ./artifacts/macos

- name: Download Artifacts from Linux
uses: actions/download-artifact@v3
with:
name: built-wheels-ubuntu-latest
path: ./artifacts/linux

- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.ref_name }} # Use the current tag name as the release version
files: |
artifacts/macos/*.whl
artifacts/linux/*.whl
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Bazel related files
bazel-*
*.bazel
bazel-bin/
bazel-out/
bazel-testlogs/
bazel-genfiles/
# End Generation Here
22 changes: 22 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Debug Sharedable dependency test",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/bazel-bin/cpp/shareable_dependency_test",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "lldb",
"targetArchitecture": "arm64"
}

]
}
File renamed without changes.
28 changes: 25 additions & 3 deletions BUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
load("@rules_python//python:defs.bzl", "py_binary", "py_test")
load("@rules_python//python:pip.bzl", "compile_pip_requirements")
load("@rules_python//python:packaging.bzl", "py_wheel", 'py_package')

package(default_visibility = ["//visibility:public"])

py_library(
name = "setup",
srcs = ["setup.py"],
compile_pip_requirements(
name = "requirements",
src = "requirements.in",
requirements_txt = "requirements_lock.txt",
)

py_wheel(
name = "array_record_wheel",
distribution = "array_record",
version = "0.6.0",
platform = select({
"@platforms//os:macos": "macosx_14_0_arm64",
"@platforms//os:linux": "manylinux2014_x86_64",
}),
deps = [
"//array_record/python:array_record_data_source",
"//array_record/python:array_record_module",
"//array_record/python:init",
"//array_record/beam:beam",
"//array_record:package_info",
],
)
37 changes: 37 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
module(
name = "array_record",
version = "0.1.0",
)

bazel_dep(name = "abseil-cpp", version = "20240116.2", repo_name = "com_google_absl")
bazel_dep(name = "abseil-py", version = "2.1.0", repo_name = "com_google_absl_py")
bazel_dep(name = "brotli", version = "1.1.0")
bazel_dep(name = "googletest", version = "1.15.2", repo_name = "com_google_googletest")
bazel_dep(name = "protobuf", version = "24.4", repo_name = "com_google_protobuf")
single_version_override(module_name="protobuf", patches=["//:protobuf.diff"], patch_strip=1)
bazel_dep(name = "riegeli", version = "0.0.0-20240606-973b6f0", repo_name = "com_google_riegeli")
bazel_dep(name = "highwayhash", version = "0.0.0-20240305-5ad3bf8")
bazel_dep(name = "rules_python", version = "0.36.0")
bazel_dep(name = "pybind11_bazel", version = "2.12.0")
bazel_dep(name = "platforms", version = "0.0.10")

SUPPORTED_PYTHON_VERSIONS = [
"3.10",
]
DEFAULT_PYTHON_VERSION = SUPPORTED_PYTHON_VERSIONS[-1]
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
[
python.toolchain(
python_version = version,
is_default = version == DEFAULT_PYTHON_VERSION,
)
for version in SUPPORTED_PYTHON_VERSIONS
]

pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
pip.parse(
hub_name = "pypi_array_record",
python_version = "3.10",
requirements_lock = "//:requirements_lock.txt",
)
use_repo(pip, "pypi_array_record")
Loading