Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
vadimq committed Aug 16, 2022
0 parents commit 0864bb4
Show file tree
Hide file tree
Showing 34 changed files with 1,122 additions and 0 deletions.
1 change: 1 addition & 0 deletions .bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.7.2
69 changes: 69 additions & 0 deletions .github/workflows/envlogger-windows-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: envlogger-windows-build
on:
workflow_dispatch:
inputs:
python-x:
required: true
default: 3
python-y:
required: true
default: 10
build:
default: true
type: boolean
tag:
required: true
default: 1.0.8
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
with:
repository: deepmind/envlogger
- uses: actions/checkout@v3
with:
path: build
- uses: msys2/setup-msys2@v2
with:
install: >-
gmp-devel
mingw-w64-x86_64-gcc
release: false
- run: |
echo "C:\msys64\usr\bin" >> $GITHUB_PATH
echo "C:\msys64\mingw64\bin" >> $GITHUB_PATH
shell: bash
- uses: actions/setup-python@v4
with:
python-version: ${{ inputs.python-x }}.${{ inputs.python-y }}
- run: |
xcopy /Y build
xcopy build\patches patches
bash -c "git apply -v *.diff"
sed -i "s/cp310/cp${{ inputs.python-x }}${{ inputs.python-y }}/" envlogger\BUILD.bazel
sed -i "s/1\.0\.8/${{ inputs.tag }}/" envlogger\BUILD.bazel
curl -O https://storage.googleapis.com/google-code-archive-source/v2/code.google.com/mman-win32/source-archive.zip
C:\Windows\System32\tar.exe -xf source-archive.zip mman-win32/trunk
cd mman-win32\trunk
bash ./configure --libdir=/mingw64/lib --incdir=/mingw64/include/sys
make
make install
shell: cmd
- run: |
bazel test --compiler=mingw-gcc --define cpu=haswell --test_output=errors --verbose_failures envlogger/...
if: ${{ inputs.build == false }}
env:
BAZEL_SH: C:\msys64\usr\bin\bash.exe
shell: cmd
- run: |
bazel build --compiler=mingw-gcc --define cpu=haswell --test_output=errors --verbose_failures envlogger:package
if: ${{ inputs.build == true }}
env:
BAZEL_SH: C:\msys64\usr\bin\bash.exe
shell: cmd
- run: |
gh release upload ${{ inputs.tag }} bazel-bin/envlogger/*.whl --clobber -R ${{ github.repository }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
56 changes: 56 additions & 0 deletions BUILD.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
diff --git a/envlogger/BUILD.bazel b/envlogger/BUILD.bazel
index 6881b77..4727880 100644
--- a/envlogger/BUILD.bazel
+++ b/envlogger/BUILD.bazel
@@ -15,9 +15,40 @@
# Build targets for environment logger.
load("@py_deps//:requirements.bzl", "requirement")
load("@rules_python//python:defs.bzl", "py_library")
+load("@rules_python//python:packaging.bzl", "py_package", "py_wheel")

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

+py_package(
+ name = "pkg",
+ packages = ["envlogger"],
+ deps = [
+ ":envlogger",
+ "//envlogger/backends:rlds_utils",
+ "//envlogger/backends:tfds_backend_writer",
+ "//envlogger/testing:catch_env",
+ ],
+)
+
+py_wheel(
+ name = "package",
+ abi = "cp310",
+ distribution = "envlogger",
+ platform = "win_amd64",
+ python_tag = "cp310",
+ requires = [
+ "absl-py",
+ "dm_env",
+ "numpy",
+ "protobuf>=3.14, <4.0",
+ "setuptools!=50.0.0",
+ ],
+ version = "1.0.8",
+ deps = [
+ ":pkg",
+ ],
+)
+
py_library(
name = "envlogger",
srcs = ["__init__.py"],
@@ -80,8 +111,8 @@ py_library(
name = "reader",
srcs = ["reader.py"],
data = [
- "//envlogger/backends/python:episode_info.so",
- "//envlogger/backends/python:riegeli_dataset_reader.so",
+ "//envlogger/backends/python:episode_info.pyd",
+ "//envlogger/backends/python:riegeli_dataset_reader.pyd",
],
deps = [
":step_data",
42 changes: 42 additions & 0 deletions BUILD2.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
diff --git a/envlogger/backends/BUILD.bazel b/envlogger/backends/BUILD.bazel
index 740d48e..46c190f 100644
--- a/envlogger/backends/BUILD.bazel
+++ b/envlogger/backends/BUILD.bazel
@@ -47,7 +47,7 @@ py_test(
py_library(
name = "backend_reader",
srcs = ["backend_reader.py"],
- data = ["//envlogger/backends/python:episode_info.so"],
+ data = ["//envlogger/backends/python:episode_info.pyd"],
deps = [
"//envlogger:step_data",
"//envlogger/converters:codec",
@@ -66,7 +66,7 @@ py_library(
py_library(
name = "in_memory_backend",
srcs = ["in_memory_backend.py"],
- data = ["//envlogger/backends/python:episode_info.so"],
+ data = ["//envlogger/backends/python:episode_info.pyd"],
deps = [
":backend_reader",
":backend_writer",
@@ -92,8 +92,8 @@ py_library(
name = "riegeli_backend_reader",
srcs = ["riegeli_backend_reader.py"],
data = [
- "//envlogger/backends/python:episode_info.so",
- "//envlogger/backends/python:riegeli_dataset_reader.so",
+ "//envlogger/backends/python:episode_info.pyd",
+ "//envlogger/backends/python:riegeli_dataset_reader.pyd",
],
deps = [
":backend_reader",
@@ -109,7 +109,7 @@ py_library(
name = "riegeli_backend_writer",
srcs = ["riegeli_backend_writer.py"],
data = [
- "//envlogger/backends/python:riegeli_dataset_writer.so",
+ "//envlogger/backends/python:riegeli_dataset_writer.pyd",
],
deps = [
":backend_writer",
85 changes: 85 additions & 0 deletions BUILD3.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
diff --git a/envlogger/backends/python/BUILD.bazel b/envlogger/backends/python/BUILD.bazel
index 2b29d51..291b146 100644
--- a/envlogger/backends/python/BUILD.bazel
+++ b/envlogger/backends/python/BUILD.bazel
@@ -19,6 +19,14 @@ package(default_visibility = ["//envlogger:__subpackages__"])

pybind_extension(
name = "riegeli_dataset_reader",
+ linkopts = [
+ "-static-libgcc",
+ "-static-libstdc++",
+ "-Wl,-Bstatic,--whole-archive",
+ "-lwinpthread",
+ "-Wl,--no-whole-archive",
+ "-Wl,--allow-multiple-definition"
+ ],
srcs = ["riegeli_dataset_reader.cc"],
deps = [
"//envlogger/backends/cc:riegeli_dataset_reader",
@@ -29,8 +37,23 @@ pybind_extension(
],
)

+genrule(
+ name = "riegeli_dataset_reader_pyd",
+ srcs = ["riegeli_dataset_reader.so"],
+ outs = ["riegeli_dataset_reader.pyd"],
+ cmd = "mv $(location riegeli_dataset_reader.so) $(location riegeli_dataset_reader.pyd)",
+)
+
pybind_extension(
name = "riegeli_dataset_writer",
+ linkopts = [
+ "-static-libgcc",
+ "-static-libstdc++",
+ "-Wl,-Bstatic,--whole-archive",
+ "-lwinpthread",
+ "-Wl,--no-whole-archive",
+ "-Wl,--allow-multiple-definition"
+ ],
srcs = ["riegeli_dataset_writer.cc"],
deps = [
"//envlogger/backends/cc:riegeli_dataset_writer",
@@ -41,8 +64,22 @@ pybind_extension(
],
)

+genrule(
+ name = "riegeli_dataset_writer_pyd",
+ srcs = ["riegeli_dataset_writer.so"],
+ outs = ["riegeli_dataset_writer.pyd"],
+ cmd = "mv $(location riegeli_dataset_writer.so) $(location riegeli_dataset_writer.pyd)",
+)
+
pybind_extension(
name = "episode_info",
+ linkopts = [
+ "-static-libgcc",
+ "-static-libstdc++",
+ "-Wl,-Bstatic,--whole-archive",
+ "-lwinpthread",
+ "-Wl,--no-whole-archive"
+ ],
srcs = ["episode_info.cc"],
deps = [
"//envlogger/backends/cc:episode_info",
@@ -51,10 +88,17 @@ pybind_extension(
],
)

+genrule(
+ name = "episode_info_pyd",
+ srcs = ["episode_info.so"],
+ outs = ["episode_info.pyd"],
+ cmd = "mv $(location episode_info.so) $(location episode_info.pyd)",
+)
+
py_test(
name = "episode_info_test",
srcs = ["episode_info_test.py"],
- data = [":episode_info.so"],
+ data = [":episode_info.pyd"],
deps = [
"//envlogger/proto:storage_py_pb2",
requirement("absl-py"),
12 changes: 12 additions & 0 deletions BUILD4.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/envlogger/converters/BUILD.bazel b/envlogger/converters/BUILD.bazel
index 6670874..857750b 100644
--- a/envlogger/converters/BUILD.bazel
+++ b/envlogger/converters/BUILD.bazel
@@ -81,6 +81,7 @@ cc_test(
name = "xtensor_codec_test",
srcs = ["xtensor_codec_test.cc"],
deps = [
+ "@dbghelp",
":make_visitor",
":xtensor_codec",
"//envlogger/platform:parse_text_proto",
Loading

0 comments on commit 0864bb4

Please sign in to comment.