This is an automated email from the ASF dual-hosted git repository.
chaokunyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/fory.git
The following commit(s) were added to refs/heads/main by this push:
new 9b08470c0 feat(c+/python): upgrade bazel to bazel8 (#2937)
9b08470c0 is described below
commit 9b08470c0e42de6a1c31e2c2b6156d0c985a1bb8
Author: Shawn Yang <[email protected]>
AuthorDate: Thu Nov 27 15:23:21 2025 +0800
feat(c+/python): upgrade bazel to bazel8 (#2937)
## What does this PR do?
upgrade bazel to bazel8, and use bazel module
## Related issues
Closes #2279
Closes #2285
## Does this PR introduce any user-facing change?
<!--
If any user-facing interface changes, please [open an
issue](https://github.com/apache/fory/issues/new/choose) describing the
need to do so and update the document if necessary.
Delete section if not applicable.
-->
- [ ] Does this PR introduce any public API change?
- [ ] Does this PR introduce any binary protocol compatibility change?
## Benchmark
<!--
When the PR has an impact on performance (if you don't know whether the
PR will have an impact on performance, you can submit the PR first, and
if it will have impact on performance, the code reviewer will explain
it), be sure to attach a benchmark data here.
Delete section if not applicable.
-->
---
.bazelversion | 2 +-
.gitignore | 1 -
AGENTS.md | 17 +-
BUILD | 25 +--
LICENSE | 7 +-
MODULE.bazel | 61 +++++++
WORKSPACE | 12 +-
bazel/cython.BUILD | 28 ---
bazel/cython_library.bzl | 23 ++-
bazel/fory_deps_setup.bzl | 159 -----------------
bazel/py/BUILD | 23 ---
bazel/py/BUILD.tpl | 30 ----
bazel/py/python_configure.bzl | 384 ----------------------------------------
bazel/py/variety.tpl | 28 ---
ci/run_ci.sh | 19 +-
ci/tasks/common.py | 41 ++++-
cpp/fory/encoder/BUILD | 4 +-
cpp/fory/meta/BUILD | 10 +-
cpp/fory/python/BUILD | 2 +-
cpp/fory/row/BUILD | 2 +-
cpp/fory/serialization/BUILD | 24 +--
cpp/fory/type/BUILD | 2 +-
cpp/fory/util/BUILD | 26 +--
licenses/LICENSE-tensorflow.txt | 251 --------------------------
python/CONTRIBUTING.md | 4 -
python/setup.py | 5 +
26 files changed, 188 insertions(+), 1002 deletions(-)
diff --git a/.bazelversion b/.bazelversion
index f9da12e11..797ed2e27 100644
--- a/.bazelversion
+++ b/.bazelversion
@@ -1 +1 @@
-6.3.2
\ No newline at end of file
+8.2.1
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index 6ef4161d1..c79bd6f31 100644
--- a/.gitignore
+++ b/.gitignore
@@ -36,7 +36,6 @@ java/**/generated
javascript/**/dist/
javascript/**/node_modules/
javascript/**/build
-MODULE.bazel
MODULE.bazel.lock
.DS_Store
**/.DS_Store
diff --git a/AGENTS.md b/AGENTS.md
index 44ac62da1..87b72e9c4 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -60,8 +60,8 @@ mvn -T16 test -Dtest=org.apache.fory.TestClass#testMethod
# Build C++ library
bazel build //cpp/...
-# Build Cython extensions
-bazel build //:cp_fory_so
+# Build Cython extensions (replace X.Y with your Python version, e.g., 3.10)
+bazel build //:cp_fory_so
--@rules_python//python/config_settings:python_version=X.Y
# Run tests
bazel test $(bazel query //cpp/...)
@@ -105,9 +105,9 @@ ruff check --fix .
# Install
pip install -v -e .
-# Build native extension when cython code changed
-bazel build //:cp_fory_so --config=x86_64 # For x86_64
-bazel build //:cp_fory_so --copt=-fsigned-char # For arm64 and aarch64
+# Build native extension when cython code changed (replace X.Y with your
Python version)
+bazel build //:cp_fory_so
--@rules_python//python/config_settings:python_version=X.Y --config=x86_64 #
For x86_64
+bazel build //:cp_fory_so
--@rules_python//python/config_settings:python_version=X.Y --copt=-fsigned-char
# For arm64 and aarch64
# Run tests without cython
ENABLE_FORY_CYTHON_SERIALIZATION=0 pytest -v -s .
@@ -385,12 +385,9 @@ Fory serialization for every language is implemented
independently to minimize t
`bazel` dir provides build support for fory C++ and Cython:
-- `bazel/fory_deps_setup.bzl`: setup external dependencies for bazel build
- `bazel/cython_library.bzl`: `pyx_library` rule for building Cython extensions
-- `bazel/cython.BUILD`: build file for external Cython dependency
-- `bazel/py/python_configure.bzl`: repository rule for Python autoconfiguration
-- `bazel/py/BUILD.tpl`: template for generated Python configuration BUILD file
-- `bazel/py/variety.tpl`: template for Python version-specific configuration
+
+Dependencies are managed via `MODULE.bazel` using bzlmod (Bazel 8+).
#### C++
diff --git a/BUILD b/BUILD
index 286cf58f6..8befe8817 100644
--- a/BUILD
+++ b/BUILD
@@ -16,7 +16,7 @@
# under the License.
load("//bazel:cython_library.bzl", "pyx_library")
-load("@compile_commands_extractor//:refresh_compile_commands.bzl",
"refresh_compile_commands")
+load("@hedron_compile_commands//:refresh_compile_commands.bzl",
"refresh_compile_commands")
pyx_library(
@@ -65,21 +65,24 @@ pyx_library(
"//cpp/fory/util:fory_util",
"//cpp/fory/type:fory_type",
"//cpp/fory/python:_pyfory",
- "@com_google_absl//absl/container:flat_hash_map",
+ "@abseil-cpp//absl/container:flat_hash_map",
],
)
pyx_library(
name = "_format",
- srcs = glob([
- "python/pyfory/__init__.py",
- "python/pyfory/includes/*.pxd",
- "python/pyfory/_util.pxd",
- "python/pyfory/*.pxi",
- "python/pyfory/format/_format.pyx",
- "python/pyfory/format/__init__.py",
- "python/pyfory/format/*.pxi",
- ]),
+ srcs = glob(
+ [
+ "python/pyfory/__init__.py",
+ "python/pyfory/includes/*.pxd",
+ "python/pyfory/_util.pxd",
+ "python/pyfory/*.pxi",
+ "python/pyfory/format/_format.pyx",
+ "python/pyfory/format/__init__.py",
+ "python/pyfory/format/*.pxi",
+ ],
+ allow_empty = True,
+ ),
cc_kwargs = dict(
linkstatic = 1,
),
diff --git a/LICENSE b/LICENSE
index d39c69473..3f7fc8158 100644
--- a/LICENSE
+++ b/LICENSE
@@ -242,15 +242,10 @@ The text of each license is the standard Apache 2.0
license.
* ray (https://github.com/ray-project/ray)
Files:
ci/format.sh
- bazel/fory_deps_setup.bzl
-* grpc (https://github.com/grpc/grpc) and tensorflow
(https://github.com/tensorflow/tensorflow)
+* grpc (https://github.com/grpc/grpc)
Files:
bazel/cython_library.bzl
- bazel/cython.BUILD
- bazel/py/python_configure.bzl
- bazel/py/BUILD.tpl
- bazel/py/variety.tpl
================================================================
diff --git a/MODULE.bazel b/MODULE.bazel
new file mode 100644
index 000000000..f47b3719b
--- /dev/null
+++ b/MODULE.bazel
@@ -0,0 +1,61 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+module(
+ name = "fory",
+ version = "0.14.0",
+)
+
+# Platforms (needed for platform-specific build configurations)
+bazel_dep(name = "platforms", version = "0.0.11")
+
+# Bazel Skylib
+bazel_dep(name = "bazel_skylib", version = "1.7.1")
+
+# Rules CC (C++ rules)
+bazel_dep(name = "rules_cc", version = "0.1.1")
+
+# Rules Python - standard Python rules
+bazel_dep(name = "rules_python", version = "1.4.1")
+
+# Configure Python toolchain to use version from BAZEL_PYTHON_VERSION env var
+# This allows building extensions with the correct Python version headers
+python = use_extension("@rules_python//python/extensions:python.bzl", "python")
+python.toolchain(python_version = "3.8")
+python.toolchain(python_version = "3.9")
+python.toolchain(python_version = "3.10")
+python.toolchain(python_version = "3.11")
+python.toolchain(python_version = "3.12")
+python.toolchain(python_version = "3.13")
+use_repo(python, "python_versions")
+
+# Cython from BCR with official rules
+bazel_dep(name = "cython", version = "3.1.3")
+
+# Google Test
+bazel_dep(name = "googletest", version = "1.15.2")
+
+# Abseil C++
+bazel_dep(name = "abseil-cpp", version = "20240722.0")
+
+# Hedron's Compile Commands Extractor for Bazel
+bazel_dep(name = "hedron_compile_commands", dev_dependency = True)
+git_override(
+ module_name = "hedron_compile_commands",
+ remote =
"https://github.com/hedronvision/bazel-compile-commands-extractor.git",
+ commit = "0e990032f3c5a866e72615cf67e5ce22186dcb97",
+)
diff --git a/WORKSPACE b/WORKSPACE
index 9e268ac25..7b92aec42 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -15,12 +15,6 @@
# specific language governing permissions and limitations
# under the License.
-workspace(name = "fory")
-
-load("//bazel:fory_deps_setup.bzl", "setup_deps")
-setup_deps()
-
-load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
-load("//bazel/py:python_configure.bzl", "python_configure")
-bazel_skylib_workspace()
-python_configure(name="local_config_python")
+# This file is intentionally kept minimal.
+# Dependencies are managed via MODULE.bazel using bzlmod.
+# See MODULE.bazel for the list of dependencies.
diff --git a/bazel/cython.BUILD b/bazel/cython.BUILD
deleted file mode 100644
index 1c4d33997..000000000
--- a/bazel/cython.BUILD
+++ /dev/null
@@ -1,28 +0,0 @@
-# Adapted from tensorflow/third_party/cython.BUILD
-
-py_library(
- name="cython_lib",
- srcs=glob(
- ["Cython/**/*.py"],
- exclude=[
- "**/Tests/*.py",
- ],
- ) + ["cython.py"],
- data=glob([
- "Cython/**/*.pyx",
- "Cython/Utility/*.*",
- "Cython/Includes/**/*.pxd",
- ]),
- srcs_version="PY2AND3",
- visibility=["//visibility:public"],
-)
-
-# May not be named "cython", since that conflicts with Cython/ on OSX
-py_binary(
- name="cython_binary",
- srcs=["cython.py"],
- main="cython.py",
- srcs_version="PY2AND3",
- visibility=["//visibility:public"],
- deps=["cython_lib"],
-)
diff --git a/bazel/cython_library.bzl b/bazel/cython_library.bzl
index 11ed111f2..143994829 100644
--- a/bazel/cython_library.bzl
+++ b/bazel/cython_library.bzl
@@ -1,5 +1,5 @@
-# Adapted from tensorflow/tensorflow/core/platform/default/build_config.bzl
-# and grpc/bazel/cython_library.bzl
+# Adapted from cython/Tools/rules.bzl
+# Uses official Cython rules pattern from BCR
"""Custom rules for building Cython extensions"""
def pyx_library(name, deps = [], cc_kwargs = {}, py_deps = [], srcs = [],
**kwargs):
@@ -41,10 +41,7 @@ def pyx_library(name, deps = [], cc_kwargs = {}, py_deps =
[], srcs = [], **kwar
name = filename + "_cython_translation",
srcs = [filename],
outs = [filename.split(".")[0] + ".cpp"],
- # Optionally use PYTHON_BIN_PATH on Linux platforms so that python
3
- # works. Windows has issues with cython_binary so skip
PYTHON_BIN_PATH.
- cmd =
- "PYTHONHASHSEED=0 $(location @cython//:cython_binary) --cplus
$(SRCS) --output-file $(OUTS)",
+ cmd = "PYTHONHASHSEED=0 $(execpath @cython//:cython_binary)
--cplus $(SRCS) --output-file $(OUTS)",
tools = ["@cython//:cython_binary"] + pxd_srcs,
)
@@ -52,11 +49,21 @@ def pyx_library(name, deps = [], cc_kwargs = {}, py_deps =
[], srcs = [], **kwar
for src in pyx_srcs:
stem = src.split(".")[0]
shared_object_name = stem + ".so"
+
+ # Get linkopts from cc_kwargs or use empty list
+ linkopts = cc_kwargs.pop("linkopts", [])
+
native.cc_binary(
name = cc_kwargs.pop("name", shared_object_name),
srcs = [stem + ".cpp"] + cc_kwargs.pop("srcs", []),
- deps = deps + ["@local_config_python//:python_headers"] +
cc_kwargs.pop("deps", []),
+ deps = deps + ["@rules_python//python/cc:current_py_cc_headers"] +
cc_kwargs.pop("deps", []),
linkshared = cc_kwargs.pop("linkshared", 1),
+ # On macOS, use -undefined dynamic_lookup to allow Python symbols
+ # to be resolved at runtime when the extension is imported.
+ linkopts = linkopts + select({
+ "@platforms//os:macos": ["-undefined", "dynamic_lookup"],
+ "//conditions:default": [],
+ }),
**cc_kwargs
)
shared_objects.append(shared_object_name)
@@ -69,7 +76,7 @@ def pyx_library(name, deps = [], cc_kwargs = {}, py_deps =
[], srcs = [], **kwar
name = name,
srcs = py_srcs,
deps = py_deps,
- srcs_version = "PY2AND3",
+ srcs_version = "PY3",
data = data,
**kwargs
)
diff --git a/bazel/fory_deps_setup.bzl b/bazel/fory_deps_setup.bzl
deleted file mode 100644
index 95e282a7d..000000000
--- a/bazel/fory_deps_setup.bzl
+++ /dev/null
@@ -1,159 +0,0 @@
-# This file is derived from
https://github.com/ray-project/ray/blob/7fb3feb25e2c19616944f16b026b7f5052451e8d/bazel/ray_deps_setup.bzl
-
-load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository",
"new_git_repository")
-load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive",
"http_file")
-
-def get_mirror_url(name, sha256, url):
- """ Get internal URL of the library if no public network access. """
- SUPPORTED_EXTENSIONS = [".zip", ".tar.gz", ".tar.bz2"]
- extension = None
- for ex in SUPPORTED_EXTENSIONS:
- if url.endswith(ex):
- extension = ex
- break
- if extension == None:
- fail("Unknown extension: " + url)
-
- # This needs to be in sync with `oss_uploader.py`
- file_name = "%s-%s%s" % (name, sha256, extension)
- # return "http://internal/" + file_name
- return url
-
-def urlsplit(url):
- """ Splits a URL like "https://example.com/a/b?c=d&e#f" into a tuple:
- ("https", ["example", "com"], ["a", "b"], ["c=d", "e"], "f")
- A trailing slash will result in a correspondingly empty final path
component.
- """
- split_on_anchor = url.split("#", 1)
- split_on_query = split_on_anchor[0].split("?", 1)
- split_on_scheme = split_on_query[0].split("://", 1)
- if len(split_on_scheme) <= 1: # Scheme is optional
- split_on_scheme = [None] + split_on_scheme[:1]
- split_on_path = split_on_scheme[1].split("/")
- return {
- "scheme": split_on_scheme[0],
- "netloc": split_on_path[0].split("."),
- "path": split_on_path[1:],
- "query": split_on_query[1].split("&") if len(split_on_query) > 1 else
None,
- "fragment": split_on_anchor[1] if len(split_on_anchor) > 1 else None,
- }
-
-def auto_http_archive(
- *,
- name = None,
- url = None,
- urls = True,
- build_file = None,
- build_file_content = None,
- strip_prefix = True,
- **kwargs):
- """ Intelligently choose mirrors based on the given URL for the download.
-
- Either url or urls is required.
-
- If name == None , it is auto-deduced, but this is NOT recommended.
- If urls == True , mirrors are automatically chosen.
- If build_file == True , it is auto-deduced.
- If strip_prefix == True , it is auto-deduced.
- """
- DOUBLE_SUFFIXES_LOWERCASE = [("tar", "bz2"), ("tar", "gz"), ("tar", "xz")]
- mirror_prefixes = ["https://mirror.bazel.build/"]
-
- canonical_url = url if url != None else urls[0]
- url_parts = urlsplit(canonical_url)
- url_except_scheme = (canonical_url.replace(url_parts["scheme"] + "://",
"") if url_parts["scheme"] != None else canonical_url)
- url_path_parts = url_parts["path"]
- url_filename = url_path_parts[-1]
- url_filename_parts = (url_filename.rsplit(".", 2) if
(tuple(url_filename.lower().rsplit(".", 2)[-2:]) in
-
DOUBLE_SUFFIXES_LOWERCASE) else url_filename.rsplit(".", 1))
- is_github = url_parts["netloc"] == ["github", "com"]
-
- if name == None: # Deduce "com_github_user_project_name" from
"https://github.com/user/project-name/..."
- name = "_".join(url_parts["netloc"][::-1] +
url_path_parts[:2]).replace("-", "_")
-
- if build_file == True:
- build_file = "@fory//%s:%s" % ("bazel", "BUILD." + name)
-
- if urls == True:
- prefer_url_over_mirrors = is_github
- urls = [
- mirror_prefix + url_except_scheme
- for mirror_prefix in mirror_prefixes
- if not canonical_url.startswith(mirror_prefix)
- ]
- urls.insert(0 if prefer_url_over_mirrors else len(urls), canonical_url)
- else:
- print("No implicit mirrors used because urls were explicitly provided")
-
- if strip_prefix == True:
- prefix_without_v = url_filename_parts[0]
- if prefix_without_v.startswith("v") and
prefix_without_v[1:2].isdigit():
- # GitHub automatically strips a leading 'v' in version numbers
- prefix_without_v = prefix_without_v[1:]
- strip_prefix = (url_path_parts[1] + "-" + prefix_without_v if
is_github and url_path_parts[2:3] == ["archive"] else url_filename_parts[0])
-
- # Use internal OSS address.
- url = get_mirror_url(name, kwargs["sha256"], url or urls[0])
- urls = None
-
- # Add `@com_github_ray_project_ray` prefix to the patch files,
- # otherwise when other projects loads Ray, there will be issues finding
these files.
- if "patches" in kwargs:
- kwargs["patches"] = [
- "@fory" + patch
- for patch in kwargs["patches"]
- ]
-
- return http_archive(
- name = name,
- url = url,
- urls = urls,
- build_file = build_file,
- build_file_content = build_file_content,
- strip_prefix = strip_prefix,
- **kwargs
- )
-
-def setup_deps():
- # Fix @platforms error, see
https://groups.google.com/g/bazel-discuss/c/iQyt08ZaNek
- http_archive(
- name = "bazel_skylib",
- sha256 =
"74d544d96f4a5bb630d465ca8bbcfe231e3594e5aae57e1edbf17a6eb3ca2506",
- urls = [
-
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz",
-
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz",
- ],
- )
- http_archive(
- name = "rules_python",
- sha256 =
"9fcf91dbcc31fde6d1edb15f117246d912c33c36f44cf681976bd886538deba6",
- strip_prefix = "rules_python-0.8.0",
- url =
"https://github.com/bazelbuild/rules_python/archive/refs/tags/0.8.0.tar.gz",
- )
- # Cython for building Python extensions
- # leary cython failed with: `found 'CKeyValueMetadata'`
- # see https://github.com/apache/arrow/issues/28629
- auto_http_archive(
- name = "cython",
- build_file = "@fory//bazel:cython.BUILD",
- url =
"https://github.com/cython/cython/releases/download/3.1.1/cython-3.1.1.tar.gz",
- sha256 =
"505ccd413669d5132a53834d792c707974248088c4f60c497deb1b416e366397",
- )
- auto_http_archive(
- name = "com_google_googletest",
- url =
"https://github.com/google/googletest/archive/refs/tags/release-1.11.0.tar.gz",
- sha256 =
"b4870bf121ff7795ba20d20bcdd8627b8e088f2d1dab299a031c1034eddc93d5",
- )
- auto_http_archive(
- name = "com_google_absl",
- sha256 =
"5366d7e7fa7ba0d915014d387b66d0d002c03236448e1ba9ef98122c13b35c36",
- strip_prefix = "abseil-cpp-20230125.3",
- urls = [
- "https://github.com/abseil/abseil-cpp/archive/20230125.3.tar.gz",
- ],
- )
- http_archive(
- name = "compile_commands_extractor",
- url =
"https://github.com/hedronvision/bazel-compile-commands-extractor/archive/80ac7efb33a65f0cc627635e5b958ea3eb03231d.tar.gz",
- strip_prefix =
"bazel-compile-commands-extractor-80ac7efb33a65f0cc627635e5b958ea3eb03231d",
- )
diff --git a/bazel/py/BUILD b/bazel/py/BUILD
deleted file mode 100644
index 1fc80965e..000000000
--- a/bazel/py/BUILD
+++ /dev/null
@@ -1,23 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-# Package for Python configuration templates
-
-exports_files([
- "BUILD.tpl",
- "variety.tpl",
-])
diff --git a/bazel/py/BUILD.tpl b/bazel/py/BUILD.tpl
deleted file mode 100644
index 0677a083b..000000000
--- a/bazel/py/BUILD.tpl
+++ /dev/null
@@ -1,30 +0,0 @@
-# Adapted from tensorflow/third_party/py/ and grpc/third_party/py/
-
-package(default_visibility=["//visibility:public"])
-
-config_setting(
- name="windows",
- values={"cpu": "x64_windows"},
- visibility=["//visibility:public"],
-)
-
-config_setting(
- name="python3",
- flag_values = {"@rules_python//python:python_version": "PY3"}
-)
-
-cc_library(
- name = "python_lib",
- deps = select({
- ":python3": ["//_python3:_python3_lib"],
- "//conditions:default": ["not-existing.lib"],
- })
-)
-
-cc_library(
- name = "python_headers",
- deps = select({
- ":python3": ["//_python3:_python3_headers"],
- "//conditions:default": ["not-existing.headers"],
- })
-)
diff --git a/bazel/py/python_configure.bzl b/bazel/py/python_configure.bzl
deleted file mode 100644
index 8181b712e..000000000
--- a/bazel/py/python_configure.bzl
+++ /dev/null
@@ -1,384 +0,0 @@
-# Adapted from tensorflow/third_party/py/ and grpc/third_party/py/
-"""Repository rule for Python autoconfiguration.
-
-`python_configure` depends on the following environment variables:
-
- * `PYTHON3_BIN_PATH`: location of python binary.
- * `PYTHON3_LIB_PATH`: Location of python libraries.
-"""
-
-_BAZEL_SH = "BAZEL_SH"
-_PYTHON3_BIN_PATH = "PYTHON3_BIN_PATH"
-_PYTHON3_LIB_PATH = "PYTHON3_LIB_PATH"
-
-_HEADERS_HELP = (
- "Are Python headers installed? Try installing " +
- "python3-dev on Debian-based systems. Try python3-devel " +
- "on Redhat-based systems."
-)
-
-def _tpl(repository_ctx, tpl, substitutions = {}, out = None):
- if not out:
- out = tpl
- repository_ctx.template(
- out,
- Label("//bazel/py:%s.tpl" % tpl),
- substitutions,
- )
-
-def _fail(msg):
- """Output failure message when auto configuration fails."""
- red = "\033[0;31m"
- no_color = "\033[0m"
- fail("%sPython Configuration Error:%s %s\n" % (red, no_color, msg))
-
-def _is_windows(repository_ctx):
- """Returns true if the host operating system is windows."""
- os_name = repository_ctx.os.name.lower()
- return os_name.find("windows") != -1
-
-def _execute(
- repository_ctx,
- cmdline,
- error_msg = None,
- error_details = None,
- empty_stdout_fine = False):
- """Executes an arbitrary shell command.
-
- Args:
- repository_ctx: the repository_ctx object
- cmdline: list of strings, the command to execute
- error_msg: string, a summary of the error if the command fails
- error_details: string, details about the error or steps to fix it
- empty_stdout_fine: bool, if True, an empty stdout result is fine,
otherwise
- it's an error
- Return:
- the result of repository_ctx.execute(cmdline)
- """
- result = repository_ctx.execute(cmdline)
- if result.stderr or not (empty_stdout_fine or result.stdout):
- _fail("\n".join([
- error_msg.strip() if error_msg else "Repository command failed",
- result.stderr.strip(),
- error_details if error_details else "",
- ]))
- else:
- return result
-
-def _read_dir(repository_ctx, src_dir):
- """Returns a string with all files in a directory.
-
- Finds all files inside a directory, traversing subfolders and following
- symlinks. The returned string contains the full path of all files
- separated by line breaks.
- """
- if _is_windows(repository_ctx):
- src_dir = src_dir.replace("/", "\\")
- find_result = _execute(
- repository_ctx,
- ["cmd.exe", "/c", "dir", src_dir, "/b", "/s", "/a-d"],
- empty_stdout_fine = True,
- )
-
- # src_files will be used in genrule.outs where the paths must
- # use forward slashes.
- return find_result.stdout.replace("\\", "/")
- else:
- find_result = _execute(
- repository_ctx,
- ["find", src_dir, "-follow", "-type", "f"],
- empty_stdout_fine = True,
- )
- return find_result.stdout
-
-def _genrule(src_dir, genrule_name, command, outs):
- """Returns a string with a genrule.
-
- Genrule executes the given command and produces the given outputs.
- """
- return ("genrule(\n" + ' name = "' + genrule_name + '",\n' +
- " outs = [\n" + outs + "\n ],\n" + ' cmd = """\n' +
- command + '\n """,\n' + ")\n")
-
-def _normalize_path(path):
- """Returns a path with '/' and remove the trailing slash."""
- path = path.replace("\\", "/")
- if path[-1] == "/":
- path = path[:-1]
- return path
-
-def _symlink_genrule_for_dir(
- repository_ctx,
- src_dir,
- dest_dir,
- genrule_name,
- src_files = [],
- dest_files = []):
- """Returns a genrule to symlink(or copy if on Windows) a set of files.
-
- If src_dir is passed, files will be read from the given directory;
otherwise
- we assume files are in src_files and dest_files
- """
- if src_dir != None:
- src_dir = _normalize_path(src_dir)
- dest_dir = _normalize_path(dest_dir)
- files = "\n".join(
- sorted(_read_dir(repository_ctx, src_dir).splitlines()),
- )
-
- # Create a list with the src_dir stripped to use for outputs.
- dest_files = files.replace(src_dir, "").splitlines()
- src_files = files.splitlines()
- command = []
- outs = []
- for i in range(len(dest_files)):
- if dest_files[i] != "":
- # If we have only one file to link we do not want to use the
dest_dir, as
- # $(@D) will include the full path to the file.
- dest = "$(@D)/" + dest_dir + dest_files[i] if len(
- dest_files,
- ) != 1 else "$(@D)/" + dest_files[i]
-
- # On Windows, symlink is not supported, so we just copy all the
files.
- cmd = "cp -f" if _is_windows(repository_ctx) else "ln -s"
- command.append(cmd + ' "%s" "%s"' % (src_files[i], dest))
- outs.append(' "' + dest_dir + dest_files[i] + '",')
- return _genrule(
- src_dir,
- genrule_name,
- " && ".join(command),
- "\n".join(outs),
- )
-
-def _get_python_bin(repository_ctx, bin_path_key, default_bin_path,
allow_absent):
- """Gets the python bin path."""
- python_bin = repository_ctx.os.environ.get(bin_path_key, default_bin_path)
- if not repository_ctx.path(python_bin).exists:
- # It's a command, use 'which' to find its path.
- python_bin_path = repository_ctx.which(python_bin)
- else:
- # It's a path, use it as it is.
- python_bin_path = python_bin
- if python_bin_path != None:
- return str(python_bin_path)
- if not allow_absent:
- _fail("Cannot find python in PATH, please make sure " +
- "python is installed and add its directory in PATH, or --define
" +
- "%s='/something/else'.\nPATH=%s" %
- (bin_path_key, repository_ctx.os.environ.get("PATH", "")))
- else:
- return None
-
-def _get_bash_bin(repository_ctx):
- """Gets the bash bin path."""
- bash_bin = repository_ctx.os.environ.get(_BAZEL_SH)
- if bash_bin != None:
- return bash_bin
- else:
- bash_bin_path = repository_ctx.which("bash")
- if bash_bin_path != None:
- return str(bash_bin_path)
- else:
- _fail(
- "Cannot find bash in PATH, please make sure " +
- "bash is installed and add its directory in PATH, or --define
" +
- "%s='/path/to/bash'.\nPATH=%s" %
- (_BAZEL_SH, repository_ctx.os.environ.get("PATH", "")),
- )
-
-def _get_python_lib(repository_ctx, python_bin, lib_path_key):
- """Gets the python lib path."""
- python_lib = repository_ctx.os.environ.get(lib_path_key)
- if python_lib != None:
- return python_lib
- print_lib = (
- "<<END\n" + "from __future__ import print_function\n" +
- "import site\n" + "import os\n" + "\n" + "try:\n" +
- " input = raw_input\n" + "except NameError:\n" + " pass\n" + "\n" +
- "python_paths = []\n" + "if os.getenv('PYTHONPATH') is not None:\n" +
- " python_paths = os.getenv('PYTHONPATH').split(':')\n" + "try:\n" +
- " library_paths = site.getsitepackages()\n" +
- "except AttributeError:\n" +
- " import sysconfig\n" +
- " library_paths = [sysconfig.get_path('purelib')]\n" +
- "all_paths = set(python_paths + library_paths)\n" + "paths = []\n" +
- "for path in all_paths:\n" + " if os.path.isdir(path):\n" +
- " paths.append(path)\n" + "if len(paths) >=1:\n" +
- " print(paths[0])\n" + "END"
- )
- cmd = '"%s" - %s' % (python_bin, print_lib)
- result = repository_ctx.execute([_get_bash_bin(repository_ctx), "-c", cmd])
- return result.stdout.strip("\n")
-
-def _check_python_lib(repository_ctx, python_lib):
- """Checks the python lib path."""
- cmd = 'test -d "%s" -a -x "%s"' % (python_lib, python_lib)
- result = repository_ctx.execute([_get_bash_bin(repository_ctx), "-c", cmd])
- if result.return_code == 1:
- _fail("Invalid python library path: %s" % python_lib)
-
-def _check_python_bin(repository_ctx, python_bin, bin_path_key, allow_absent):
- """Checks the python bin path."""
- cmd = '[[ -x "%s" ]] && [[ ! -d "%s" ]]' % (python_bin, python_bin)
- result = repository_ctx.execute([_get_bash_bin(repository_ctx), "-c", cmd])
- if result.return_code == 1:
- if not allow_absent:
- _fail("--define %s='%s' is not executable. Is it the python
binary?" %
- (bin_path_key, python_bin))
- else:
- return None
- return True
-
-def _get_python_include(repository_ctx, python_bin):
- """Gets the python include path."""
- result = _execute(
- repository_ctx,
- [
- python_bin,
- "-c",
- "from __future__ import print_function;" +
- "import sysconfig;" +
- "print(sysconfig.get_path('include'))",
- ],
- error_msg = "Problem getting python include path for
{}.".format(python_bin),
- error_details = (
- "Is the Python binary path set up right? " + "(See ./configure or
" +
- python_bin + ".) " + _HEADERS_HELP
- ),
- )
- include_path = result.stdout.splitlines()[0]
- _execute(
- repository_ctx,
- [
- python_bin,
- "-c",
- "import os;" +
- "main_header = os.path.join(r'{}',
'Python.h');".format(include_path) +
- "assert os.path.exists(main_header), main_header + ' does not
exist.'",
- ],
- error_msg = "Unable to find Python headers for {}".format(python_bin),
- error_details = _HEADERS_HELP,
- empty_stdout_fine = True,
- )
- return include_path
-
-def _get_python_import_lib_name(repository_ctx, python_bin, bin_path_key):
- """Get Python import library name (pythonXY.lib) on Windows."""
- result = _execute(
- repository_ctx,
- [
- python_bin,
- "-c",
- "import sys;" + 'print("python" + str(sys.version_info[0]) + ' +
- ' str(sys.version_info[1]) + ".lib")',
- ],
- error_msg = "Problem getting python import library.",
- error_details = ("Is the Python binary path set up right? " +
- "(See ./configure or " + bin_path_key + ".) "),
- )
- return result.stdout.splitlines()[0]
-
-def _create_single_version_package(
- repository_ctx,
- variety_name,
- bin_path_key,
- default_bin_path,
- lib_path_key,
- allow_absent):
- """Creates the repository containing files set up to build with Python."""
- empty_include_rule = "filegroup(\n name=\"{}_include\",\n
srcs=[],\n)".format(variety_name)
-
- python_bin = _get_python_bin(repository_ctx, bin_path_key,
default_bin_path, allow_absent)
- if (python_bin == None or
- _check_python_bin(repository_ctx,
- python_bin,
- bin_path_key,
- allow_absent) == None) and allow_absent:
- python_include_rule = empty_include_rule
- else:
- python_lib = _get_python_lib(repository_ctx, python_bin, lib_path_key)
- _check_python_lib(repository_ctx, python_lib)
- python_include = _get_python_include(repository_ctx, python_bin)
- python_include_rule = _symlink_genrule_for_dir(
- repository_ctx,
- python_include,
- "{}_include".format(variety_name),
- "{}_include".format(variety_name),
- )
- python_import_lib_genrule = ""
-
- # To build Python C/C++ extension on Windows, we need to link to python
import library pythonXY.lib
- # See https://docs.python.org/3/extending/windows.html
- if _is_windows(repository_ctx):
- python_include = _normalize_path(python_include)
- python_import_lib_name = _get_python_import_lib_name(
- repository_ctx,
- python_bin,
- bin_path_key,
- )
- python_import_lib_src = python_include.rsplit(
- "/",
- 1,
- )[0] + "/libs/" + python_import_lib_name
- python_import_lib_genrule = _symlink_genrule_for_dir(
- repository_ctx,
- None,
- "",
- "{}_import_lib".format(variety_name),
- [python_import_lib_src],
- [python_import_lib_name],
- )
- _tpl(
- repository_ctx,
- "variety",
- {
- "%{PYTHON_INCLUDE_GENRULE}": python_include_rule,
- "%{PYTHON_IMPORT_LIB_GENRULE}": python_import_lib_genrule,
- "%{VARIETY_NAME}": variety_name,
- },
- out = "{}/BUILD".format(variety_name),
- )
-
-def _python_autoconf_impl(repository_ctx):
- """Implementation of the python_autoconf repository rule."""
- _create_single_version_package(
- repository_ctx,
- "_python3",
- _PYTHON3_BIN_PATH,
- "python3" if not _is_windows(repository_ctx) else "python.exe",
- _PYTHON3_LIB_PATH,
- False
- )
- _tpl(repository_ctx, "BUILD")
-
-python_configure = repository_rule(
- implementation = _python_autoconf_impl,
- environ = [
- _BAZEL_SH,
- _PYTHON3_BIN_PATH,
- _PYTHON3_LIB_PATH,
- ],
- attrs = {
- "_build_tpl": attr.label(
- default = Label("//bazel/py:BUILD.tpl"),
- allow_single_file = True,
- ),
- "_variety_tpl": attr.label(
- default = Label("//bazel/py:variety.tpl"),
- allow_single_file = True,
- ),
- },
-)
-"""Detects and configures the local Python.
-
-It expects the system have a working Python 3 installation.
-
-Add the following to your WORKSPACE FILE:
-
-```python
-python_configure(name = "local_config_python")
-```
-
-Args:
- name: A unique name for this workspace rule.
-"""
diff --git a/bazel/py/variety.tpl b/bazel/py/variety.tpl
deleted file mode 100644
index 2e1725845..000000000
--- a/bazel/py/variety.tpl
+++ /dev/null
@@ -1,28 +0,0 @@
-# Adapted from tensorflow/third_party/py/ and grpc/third_party/py/
-
-package(default_visibility=["//visibility:public"])
-
-# To build Python C/C++ extension on Windows, we need to link to python import
library pythonXY.lib
-# See https://docs.python.org/3/extending/windows.html
-cc_import(
- name="%{VARIETY_NAME}_lib",
- interface_library=select({
- "//:windows": ":%{VARIETY_NAME}_import_lib",
- # A placeholder for Unix platforms which makes --no_build happy.
- "//conditions:default": "not-existing.lib",
- }),
- system_provided=1,
-)
-
-cc_library(
- name="%{VARIETY_NAME}_headers",
- hdrs=[":%{VARIETY_NAME}_include"],
- deps=select({
- "//:windows": [":%{VARIETY_NAME}_lib"],
- "//conditions:default": [],
- }),
- includes=["%{VARIETY_NAME}_include"],
-)
-
-%{PYTHON_INCLUDE_GENRULE}
-%{PYTHON_IMPORT_LIB_GENRULE}
diff --git a/ci/run_ci.sh b/ci/run_ci.sh
index f27835341..21d76e121 100755
--- a/ci/run_ci.sh
+++ b/ci/run_ci.sh
@@ -65,10 +65,20 @@ get_bazel_version() {
}
install_bazel() {
+ REQUIRED_VERSION=$(get_bazel_version)
+
if command -v bazel >/dev/null; then
echo "existing bazel location $(which bazel)"
- echo "existing bazel version $(bazel version)"
- return
+ INSTALLED_VERSION=$(bazel --version 2>/dev/null | sed 's/bazel //')
+ echo "existing bazel version: $INSTALLED_VERSION, required:
$REQUIRED_VERSION"
+ if [ "$INSTALLED_VERSION" = "$REQUIRED_VERSION" ]; then
+ echo "Bazel version matches, using cached binary"
+ return
+ else
+ echo "Bazel version mismatch, re-downloading..."
+ # Remove old bazel binary
+ rm -f "$(which bazel)" 2>/dev/null || true
+ fi
fi
ARCH="$(uname -m)"
@@ -88,12 +98,11 @@ install_bazel() {
*) echo "Unsupported OS: $OPERATING_SYSTEM"; exit 1 ;;
esac
- BAZEL_VERSION=$(get_bazel_version)
BAZEL_DIR="$HOME/.local/bin"
mkdir -p "$BAZEL_DIR"
- # Construct platform-specific URL
-
BINARY_URL="https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VERSION}/bazel-${BAZEL_VERSION}-${OS}-${ARCH}"
+ # Construct platform-specific URL (use REQUIRED_VERSION defined at function
start)
+
BINARY_URL="https://github.com/bazelbuild/bazel/releases/download/${REQUIRED_VERSION}/bazel-${REQUIRED_VERSION}-${OS}-${ARCH}"
echo "Downloading bazel from: $BINARY_URL"
# Retry download with exponential backoff to avoid transient network errors
in CI
diff --git a/ci/tasks/common.py b/ci/tasks/common.py
index 65ba8b488..40b5ac4cf 100644
--- a/ci/tasks/common.py
+++ b/ci/tasks/common.py
@@ -24,7 +24,9 @@ import importlib
# Constants
PYARROW_VERSION = "15.0.0"
-PROJECT_ROOT_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)),
"../../")
+PROJECT_ROOT_DIR = os.path.normpath(
+ os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../")
+)
# Configure logging
logging.basicConfig(
@@ -121,9 +123,15 @@ def cd_project_subdir(subdir):
def bazel(cmd: str):
- """Execute a bazel command."""
- bazel_cmd = "bazel" if is_windows() else "~/bin/bazel"
- return exec_cmd(f"{bazel_cmd} {cmd}")
+ """Execute a bazel command from the project root directory."""
+ # Ensure we're in the project root directory where MODULE.bazel is located
+ original_dir = os.getcwd()
+ os.chdir(PROJECT_ROOT_DIR)
+ try:
+ bazel_cmd = "bazel" if is_windows() else "~/bin/bazel"
+ return exec_cmd(f"{bazel_cmd} {cmd}")
+ finally:
+ os.chdir(original_dir)
def update_shell_profile():
@@ -144,6 +152,8 @@ def update_shell_profile():
def install_bazel():
"""Download and install bazel."""
+ required_version = get_bazel_version()
+
# Check if bazel is already cached (from GitHub Actions cache)
if not is_windows():
home_bin = os.path.expanduser("~/bin")
@@ -157,11 +167,23 @@ def install_bazel():
if os.path.exists(path) and os.access(path, os.X_OK):
logging.info(f"Bazel already exists at {path}, verifying...")
try:
- # Verify it works
+ # Verify it works and has the correct version
result = exec_cmd(f"{path} --version")
- logging.info(f"Cached Bazel binary is valid:
{result.strip()}")
- logging.info("Skipping Bazel download, using cached
binary")
- return
+ installed_version = result.strip().replace("bazel ", "")
+ if installed_version == required_version:
+ logging.info(f"Cached Bazel binary is valid:
{result.strip()}")
+ logging.info("Skipping Bazel download, using cached
binary")
+ return
+ else:
+ logging.warning(
+ f"Cached Bazel version {installed_version} does
not match "
+ f"required version {required_version}"
+ )
+ logging.info("Re-downloading Bazel with correct
version...")
+ try:
+ os.remove(path)
+ except Exception:
+ pass
except Exception as e:
logging.warning(f"Cached Bazel binary at {path} is
invalid: {e}")
logging.info("Re-downloading Bazel...")
@@ -214,7 +236,8 @@ def install_bazel():
psutil = importlib.import_module("psutil")
total_mem = psutil.virtual_memory().total
limit_jobs = int(total_mem / 1024 / 1024 / 1024 / 3)
- with open(".bazelrc", "a") as file:
+ bazelrc_path = os.path.join(PROJECT_ROOT_DIR, ".bazelrc")
+ with open(bazelrc_path, "a") as file:
file.write(f"\nbuild --jobs={limit_jobs}")
diff --git a/cpp/fory/encoder/BUILD b/cpp/fory/encoder/BUILD
index 0d19f0dc2..a97b394b5 100644
--- a/cpp/fory/encoder/BUILD
+++ b/cpp/fory/encoder/BUILD
@@ -2,7 +2,7 @@ load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
cc_library(
name = "fory_encoder",
- srcs = glob(["*.cc"], exclude=["*test.cc"]),
+ srcs = glob(["*.cc"], exclude=["*test.cc"], allow_empty = True),
hdrs = glob(["*.h"]),
strip_include_prefix = "/cpp",
deps = [
@@ -17,6 +17,6 @@ cc_test(
srcs = glob(["*_test.cc"]),
deps = [
":fory_encoder",
- "@com_google_googletest//:gtest",
+ "@googletest//:gtest",
],
)
diff --git a/cpp/fory/meta/BUILD b/cpp/fory/meta/BUILD
index d5baeaec3..c595c7d37 100644
--- a/cpp/fory/meta/BUILD
+++ b/cpp/fory/meta/BUILD
@@ -2,7 +2,7 @@ load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
cc_library(
name = "fory_meta",
- srcs = glob(["*.cc"], exclude=["*test.cc"]),
+ srcs = glob(["*.cc"], exclude=["*test.cc"], allow_empty = True),
hdrs = glob(["*.h"]),
strip_include_prefix = "/cpp",
visibility = ["//visibility:public"],
@@ -13,7 +13,7 @@ cc_test(
srcs = ["preprocessor_test.cc"],
deps = [
":fory_meta",
- "@com_google_googletest//:gtest",
+ "@googletest//:gtest",
],
)
@@ -22,7 +22,7 @@ cc_test(
srcs = ["field_info_test.cc"],
deps = [
":fory_meta",
- "@com_google_googletest//:gtest",
+ "@googletest//:gtest",
],
)
@@ -31,7 +31,7 @@ cc_test(
srcs = ["enum_info_test.cc"],
deps = [
":fory_meta",
- "@com_google_googletest//:gtest",
+ "@googletest//:gtest",
],
)
@@ -40,6 +40,6 @@ cc_test(
srcs = ["type_traits_test.cc"],
deps = [
":fory_meta",
- "@com_google_googletest//:gtest",
+ "@googletest//:gtest",
],
)
diff --git a/cpp/fory/python/BUILD b/cpp/fory/python/BUILD
index 3197841f6..7b878436e 100644
--- a/cpp/fory/python/BUILD
+++ b/cpp/fory/python/BUILD
@@ -27,7 +27,7 @@ cc_library(
strip_include_prefix = "/cpp",
deps = [
"//cpp/fory/util:fory_util",
- "@local_config_python//:python_headers",
+ "@rules_python//python/cc:current_py_cc_headers",
],
visibility = ["//visibility:public"],
)
\ No newline at end of file
diff --git a/cpp/fory/row/BUILD b/cpp/fory/row/BUILD
index 2061df1e8..40ca8c2b7 100644
--- a/cpp/fory/row/BUILD
+++ b/cpp/fory/row/BUILD
@@ -17,6 +17,6 @@ cc_test(
srcs = ["row_test.cc"],
deps = [
":fory_row_format",
- "@com_google_googletest//:gtest",
+ "@googletest//:gtest",
],
)
diff --git a/cpp/fory/serialization/BUILD b/cpp/fory/serialization/BUILD
index c636888dd..a19d872e5 100644
--- a/cpp/fory/serialization/BUILD
+++ b/cpp/fory/serialization/BUILD
@@ -43,8 +43,8 @@ cc_test(
srcs = ["serialization_test.cc"],
deps = [
":fory_serialization",
- "@com_google_googletest//:gtest",
- "@com_google_googletest//:gtest_main",
+ "@googletest//:gtest",
+ "@googletest//:gtest_main",
],
)
@@ -53,8 +53,8 @@ cc_test(
srcs = ["struct_test.cc"],
deps = [
":fory_serialization",
- "@com_google_googletest//:gtest",
- "@com_google_googletest//:gtest_main",
+ "@googletest//:gtest",
+ "@googletest//:gtest_main",
],
)
@@ -63,8 +63,8 @@ cc_test(
srcs = ["struct_compatible_test.cc"],
deps = [
":fory_serialization",
- "@com_google_googletest//:gtest",
- "@com_google_googletest//:gtest_main",
+ "@googletest//:gtest",
+ "@googletest//:gtest_main",
],
)
@@ -73,8 +73,8 @@ cc_test(
srcs = ["smart_ptr_serializer_test.cc"],
deps = [
":fory_serialization",
- "@com_google_googletest//:gtest",
- "@com_google_googletest//:gtest_main",
+ "@googletest//:gtest",
+ "@googletest//:gtest_main",
],
)
@@ -83,8 +83,8 @@ cc_test(
srcs = ["map_serializer_test.cc"],
deps = [
":fory_serialization",
- "@com_google_googletest//:gtest",
- "@com_google_googletest//:gtest_main",
+ "@googletest//:gtest",
+ "@googletest//:gtest_main",
],
)
@@ -93,8 +93,8 @@ cc_test(
srcs = ["meta_string_test.cc"],
deps = [
":fory_serialization",
- "@com_google_googletest//:gtest",
- "@com_google_googletest//:gtest_main",
+ "@googletest//:gtest",
+ "@googletest//:gtest_main",
],
)
diff --git a/cpp/fory/type/BUILD b/cpp/fory/type/BUILD
index aecf58bf1..aeff47cdb 100644
--- a/cpp/fory/type/BUILD
+++ b/cpp/fory/type/BUILD
@@ -2,7 +2,7 @@ load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
cc_library(
name = "fory_type",
- srcs = glob(["*.cc"], exclude=["*test.cc"]),
+ srcs = glob(["*.cc"], exclude=["*test.cc"], allow_empty = True),
hdrs = glob(["*.h"]),
copts = select({
"@platforms//cpu:x86_64": ["-mavx2"],
diff --git a/cpp/fory/util/BUILD b/cpp/fory/util/BUILD
index b44c464c3..6e90873e9 100644
--- a/cpp/fory/util/BUILD
+++ b/cpp/fory/util/BUILD
@@ -9,9 +9,9 @@ cc_library(
linkstatic=True,
deps = [
"//cpp/fory/meta:fory_meta",
- "@com_google_absl//absl/debugging:failure_signal_handler",
- "@com_google_absl//absl/debugging:stacktrace",
- "@com_google_absl//absl/debugging:symbolize",
+ "@abseil-cpp//absl/debugging:failure_signal_handler",
+ "@abseil-cpp//absl/debugging:stacktrace",
+ "@abseil-cpp//absl/debugging:symbolize",
],
visibility = ["//visibility:public"],
)
@@ -22,8 +22,8 @@ cc_test(
srcs = ["time_util_test.cc"],
deps = [
":fory_util",
- "@com_google_googletest//:gtest",
- "@com_google_googletest//:gtest_main",
+ "@googletest//:gtest",
+ "@googletest//:gtest_main",
],
)
@@ -32,7 +32,7 @@ cc_test(
srcs = ["logging_test.cc"],
deps = [
":fory_util",
- "@com_google_googletest//:gtest",
+ "@googletest//:gtest",
],
)
@@ -41,7 +41,7 @@ cc_test(
srcs = ["result_test.cc"],
deps = [
":fory_util",
- "@com_google_googletest//:gtest",
+ "@googletest//:gtest",
],
)
@@ -50,7 +50,7 @@ cc_test(
srcs = ["error_test.cc"],
deps = [
":fory_util",
- "@com_google_googletest//:gtest",
+ "@googletest//:gtest",
],
)
@@ -59,8 +59,8 @@ cc_test(
srcs = ["buffer_test.cc"],
deps = [
":fory_util",
- "@com_google_googletest//:gtest",
- "@com_google_googletest//:gtest_main",
+ "@googletest//:gtest",
+ "@googletest//:gtest_main",
],
)
@@ -69,8 +69,8 @@ cc_test(
srcs = ["pool_test.cc"],
deps = [
":fory_util",
- "@com_google_googletest//:gtest",
- "@com_google_googletest//:gtest_main",
+ "@googletest//:gtest",
+ "@googletest//:gtest_main",
],
)
@@ -79,6 +79,6 @@ cc_test(
srcs = ["string_util_test.cc"],
deps = [
":fory_util",
- "@com_google_googletest//:gtest",
+ "@googletest//:gtest",
],
)
diff --git a/licenses/LICENSE-tensorflow.txt b/licenses/LICENSE-tensorflow.txt
deleted file mode 100644
index 12d255f8e..000000000
--- a/licenses/LICENSE-tensorflow.txt
+++ /dev/null
@@ -1,251 +0,0 @@
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-## Some of TensorFlow's code is derived from Caffe, which is subject to the
following copyright notice:
-
-COPYRIGHT
-
-All contributions by the University of California:
-
-Copyright (c) 2014, The Regents of the University of California (Regents)
-All rights reserved.
-
-All other contributions:
-
-Copyright (c) 2014, the respective contributors
-All rights reserved.
-
-Caffe uses a shared copyright model: each contributor holds copyright over
-their contributions to Caffe. The project versioning records all such
-contribution and copyright details. If a contributor wants to further mark
-their specific copyright on a particular contribution, they should indicate
-their copyright solely in the commit message of the change when it is
-committed.
-
-LICENSE
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-1. Redistributions of source code must retain the above copyright notice, this
- list of conditions and the following disclaimer.
-
-2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR
- ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-CONTRIBUTION AGREEMENT
-
-By contributing to the BVLC/caffe repository through pull-request, comment,
-or otherwise, the contributor releases their content to the
-license and copyright terms herein.
\ No newline at end of file
diff --git a/python/CONTRIBUTING.md b/python/CONTRIBUTING.md
index 0f2cd4914..eecb4d73e 100644
--- a/python/CONTRIBUTING.md
+++ b/python/CONTRIBUTING.md
@@ -20,10 +20,6 @@ temporary directory it was the last time bazel ran. To
remedy this run
> bazel clean --expunge
-In this situation, you might also find it fruitful to run bazel yourself
before pip:
-
-> bazel build -s //:cp_fory_so
-
### Environment Requirements
- python 3.8+
diff --git a/python/setup.py b/python/setup.py
index d31f5544f..6dc32ade8 100644
--- a/python/setup.py
+++ b/python/setup.py
@@ -45,7 +45,12 @@ class BinaryDistribution(Distribution):
def __init__(self, attrs=None):
super().__init__(attrs=attrs)
if BAZEL_BUILD_EXT:
+ import sys
+
+ python_version =
f"{sys.version_info.major}.{sys.version_info.minor}"
bazel_args = ["bazel", "build", "-s"]
+ # Pass Python version to select the correct toolchain for C
extension headers
+ bazel_args +=
[f"--@rules_python//python/config_settings:python_version={python_version}"]
arch = platform.machine().lower()
if arch in ("x86_64", "amd64"):
bazel_args += ["--config=x86_64"]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]