Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
jagapiou committed Dec 5, 2024
1 parent 0947443 commit aaa961e
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 20 deletions.
33 changes: 19 additions & 14 deletions .github/workflows/make_wheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
prerelease: false

build-wheel:
name: Build-wheel ${{ matrix.cfg.name }} for Python ${{ matrix.py.version }}
name: Build-wheel ${{ matrix.cfg.name }} for Python ${{ matrix.python-version }}

runs-on: ${{ matrix.cfg.os }}

Expand All @@ -41,20 +41,21 @@ jobs:
strategy:
matrix:
cfg:
# - { name: 'ManyLinux 2.31 LLVM+libstdc++', os: 'ubuntu-20.04', cc: clang, cxx: clang++, config: --linkopt=-fuse-ld=lld }
- { name: 'ManyLinux 2.35 LLVM+libstdc++', os: 'ubuntu-22.04', cc: clang, cxx: clang++, config: --linkopt=-fuse-ld=lld }
- { name: 'ManyLinux 2.31 LLVM+libstdc++', os: 'ubuntu-20.04', cc: clang, cxx: clang++, config: --linkopt=-fuse-ld=lld }
- { name: 'MacOS 11 x86_64 LLVM+libc++', os: 'macos-11', cc: clang, cxx: clang++, config: --config=libc++ --config=macos }
- { name: 'MacOS 12 x86_64 LLVM+libc++', os: 'macos-12', cc: clang, cxx: clang++, config: --config=libc++ --config=macos }
- { name: 'MacOS 13 x86_64 LLVM+libc++', os: 'macos-13', cc: clang, cxx: clang++, config: --config=libc++ --config=macos }
- { name: 'MacOS 12 ARM64 LLVM+libc++', os: 'macos-12', cc: clang, cxx: clang++,
config: --config=libc++ --config=macos_arm64 --repo_env=PY_PLATFORM_OVERRIDE=macosx_12_0_arm64 }
- { name: 'MacOS 13 ARM64 LLVM+libc++', os: 'macos-13', cc: clang, cxx: clang++,
config: --config=libc++ --config=macos_arm64 --repo_env=PY_PLATFORM_OVERRIDE=macosx_13_0_arm64 }
# - { name: 'ManyLinux ???? LLVM+libstdc++', os: 'ubuntu-24.04', cc: clang, cxx: clang++, config: --linkopt=-fuse-ld=lld }
# - { name: 'MacOS 13 x86_64 LLVM+libc++', os: 'macos-13', cc: clang, cxx: clang++, config: --config=libc++ --config=macos }
# - { name: 'MacOS 14 x86_64 LLVM+libc++', os: 'macos-14', cc: clang, cxx: clang++, config: --config=libc++ --config=macos }
# - { name: 'MacOS 13 ARM64 LLVM+libc++', os: 'macos-13', cc: clang, cxx: clang++,
# config: --config=libc++ --config=macos_arm64 --repo_env=PY_PLATFORM_OVERRIDE=macosx_13_0_arm64 }
# - { name: 'MacOS 14 ARM64 LLVM+libc++', os: 'macos-14', cc: clang, cxx: clang++,
# config: --config=libc++ --config=macos_arm64 --repo_env=PY_PLATFORM_OVERRIDE=macosx_14_0_arm64 }
python-version:
- '3.8'
- '3.9'
# - '3.9'
- '3.10'
- '3.11'
# - '3.11'
# - '3.12'
# - '3.13'

env:
CC: ${{ matrix.cfg.cc }}
Expand All @@ -69,10 +70,14 @@ jobs:
python-version: ${{ matrix.python-version }}

- name: Install Python Dependencies
run: pip3 install --upgrade pip packaging check-wheel-contents
run: |
pip3 install --upgrade pip packaging check-wheel-contents setuptools
pip list
- name: Build for Python ${{ matrix.python-version }}
run: bazel --bazelrc=.bazelrc build --compilation_mode=opt --dynamic_mode=off --config=luajit ${{ matrix.cfg.config }} //dmlab2d:dmlab2d_wheel
run: |
bazel --version
bazel --bazelrc=.bazelrc build --noenable_bzlmod --compilation_mode=opt --dynamic_mode=off --config=luajit ${{ matrix.cfg.config }} //dmlab2d:dmlab2d_wheel
- name: Get built wheel name
working-directory: bazel-bin/dmlab2d
Expand Down
5 changes: 3 additions & 2 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ http_archive(

http_archive(
name = "rules_cc",
strip_prefix = "rules_cc-main",
urls = ["https://github.com/bazelbuild/rules_cc/archive/main.zip"],
urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.17/rules_cc-0.0.17.tar.gz"],
sha256 = "abc605dd850f813bb37004b77db20106a19311a96b2da1c92b789da529d28fe1",
strip_prefix = "rules_cc-0.0.17",
)

http_archive(
Expand Down
2 changes: 2 additions & 0 deletions bazel/eigen.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# Eigen is a C++ template library for linear algebra: vectors,
# matrices, and related algorithms.

load("@rules_cc//cc:defs.bzl", "cc_library")

licenses([
# Note: Eigen is an MPL2 library that includes GPL v3 and LGPL v2.1+ code.
# We've taken special care to not reference any restricted code.
Expand Down
2 changes: 2 additions & 0 deletions bazel/lua5_1.BUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Description:
# Build rule for Lua 5.1.

load("@rules_cc//cc:defs.bzl", "cc_library")

cc_library(
name = "lua5_1",
srcs = glob(
Expand Down
2 changes: 2 additions & 0 deletions bazel/lua5_2.BUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Description:
# Build rule for Lua 5.2.

load("@rules_cc//cc:defs.bzl", "cc_library")

cc_library(
name = "lua5_2",
srcs = glob(
Expand Down
1 change: 1 addition & 0 deletions bazel/luajit.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Build rule for LuaJit.

load("@bazel_skylib//rules:common_settings.bzl", "bool_flag", "string_flag")
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")

string_flag(
name = "target_arch",
Expand Down
2 changes: 2 additions & 0 deletions bazel/png.BUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Description:
# libpng is the official PNG reference library.

load("@rules_cc//cc:defs.bzl", "cc_library")

licenses(["notice"]) # BSD/MIT-like license

genrule(
Expand Down
2 changes: 2 additions & 0 deletions bazel/pybind11.BUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Description:
# Build rule for pybind11 2.2.4.

load("@rules_cc//cc:defs.bzl", "cc_library")

cc_library(
name = "pybind11",
hdrs = glob(
Expand Down
2 changes: 2 additions & 0 deletions bazel/tree.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# The tree package used to support Bazel, but no longer does so.
# This BUILD file is adapted from the last official version.

load("@rules_cc//cc:defs.bzl", "cc_library")

cc_binary(
name = "tree/_tree.so",
srcs = [
Expand Down
2 changes: 2 additions & 0 deletions bazel/zlib.BUILD
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
load("@rules_cc//cc:defs.bzl", "cc_library")

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

licenses(["notice"]) # BSD/MIT-like license (for zlib)
Expand Down
10 changes: 6 additions & 4 deletions build_defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
"""A BUILD rule for Python extensions that are defined via pybind11."""

load("@bazel_skylib//lib:collections.bzl", "collections")
load("@rules_cc//cc:defs.bzl", "cc_binary")
load("@rules_python//python:defs.bzl", "py_binary", "py_library")

def pybind_extension(
name,
Expand Down Expand Up @@ -64,7 +66,7 @@ def pybind_extension(
kwargs["visibility"] = visibility

shared_lib_name = module_name + ".so"
native.cc_binary(
cc_binary(
name = shared_lib_name,
deps = collections.uniq(deps + pybind11_deps),
copts = collections.uniq(copts + pybind11_copts),
Expand All @@ -75,15 +77,15 @@ def pybind_extension(
**cc_kwargs
)

return native.py_library(
return py_library(
name = name,
data = data + [module_name + ".so"],
tags = tags,
**py_kwargs
)

def pytype_strict_library(name, **kwargs):
native.py_library(name = name, **kwargs)
py_library(name = name, **kwargs)

def pytype_strict_binary(name, **kwargs):
native.py_binary(name = name, **kwargs)
py_binary(name = name, **kwargs)
1 change: 1 addition & 0 deletions python_system.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
_BUILD_FILE = '''# Description:
# Build rule for Python.
load("@rules_cc//cc:defs.bzl", "cc_library")
load("@rules_python//python:defs.bzl", "py_runtime_pair")
exports_files(["defs.bzl"])
Expand Down

0 comments on commit aaa961e

Please sign in to comment.