-
Notifications
You must be signed in to change notification settings - Fork 42
Add Windows build #893
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add Windows build #893
Conversation
thanks Mateusz!
Agree, would you be able to try this out? maybe in a separate PR to make things easier
this part is tricky, especially the protobuf dependency version. Downstream users are very sensitive to it. In particular, TensorFlow has pretty old protobuf dependency and using the newer ones may result into a crash in the env with grain + tensorflow. We wouldn't want that ideally. Would it be possible to not upgrade the dependencies yet? were the complaints errors?
yeah, there's an ongoing work to fix array-record build (it's broken at main), once that is in, or folks will add Windows build. For now, we shouldn't block on that (i.e. let the install fail, at least verify that we can build wheels). |
Sure! I'll take care of it.
I think I upgraded only those that otherwise gave a dependency resolve error. But I can rerun it and paste details here - maybe there's a workaround for it. |
@iindyk some updates:
|
0bf68ef
to
e205ea8
Compare
no, you're right. Would you be able to fork our build and publish workflow (no need for nightly) with added windows support and send out a PR to array-record? I will be able to submit it from inside and add trusted publishing. We can submit this in Grain either way, and test after AR release with Windows. here's the workflow I used for the last release: https://github.com/iindyk/array_record/blob/main/.github/workflows/build_and_publish.yml |
@@ -46,6 +46,9 @@ jobs: | |||
uses: actions/setup-python@v5 | |||
with: | |||
python-version: ${{ matrix.python-version }} | |||
- name: Install rsync for Windows |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
@@ -21,7 +21,7 @@ bazel_dep(name = "bazel_skylib", version = "1.6.1") | |||
bazel_dep(name = "platforms", version = "0.0.9") | |||
bazel_dep(name = "rules_python", version = "0.37.0") | |||
bazel_dep(name = "rules_cc", version = "0.0.9") | |||
bazel_dep(name = "pybind11_bazel", version = "2.11.1") | |||
bazel_dep(name = "pybind11_bazel", version = "2.11.1.bzl.3") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Building extension modules on Windows was fixed in that release: https://github.com/pybind/pybind11_bazel/releases/tag/v2.11.1.bzl.3
import threading | ||
import time | ||
import typing | ||
from typing import Any, Generic, Optional, Protocol, SupportsIndex, TypeVar, Union | ||
|
||
from absl import logging | ||
import array_record.python.array_record_data_source as array_record | ||
from etils import epath |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't use from etils import epy; epy.lazy_imports()
as Union
didn't allow epy
's returned type.
*) | ||
INCLUDE_EXT="*.so" | ||
# Also reduce noise during build. | ||
write_to_bazelrc "build --cxxopt=-Wno-deprecated-declarations --host_cxxopt=-Wno-deprecated-declarations" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I searched it and AFAIK There are no counterparts in MSVC.
Hi @iindyk, The Windows build for Grain is ready for review. I made minimal changes that were required to make it work, incl. Here's a successful build in my fork: https://github.com/mtsokol/grain/actions/runs/16052901995 |
rsync -avm -L --exclude="__pycache__/*" grain "${TMPDIR}" | ||
rsync -avm -L --include="*.so" --include="*_pb2.py" \ | ||
|
||
rsync -avm -L --exclude="__pycache__/*" grain tmp_folder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one was pretty tricky. Installed rsync
(cygwin version) had a problem with absolute paths in Windows, namely for /tmp
folder, as on Windows it's c:\users\runner~1\appdata\local\temp\
, causing:
ssh: Could not resolve hostname c: Name or service not known
thinking that Windows C:\...
path means some server C
. So I'm using an intermediate folder, and then copy to the desired one (doesn't matter on Linux/MacOS).
Here's the same issue on SO:
https://stackoverflow.com/questions/51536762/rsync-does-not-recognize-windows-path
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you pls add a comment about the intermediate folder here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
8193c75
to
6255902
Compare
if: runner.os == 'Windows' | ||
run: | | ||
echo "TEMP_DIR=${PWD}" >> $GITHUB_ENV | ||
echo "WHL_DIR=." >> $GITHUB_ENV |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had an issue with missing wheel files, looks like absolute paths on Windows aren't supported in actions/upload-artifact
: actions/upload-artifact#519 (comment)
data = select({ | ||
"@platforms//os:windows": ["//grain/_src/python/experimental/index_shuffle/python:index_shuffle_module.pyd"], | ||
"//conditions:default": ["//grain/_src/python/experimental/index_shuffle/python:index_shuffle_module.so"], | ||
}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does Bazel allow to do it in a more concise manner? (Move path to a variable an glue the extension separately?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure, I think this is ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks Mateusz!
data = select({ | ||
"@platforms//os:windows": ["//grain/_src/python/experimental/index_shuffle/python:index_shuffle_module.pyd"], | ||
"//conditions:default": ["//grain/_src/python/experimental/index_shuffle/python:index_shuffle_module.so"], | ||
}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure, I think this is ok
from grain._src.python.experimental.index_shuffle.python import index_shuffle_module as index_shuffle | ||
|
||
with epy.lazy_imports(): | ||
from grain._src.python.experimental.index_shuffle.python import index_shuffle_module as index_shuffle |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this import not work on Windows?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right - this doesn't import array_record
and works on Windows, reverted.
rsync -avm -L --exclude="__pycache__/*" grain "${TMPDIR}" | ||
rsync -avm -L --include="*.so" --include="*_pb2.py" \ | ||
|
||
rsync -avm -L --exclude="__pycache__/*" grain tmp_folder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you pls add a comment about the intermediate folder here?
@iindyk I addressed your comments. In the follow-up I will add skips for 10 tests that fail on windows (e.g. due to unix-like paths in assert strings or |
PORTED FROM #893 PiperOrigin-RevId: 784697196
PORTED FROM #893 PiperOrigin-RevId: 784697196
Ported from #893 PiperOrigin-RevId: 784697196
Ported from #893 PiperOrigin-RevId: 784697196
Ported from #893 PiperOrigin-RevId: 784697196
Ported from #893 PiperOrigin-RevId: 784697196
Ported from #893 PiperOrigin-RevId: 784697196
Ported from #893 PiperOrigin-RevId: 784697196
Ported from #893 PiperOrigin-RevId: 784697196
Ported from #893 PiperOrigin-RevId: 784697196
Ported from #893 PiperOrigin-RevId: 784697196
Ported from #893 PiperOrigin-RevId: 785285748
Should we close this PR? |
Here's a PR with Windows build support, without
array_record
dependency.Outdated:
setup-bazel
andsetup-python
Actions for Bazel and Python setup for all environments, rather than downloading and installing them in the script.I couldn't make it work with the current pyenv and bazel installation on Windows - switching to GitHub Actions worked out of the box.
Module.bazel
dependencies versions - I upgraded them.array-record
- package: https://pypi.org/project/array-record/#history. The current setup requires0.7.2
but Windows wheels for it are missing and the last one goes back to0.4.1
: https://github.com/mtsokol/grain/actions/runs/15418522140/job/43387085894.I think that first we need to make sure that all dependencies have Windows distributions.
📚 Documentation preview 📚: https://google-grain--893.org.readthedocs.build/