Skip to content

Commit dad1f38

Browse files
committed
WIP: Build for macOS
1 parent 5391813 commit dad1f38

File tree

4 files changed

+25
-24
lines changed

4 files changed

+25
-24
lines changed

.bazelrc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ build -c opt
22
build --cxxopt=-std=c++17
33
build --host_cxxopt=-std=c++17
44
build --experimental_repo_remote_exec
5-
6-
# TODO(fchern): Use non-hardcode path.
7-
build --action_env=PYTHON_BIN_PATH="/usr/bin/python3"
8-
build --action_env=PYTHON_LIB_PATH="/usr/lib/python3"
9-
build --repo_env=PYTHON_BIN_PATH="/usr/bin/python3"
10-
build --python_path="/usr/bin/python3"
5+
build --linkopt="-lpthread -lm -framework CoreFoundation"
6+
build --action_env=PYTHON_BIN_PATH="/Users/pierremarcenac/.pyenv/shims/python"
7+
build --python_path="/Users/pierremarcenac/.pyenv/shims/python"
8+
build --action_env=PYTHON_LIB_PATH="/Users/pierremarcenac/.pyenv/versions/python3.10/lib/python3.10/site-packages"
9+
build --action_env=CXXFLAGS=-stdlib=libc++ --action_env=LDFLAGS=-stdlib=libc++ --action_env=BAZEL_CXXOPTS=-stdlib=libc++ --action_env=BAZEL_LINKOPTS=-lc++:-lm

WORKSPACE

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ cc_library(
5555
# `pybind11_bazel` (https://github.com/pybind/pybind11_bazel): 20230130
5656
http_archive(
5757
name = "pybind11_bazel",
58-
strip_prefix = "pybind11_bazel-5f458fa53870223a0de7eeb60480dd278b442698",
59-
sha256 = "b35f3abc3d52ee5c753fdeeb2b5129b99e796558754ca5d245e28e51c1072a21",
60-
urls = ["https://github.com/pybind/pybind11_bazel/archive/5f458fa53870223a0de7eeb60480dd278b442698.tar.gz"],
58+
strip_prefix = "pybind11_bazel-master",
59+
# sha256 = "b35f3abc3d52ee5c753fdeeb2b5129b99e796558754ca5d245e28e51c1072a21",
60+
urls = ["https://github.com/pybind/pybind11_bazel/archive/master.tar.gz"],
6161
)
6262
# V2.10.3, 20230130
6363
http_archive(
@@ -131,9 +131,9 @@ http_archive(
131131
http_archive(
132132
name = "highwayhash",
133133
build_file = "@com_google_riegeli//third_party:highwayhash.BUILD",
134-
sha256 = "cf891e024699c82aabce528a024adbe16e529f2b4e57f954455e0bf53efae585",
135-
strip_prefix = "highwayhash-276dd7b4b6d330e4734b756e97ccfb1b69cc2e12",
136-
urls = ["https://github.com/google/highwayhash/archive/276dd7b4b6d330e4734b756e97ccfb1b69cc2e12.zip"], # 2019-02-22
134+
# sha256 = "cf891e024699c82aabce528a024adbe16e529f2b4e57f954455e0bf53efae585",
135+
strip_prefix = "highwayhash-master",
136+
urls = ["https://github.com/google/highwayhash/archive/master.zip"], # 2019-02-22
137137
)
138138

139139
# Tensorflow, 20230130

cpp/array_record_reader.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ absl::Status ArrayRecordReaderBase::ParallelReadRecords(
317317
return absl::OkStatus();
318318
}
319319
uint64_t num_chunk_groups =
320-
CeilOfRatio(state_->footer.size(), state_->chunk_group_size);
320+
CeilOfRatio<uint64_t>(state_->footer.size(), state_->chunk_group_size);
321321
const auto reader = get_backing_reader();
322322
Reader* mutable_reader = const_cast<Reader*>(
323323
reinterpret_cast<const Reader*>(reader.get()));
@@ -326,7 +326,7 @@ absl::Status ArrayRecordReaderBase::ParallelReadRecords(
326326
uint64_t chunk_idx_start = buf_idx * state_->chunk_group_size;
327327
// inclusive index, not the conventional exclusive index.
328328
uint64_t last_chunk_idx =
329-
std::min((buf_idx + 1) * state_->chunk_group_size - 1,
329+
std::min<uint64_t>((buf_idx + 1) * state_->chunk_group_size - 1,
330330
state_->footer.size() - 1);
331331
uint64_t buf_len = state_->ChunkEndOffset(last_chunk_idx) -
332332
state_->footer[chunk_idx_start].chunk_offset();
@@ -654,7 +654,7 @@ bool ArrayRecordReaderBase::ReadAheadFromBuffer(uint64_t buffer_idx) {
654654
std::vector<ChunkDecoder> decoders;
655655
decoders.reserve(state_->chunk_group_size);
656656
uint64_t chunk_start = buffer_idx * state_->chunk_group_size;
657-
uint64_t chunk_end = std::min(state_->footer.size(),
657+
uint64_t chunk_end = std::min<uint64_t>(state_->footer.size(),
658658
(buffer_idx + 1) * state_->chunk_group_size);
659659
const auto reader = get_backing_reader();
660660
for (uint64_t chunk_idx = chunk_start; chunk_idx < chunk_end; ++chunk_idx) {
@@ -693,7 +693,7 @@ bool ArrayRecordReaderBase::ReadAheadFromBuffer(uint64_t buffer_idx) {
693693
std::vector<uint64_t> chunk_offsets;
694694
chunk_offsets.reserve(state_->chunk_group_size);
695695
uint64_t chunk_start = buffer_to_add * state_->chunk_group_size;
696-
uint64_t chunk_end = std::min(
696+
uint64_t chunk_end = std::min<uint64_t>(
697697
state_->footer.size(), (buffer_to_add + 1) * state_->chunk_group_size);
698698
for (uint64_t chunk_idx = chunk_start; chunk_idx < chunk_end; ++chunk_idx) {
699699
chunk_offsets.push_back(state_->footer[chunk_idx].chunk_offset());

oss/build_whl.sh

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
set -e -x
55

66
export PYTHON_VERSION="${PYTHON_VERSION}"
7-
PYTHON="python${PYTHON_VERSION}"
7+
PYTHON="python"
88
PYTHON_MAJOR_VERSION=$(${PYTHON} -c 'import sys; print(sys.version_info.major)')
99
PYTHON_MINOR_VERSION=$(${PYTHON} -c 'import sys; print(sys.version_info.minor)')
1010
BAZEL_FLAGS="--crosstool_top="
@@ -21,18 +21,20 @@ function main() {
2121
write_to_bazelrc "build -c opt"
2222
write_to_bazelrc "build --cxxopt=-std=c++17"
2323
write_to_bazelrc "build --host_cxxopt=-std=c++17"
24-
write_to_bazelrc "build --linkopt=\"-lrt -lm\""
24+
# write_to_bazelrc "build --linkopt=\"-lrt -lm\""
2525
write_to_bazelrc "build --experimental_repo_remote_exec"
26-
write_to_bazelrc "build --action_env=PYTHON_BIN_PATH=\"/usr/bin/${PYTHON}\""
27-
write_to_bazelrc "build --action_env=PYTHON_LIB_PATH=\"/usr/lib/${PYTHON}\""
28-
write_to_bazelrc "build --python_path=\"/usr/bin/${PYTHON}\""
26+
write_to_bazelrc "build --action_env=PYTHON_BIN_PATH=\"/Users/pierremarcenac/.pyenv/shims/python\""
27+
write_to_bazelrc "build --action_env=PYTHON_LIB_PATH=\"/Users/pierremarcenac/.pyenv/versions/python3.10/lib/python3.10/site-packages\""
28+
write_to_bazelrc "build --python_path=\"/Users/pierremarcenac/.pyenv/shims/python\""
29+
30+
${PYTHON} -m pip install absl-py etils wheel
2931

3032
# Using a previous version of Blaze to avoid:
3133
# https://github.com/bazelbuild/bazel/issues/8622
3234
export USE_BAZEL_VERSION=5.4.0
33-
bazel clean
34-
bazel build ${BAZEL_FLAGS} ...
35-
bazel test ${BAZEL_FLAGS} --verbose_failures --test_output=errors ...
35+
bazel clean --expunge
36+
bazel build //...
37+
bazel test --verbose_failures --test_output=errors //...
3638

3739
DEST="/tmp/array_record/all_dist"
3840
# Create the directory, then do dirname on a non-existent file inside it to

0 commit comments

Comments
 (0)