Skip to content

Commit

Permalink
[4/4] Support for macOS - update
Browse files Browse the repository at this point in the history
  • Loading branch information
lifeiteng committed Jan 13, 2023
1 parent 6e1d4b4 commit 5a878d7
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 120 deletions.
102 changes: 0 additions & 102 deletions docker/dev.dockerfile

This file was deleted.

1 change: 0 additions & 1 deletion docker/release.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ ARG pip_dependencies=' \
numpy \
oauth2client \
pandas \
platform \
portpicker'

RUN for python in ${python_version}; do \
Expand Down
11 changes: 5 additions & 6 deletions oss_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,17 @@ for python_version in $PYTHON_VERSIONS; do
else
echo "Error unknown --python. Only [3.7|3.8|3.9|3.10]"
exit 1
fi

export PYTHON_BIN_PATH=`which python${python_version}`
export PYTHON_LIB_PATH=`${PYTHON_BIN_PATH} -c 'import site; print(site.getsitepackages()[0])'`

if [ "$(uname)" = "Darwin" ]; then
bazel_config=""
version=`sw_vers -productVersion | sed 's/\./_/g' | cut -d"_" -f1,2`
PLATFORM="macosx_${version}_"`uname -m`
PLATFORM=`${PYTHON_BIN_PATH} -c "from distutils import util; print(util.get_platform())"`
else
bazel_config="--config=manylinux2010"
bazel_config=""
PLATFORM="manylinux2010_x86_64"
bazel_config="--config=manylinux2014"
PLATFORM="manylinux2014_x86_64"
fi

# Configures Bazel environment for selected Python version.
Expand All @@ -141,7 +140,7 @@ for python_version in $PYTHON_VERSIONS; do
./bazel-bin/reverb/pip_package/build_pip_package --dst $OUTPUT_DIR $PIP_PKG_EXTRA_ARGS --platform "$PLATFORM"

# Installs pip package.
$PYTHON_BIN_PATH -mpip install --force-reinstall ${OUTPUT_DIR}*${ABI}*.whl
$PYTHON_BIN_PATH -m pip install --force-reinstall ${OUTPUT_DIR}*${ABI}*.whl

if [ "$PYTHON_TESTS" = "true" ]; then
echo "Run Python tests..."
Expand Down
16 changes: 8 additions & 8 deletions reverb/cc/platform/default/repo.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -235,20 +235,23 @@ def _tensorflow_solib_repo_impl(repo_ctx):
tf_lib_path = _find_tf_lib_path(repo_ctx)
repo_ctx.symlink(tf_lib_path, "tensorflow_solib")
if is_darwin(repo_ctx):
suffix = "2.dylib"
tensorflow_solib = "libtensorflow_cc.2.dylib"
full_path = repo_ctx.path("tensorflow_solib/{}".format(tensorflow_solib))
if not full_path.exists:
tensorflow_solib = "libtensorflow_framework.2.dylib"
else:
suffix = "so.2"
tensorflow_solib = "libtensorflow_framework.so.2"

repo_ctx.file(
"BUILD",
content = """
cc_library(
name = "framework_lib",
srcs = ["tensorflow_solib/libtensorflow_framework.{suffix}"],
srcs = ["tensorflow_solib/{tensorflow_solib}"],
deps = ["@python_includes", "@python_includes//:numpy_includes"],
visibility = ["//visibility:public"],
)
""".format(suffix=suffix))
""".format(tensorflow_solib=tensorflow_solib))

def _python_includes_repo_impl(repo_ctx):
python_include_path = _find_python_include_path(repo_ctx)
Expand All @@ -267,9 +270,6 @@ def _python_includes_repo_impl(repo_ctx):
else:
python_includes_srcs = 'srcs = ["%s"],' % python_solib.basename

# Note, "@python_includes" is a misnomer since we include the
# libpythonX.Y.so in the srcs, so we can get access to python's various
# symbols at link time.
repo_ctx.file(
"BUILD",
content = """
Expand Down Expand Up @@ -394,7 +394,7 @@ def _protoc_archive(ctx):

if is_darwin(ctx):
platform = "osx"
sha256 = ""
sha256 = "99729771ccb2f70621ac20f241f6ab1c70271f2c6bd2ea1ddbd9c2f7ae08d316"
else:
platform = "linux"

Expand Down
6 changes: 4 additions & 2 deletions reverb/cc/table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,12 @@ Table::Table(std::string name, std::shared_ptr<ItemSelector> sampler,
num_unique_samples_(0),
max_size_(max_size),
max_enqueued_inserts_(
std::max(1L, std::min<int64_t>(max_size * kMaxEnqueuedInsertsPerc,
std::max(static_cast<int64_t>(1),
std::min<int64_t>(max_size * kMaxEnqueuedInsertsPerc,
kMaxEnqueuedInserts))),
max_enqueued_extension_ops_(
std::max(1L, std::min<int64_t>(max_size * kMaxPendingExtensionOpsPerc,
std::max(static_cast<int64_t>(1),
std::min<int64_t>(max_size * kMaxPendingExtensionOpsPerc,
kMaxPendingExtensionOps))),
max_times_sampled_(max_times_sampled),
name_(std::move(name)),
Expand Down
3 changes: 2 additions & 1 deletion run_python_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ py_test() {

echo "===========Running Python tests============"

for test_file in `find reverb/ -name '*_test.py' -print`
cd reverb/ # Fix OSX circular import error
for test_file in `find ./ -name '*_test.py' -print`
do
echo "####=======Testing ${test_file}=======####"
${PYTHON_BIN_PATH} "${test_file}"
Expand Down

0 comments on commit 5a878d7

Please sign in to comment.