Skip to content

add native windows support - #144

Merged
sverhoeven merged 31 commits into
masterfrom
windows
Sep 9, 2026
Merged

add native windows support#144
sverhoeven merged 31 commits into
masterfrom
windows

Conversation

@rvhonorato

@rvhonorato rvhonorato commented Sep 4, 2026

Copy link
Copy Markdown
Member

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-win build which is the 3.14 freethreaded build because pyfftw does not have wheels for it yet

after this PR is merged and a new release is made, it should be possible for windows native users to simply run pip install powerfit-em in powershell/cmd.

I have updated the install instructions but I do not have a windows machine here to test, so please try it out.

@rvhonorato rvhonorato changed the title add windows support add native windows support Sep 4, 2026
@rvhonorato rvhonorato self-assigned this Sep 4, 2026
@rvhonorato
rvhonorato marked this pull request as ready for review September 4, 2026 14:09
@rvhonorato rvhonorato linked an issue Sep 4, 2026 that may be closed by this pull request

@AnnaEngel98 AnnaEngel98 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

Comment thread README.md

@sverhoeven sverhoeven left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 4

Powerfit 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')
1
Also 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.

Comment thread pyproject.toml
Comment thread README.md
@sverhoeven

Copy link
Copy Markdown
Collaborator

Can you do a patch bump to 6.0.2 in rust/Cargo.toml , so on merging we can immediately create a release.

@AnnaEngel98

Copy link
Copy Markdown
Contributor

For me it now works!

@AnnaEngel98

AnnaEngel98 commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

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.
Then once merged I will re-generate the output in the haddocking/powerfit-examples repo

EDIT: Done!

AnnaEngel98
AnnaEngel98 previously approved these changes Sep 7, 2026

@sverhoeven sverhoeven left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docs are not completely accurate. Please correct.

Also tests could be improved.

Comment thread tests/test_report.py Outdated
Comment thread docs/installation.md Outdated
Comment thread docs/installation.md Outdated
sverhoeven
sverhoeven previously approved these changes Sep 9, 2026

@sverhoeven sverhoeven left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the work.

I have pushed updates for installation.md .

Could @rvhonorato and/or @AnnaEngel98 review my changes?

Comment thread docs/installation.md
Comment thread docs/installation.md
Comment thread docs/installation.md Outdated
Comment thread docs/installation.md
Co-authored-by: Rodrigo Vargas Honorato <r.vargashonorato@uu.nl>
@rvhonorato

Copy link
Copy Markdown
Member Author

Think we are done here, @sverhoeven could you please handle the release?

@sverhoeven

Copy link
Copy Markdown
Collaborator

Think we are done here, @sverhoeven could you please handle the release?

Will do.

@sverhoeven
sverhoeven merged commit e066414 into master Sep 9, 2026
22 checks passed
@sverhoeven
sverhoeven deleted the windows branch September 9, 2026 12:19
@sverhoeven

Copy link
Copy Markdown
Collaborator

Think we are done here, @sverhoeven could you please handle the release?

Will do.

Done 6.0.2 is on pypi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for Windows

3 participants