python-hyperscan icon indicating copy to clipboard operation
python-hyperscan copied to clipboard

Adding Windows compatibility for hyperscan

Open steven-t-murphy opened this issue 1 year ago • 2 comments

Discussed in https://github.com/darvid/python-hyperscan/discussions/155

Originally posted by steven-t-murphy September 9, 2024

Our team has been working on a project that required Hyperscan to be compatible with Windows. We modified the setup.py and created a script to enable successful builds on Windows, and we are now using Hyperscan on both Windows and Linux platforms.

We would like to contribute these changes back to the community.

Exit Criteria:

  • python-hyperscan fork are both public on GitHub
  • GitHub regression testing operational
  • pypi updated with windows compatibility

steven-t-murphy avatar Oct 02 '24 15:10 steven-t-murphy

For this reason: https://github.com/SAP/credential-digger/issues/52#issuecomment-712261327

I would really like to see Windows support too. to be able to use https://marketplace.visualstudio.com/items?itemName=SAPOSS.vs-code-extension-for-project-credential-digger the plugin in VSCode.

JaneX8 avatar Oct 14 '24 16:10 JaneX8

@darvid

LucianoBAF avatar Oct 16 '24 13:10 LucianoBAF

Does anyone happen to have any more information on the progress of this issue, or alternative solutions?

JaneX8 avatar Nov 28 '24 22:11 JaneX8

For credential digger specifically, it appears that extension supports changing the binary location as well as using a Docker container, so I would suspect it could be possible to use WSL or docker?

darvid avatar Nov 28 '24 23:11 darvid

Ah yes. I could make that work. Thank you for that idea.

JaneX8 avatar Nov 29 '24 18:11 JaneX8

PR opened to add windows compatibility https://github.com/darvid/python-hyperscan/pull/168

steven-t-murphy avatar Jan 09 '25 17:01 steven-t-murphy

PR opened to add windows compatibility https://github.com/darvid/python-hyperscan/pull/168

Thank you Steven! Great job.

JaneX8 avatar Jan 09 '25 17:01 JaneX8

To build the wheels I am currently bypassing pdm_build https://github.com/darvid/python-hyperscan/blob/30c13f55bb3a973a8b66e372dd6848c4a7f0b991/pdm_build.py#L43 which specifies "win32 not currently supported". The way I am bypassing is simply running.

python -m pip install build
python -m build --wheel

I think as we look at the CI toolset this may be an aspect to look at for enabling the build of Windows artifacts.

steven-t-murphy avatar Jan 10 '25 20:01 steven-t-murphy

@darvid curious if you have a timeline in mind for releasing 0.79, and if there is anything you need from me to support adding the windows wheels to pypi.

steven-t-murphy avatar Feb 05 '25 14:02 steven-t-murphy

@steven-t-murphy apologies for the delays - spent a bit more time than anticipated due to factors mentioned below, but the long and short of it is I'd appreciate if you get a chance to checkout and build the wheels on Windows whenever you get a chance if you don't mind, with cibuildwheel ideally, e.g.:

pipx install cibuildwheel
cibuildwheel --only=cp313-win_amd64

TLDR of the changes, thanks to your work on the windows build that helped me figure out the following:

  • updated the build process to use more modern standards for native Python extensions, e.g. via scikit-build-core (+ CMake)
  • what took some time was figuring out how to build on win32 statically linked to MSVC and hyperscan. also, vectorscan explicitly dropped support for windows, so the current solution is use the last open source version of Hyperscan on win32, and vectorscan on other platforms (customizable with build time flags). an option for optimizing the build process would be to vendor HS/VS + build time deps for chimera/static support like PCRE, but for now I'm just pulling in dependencies with CMake.
  • had to do a bunch of platform specific configuration for CMake, currently some stuff is hardcoded (e.g. platform version for visual studio is 17 2022 which is the version available on MS Server Github action runners) while I test all platforms; windows, linux (gcc, glibc), and linux (musl) - trying macOS x86 and apple silicon next.

if everything works for you, the next step would be to configure the CI which in theory should be less complex now as we wouldn't need platform specific build scripts moving forward.

darvid avatar Feb 06 '25 20:02 darvid

ok there should be some windows wheels here:

https://github.com/darvid/python-hyperscan/actions/runs/13213324889

darvid avatar Feb 08 '25 07:02 darvid

unless there's any glaring issues, i'll cut a release soon

darvid avatar Feb 10 '25 22:02 darvid

Thanks for making the Windows compatibility!! Just to let you know that the Pypi package is still at 0.7.8. Would love to get version 0.7.9 in there to start using it from pip :). Thanks

LucianoBAF avatar Mar 20 '25 12:03 LucianoBAF

Would love to get version 0.7.9 in there to start using it from pip

It looks like your deployment workflow failed, @darvid. The binaries built successfully, but it failed to publish to PyPi

I suspect you simply need to change the package name back to hyperscan, as it was before your workflows revamp in 0.7.8

lazy-chesapeake avatar Apr 17 '25 02:04 lazy-chesapeake

Would love to get version 0.7.9 in there to start using it from pip

It looks like your deployment workflow failed, @darvid. The binaries built successfully, but it failed to publish to PyPi

I suspect you simply need to change the package name back to hyperscan, as it was before your workflows revamp in 0.7.8

[internally screaming]

apologies for the delay, win32 wheels should now be up, iterated on a few patch versions while debugging CI so we're going from 0.7.9 -> 0.7.12 but i don't want to mutate history so hopefully no more redundant releases required moving forward.

https://github.com/darvid/python-hyperscan/actions/runs/15048801362/job/42299607077

darvid avatar May 15 '25 15:05 darvid