add native windows support - #144
Conversation
AnnaEngel98
left a comment
There was a problem hiding this comment.
You need to install Microsoft C++ Build Tools and then specifically the "Desktop development with C++" part to be able to use rust on Windows. So I think that needs to be added as a dependency for Windows.
Then, I used the example to run powerfit, and it all works, except when it wants to generate the report with the gzipped map, this also happens with the unzipped map
powerfit EMD-2325.map 8.9 3zpz_C.cif.gz --angle 5 --directory output --report --delimiter , --nproc 12
Target file read from: C:\Users\5807441\Documents\test\powerfit\test\EMD-2325.map
Target resolution: 8.90
Initial shape of density: 180 180 180
Shape after trimming: 103 78 77
Shape after extending: 105 80 80
Template file read from: C:\Users\5807441\Documents\test\powerfit\test\3zpz_C.cif.gz
Calculating core-weighted mask.
Reading in rotations.
Requested rotational sampling density: 5.00
Real rotational sampling density: 5.27
Requested number of processors: 12
Starting search
Time for search: 7m 7s
Analyzing results
Writing solutions to file.
Writing PDBs to file.
Total time: 7m 8s
Copying target file (EMD-2325.map) to report directory (output).
Traceback (most recent call last):
File "<frozen runpy>", line 203, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "C:\Users\5807441\Documents\test\powerfit\.venv\Scripts\powerfit.exe\__main__.py", line 10, in <module>
sys.exit(main())
~~~~^^
File "C:\Users\5807441\Documents\test\powerfit\.venv\Lib\site-packages\powerfit_em\powerfit.py", line 326, in main
generate_report(args.directory, args.target.name, args.num, args.delimiter, options=options)
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\5807441\Documents\test\powerfit\.venv\Lib\site-packages\powerfit_em\report.py", line 633, in generate_report
state_path.write_text(state.dumps(indent=2))
~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\5807441\AppData\Roaming\uv\python\cpython-3.14-windows-x86_64-none\Lib\pathlib\__init__.py", line 810, in write_text
return f.write(data)
~~~~~~~^^^^^^
File "C:\Users\5807441\AppData\Roaming\uv\python\cpython-3.14-windows-x86_64-none\Lib\encodings\cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeEncodeError: 'charmap' codec can't encode character '\u03b1' in position 3618: character maps to <undefined>
There was a problem hiding this comment.
Works, mostly except --report
Windows Python 3.14 wheel tests
I downloaded the Windows artifact zip from https://github.com/haddocking/powerfit/actions/runs/34101384448 and unzipped it.
# In Windows powershell with admin rights
winget install astral-sh.uv
# In normal powershell
mkdir bla
cd bla
uv venv --python 3.14
uv pip install ..\Downloads\cibw-wheels-windows-intel-3\powerfit_em-6.0.1-cp314-cp314-win_amd64.whl
Resolved 16 packages in 503ms
Prepared 14 packages in 1.24s
Installed 16 packages in 391ms
+ annotated-types==0.8.0
+ colorama==0.4.6
+ markdown-it-py==4.2.0
+ mdurl==0.1.2
+ molviewspec==1.8.1
+ numpy==2.5.3
+ powerfit-em==6.0.1 (from file:///C:/.../Downloads/cibw-wheels-windows-intel-3/powerfit_em-6.0.1-cp314-cp314-win_amd64.whl)
+ pydantic==2.13.5
+ pydantic-core==2.46.5
+ pyfftw==0.15.1
+ pygments==2.21.0
+ rich==15.0.0
+ scipy==1.18.1
+ tqdm==4.70.0
+ typing-extensions==4.16.0
+ typing-inspection==0.4.4
uv run powerfit emd_1046.map.gz 20 9A2G.cif.gz -a 20 --delimiter ',' -n 0 -d rdef
uv run powerfit emd_1046.map.gz 20 9A2G.cif.gz -a 20 --delimiter ',' -n 5 -d rcpurust --cpu-backend rust --report --nproc 4Powerfit runs OK, report does not.
Got same error as Anna: UnicodeEncodeError: 'charmap' codec can't encode character '\u03b1' in position 3618: character maps to <undefined> error.
We should call `write_text` with `encoding='utf-8'` arg to fix.
Python 3.13.14 (tags/v3.13.14:fd17997, Jun 10 2026, 13:03:48) [MSC v.1944 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from pathlib import Path
>>> Path("a.txt").write_text("α")
Traceback (most recent call last):
File "<python-input-1>", line 1, in <module>
Path("a.txt").write_text("α")
~~~~~~~~~~~~~~~~~~~~~~~~^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.13_3.13.3824.0_x64__qbz5n2kfra8p0\Lib\pathlib\_local.py", line 555, in write_text
return PathBase.write_text(self, data, encoding, errors, newline)
~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.13_3.13.3824.0_x64__qbz5n2kfra8p0\Lib\pathlib\_abc.py", line 652, in write_text
return f.write(data)
~~~~~~~^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.13_3.13.3824.0_x64__qbz5n2kfra8p0\Lib\encodings\cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeEncodeError: 'charmap' codec can't encode character '\u03b1' in position 0: character maps to <undefined>
>>> Path("a.txt").write_text("α", encoding='utf-8')
1Also got cuda version with conda working
winget install Nvidia.CUDA # In admin powershell
nvidia-smi
$env:CUDAHOME="C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.3"
uv pip install cupy-cuda13x siphash24 pyvkfft
× Failed to build `pyvkfft==2025.1.1`
├─▶ The build backend returned an error
╰─▶ Call to `setuptools.build_meta:__legacy__.build_wheel` failed (exit code: 1)
[stderr]
<string>:221: UserWarning: CUDA not available ($CUDAHOME/$CUDA_PATH variables missing and nvcc not in path. Skipping pyvkfft.cuda module installation.Take 2 using conda instead of uv
winget install Mamba.Micromamba # In admin powershell
C:\...\AppData\Local\micromamba\micromamba.exe create -n pf pyvkfft pyopencl cupy cuda-version=13
micromamba.exe shell hook -s powershell | Out-String | Invoke-Expression
micromamba activate pf
pip install ..\Downloads\cibw-wheels-windows-intel-3\powerfit_em-6.0.1-cp314-cp314-win_amd64.whl
powerfit emd_1046.map.gz 20 9A2G.cif.gz -a 20 --gpu -d rgpu
,,,
Using CUDA-accelerated search.
Starting search
Batching 648 rotations with batch size 100 (max 1786).
Time for search: 1.488 s
...Please fix report and incorporate my testing into docs.
|
Can you do a patch bump to 6.0.2 in rust/Cargo.toml , so on merging we can immediately create a release. |
|
For me it now works! |
|
I will also update the example instructions here, so the example will also be with version 6.0.2 and running on windows, so please wait before merging. EDIT: Done! |
Update powerfit-example
sverhoeven
left a comment
There was a problem hiding this comment.
The docs are not completely accurate. Please correct.
Also tests could be improved.
sverhoeven
left a comment
There was a problem hiding this comment.
Thanks for the work.
I have pushed updates for installation.md .
Could @rvhonorato and/or @AnnaEngel98 review my changes?
Co-authored-by: Rodrigo Vargas Honorato <r.vargashonorato@uu.nl>
|
Think we are done here, @sverhoeven could you please handle the release? |
Will do. |
Done 6.0.2 is on pypi |
this PR adds native windows support to the release pipeline.
turns out the current code is already compatible with windows native, here I just had to make some minor tweaks to the tests to handle scenarios without
pyopencl(that were not being ran in the CI). I also added all supported OS to the testing matrix for completion.added a skip to
cp314t-winbuild which is the 3.14 freethreaded build because pyfftw does not have wheels for it yetafter this PR is merged and a new release is made, it should be possible for windows native users to simply run
pip install powerfit-emin powershell/cmd.I have updated the install instructions but I do not have a windows machine here to test, so please try it out.