freud icon indicating copy to clipboard operation
freud copied to clipboard

cibuildwheel for Windows

Open bdice opened this issue 3 years ago • 11 comments

Description

Extension of #746 for Windows wheels. The rest of #746 is relatively complete for Linux/Mac.

Motivation and Context

Windows wheels would be very helpful for use with the OVITO Pro desktop application.

How Has This Been Tested?

Needs manual testing.

Types of changes

  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [x] New feature (non-breaking change which adds or improves functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to change)
  • [ ] Documentation improvement (updates to user guides, docstrings, or developer docs)

Checklist:

  • [x] I have read the CONTRIBUTING document.
  • [x] My code follows the code style of this project.
  • [x] I have updated the documentation (if relevant).
  • [x] I have added tests that cover my changes (if relevant).
  • [ ] All new and existing tests passed.
  • [ ] I have updated the credits.
  • [ ] I have updated the Changelog.

bdice avatar Apr 17 '21 22:04 bdice

Codecov Report

Merging #749 (5374db2) into master (5e16b45) will not change coverage. The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #749   +/-   ##
=======================================
  Coverage   55.38%   55.38%           
=======================================
  Files          16       16           
  Lines        2580     2580           
  Branches       36       36           
=======================================
  Hits         1429     1429           
  Misses       1135     1135           
  Partials       16       16           

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 5e16b45...5374db2. Read the comment docs.

codecov[bot] avatar Apr 17 '21 23:04 codecov[bot]

Builds are failing because scikit-build doesn't find Visual Studio 2019 when building the wheel. CMake is able to successfully build the TBB library with Visual Studio 2019 before it tries to build freud, and it appears (from verbose output) that the isolated build environment should be using a recent enough version of CMake and scikit-build to detect and use Visual Studio 2019. @joaander @glotzerlab/freud-developers help would be appreciated, if you have any insights.

bdice avatar Apr 17 '21 23:04 bdice

It looks like the TBB installation is incomplete:

    CMake Error at C:/Program Files (x86)/TBB/lib/cmake/TBB/TBBTargets.cmake:91 (message):
      The imported target "TBB::tbb" references the file
  
         "C:/Program Files (x86)/TBB/lib/tbb12.lib"

There is a TBB cmake config file that references a library that wasn't installed.

Looking back at the TBB build in the CI output, it seems that it doesn't compile TBB at all.

  -- Install configuration: "Release"
  -- Install component: "devel"
  -- Installing: C:/Program Files (x86)/TBB/include
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/blocked_range.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/blocked_range2d.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/blocked_range3d.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/blocked_rangeNd.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/cache_aligned_allocator.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/combinable.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/concurrent_hash_map.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/concurrent_lru_cache.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/concurrent_map.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/concurrent_priority_queue.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/concurrent_queue.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/concurrent_set.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/concurrent_unordered_map.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/concurrent_unordered_set.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/concurrent_vector.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/detail
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/detail/_aggregator.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/detail/_aligned_space.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/detail/_allocator_traits.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/detail/_assert.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/detail/_concurrent_queue_base.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/detail/_concurrent_skip_list.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/detail/_concurrent_unordered_base.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/detail/_config.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/detail/_containers_helpers.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/detail/_exception.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/detail/_flow_graph_body_impl.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/detail/_flow_graph_cache_impl.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/detail/_flow_graph_impl.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/detail/_flow_graph_indexer_impl.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/detail/_flow_graph_item_buffer_impl.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/detail/_flow_graph_join_impl.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/detail/_flow_graph_nodes_deduction.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/detail/_flow_graph_node_impl.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/detail/_flow_graph_node_set_impl.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/detail/_flow_graph_tagged_buffer_impl.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/detail/_flow_graph_trace_impl.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/detail/_flow_graph_types_impl.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/detail/_hash_compare.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/detail/_machine.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/detail/_namespace_injection.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/detail/_node_handle.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/detail/_pipeline_filters.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/detail/_pipeline_filters_deduction.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/detail/_range_common.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/detail/_rtm_mutex.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/detail/_rtm_rw_mutex.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/detail/_segment_table.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/detail/_small_object_pool.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/detail/_string_resource.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/detail/_task.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/detail/_template_helpers.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/detail/_utils.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/enumerable_thread_specific.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/flow_graph.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/flow_graph_abstractions.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/global_control.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/info.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/memory_pool.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/null_mutex.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/null_rw_mutex.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/parallel_for.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/parallel_for_each.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/parallel_invoke.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/parallel_pipeline.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/parallel_reduce.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/parallel_scan.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/parallel_sort.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/partitioner.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/profiling.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/queuing_mutex.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/queuing_rw_mutex.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/scalable_allocator.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/spin_mutex.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/spin_rw_mutex.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/task.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/task_arena.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/task_group.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/task_scheduler_observer.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/tbbmalloc_proxy.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/tbb_allocator.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/tick_count.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb/version.h
  -- Installing: C:/Program Files (x86)/TBB/include/oneapi/tbb.h
  -- Installing: C:/Program Files (x86)/TBB/include/tbb
  -- Installing: C:/Program Files (x86)/TBB/include/tbb/blocked_range.h
  -- Installing: C:/Program Files (x86)/TBB/include/tbb/blocked_range2d.h
  -- Installing: C:/Program Files (x86)/TBB/include/tbb/blocked_range3d.h
  -- Installing: C:/Program Files (x86)/TBB/include/tbb/blocked_rangeNd.h
  -- Installing: C:/Program Files (x86)/TBB/include/tbb/cache_aligned_allocator.h
  -- Installing: C:/Program Files (x86)/TBB/include/tbb/combinable.h
  -- Installing: C:/Program Files (x86)/TBB/include/tbb/concurrent_hash_map.h
  -- Installing: C:/Program Files (x86)/TBB/include/tbb/concurrent_lru_cache.h
  -- Installing: C:/Program Files (x86)/TBB/include/tbb/concurrent_map.h
  -- Installing: C:/Program Files (x86)/TBB/include/tbb/concurrent_priority_queue.h
  -- Installing: C:/Program Files (x86)/TBB/include/tbb/concurrent_queue.h
  -- Installing: C:/Program Files (x86)/TBB/include/tbb/concurrent_set.h
  -- Installing: C:/Program Files (x86)/TBB/include/tbb/concurrent_unordered_map.h
  -- Installing: C:/Program Files (x86)/TBB/include/tbb/concurrent_unordered_set.h
  -- Installing: C:/Program Files (x86)/TBB/include/tbb/concurrent_vector.h
  -- Installing: C:/Program Files (x86)/TBB/include/tbb/enumerable_thread_specific.h
  -- Installing: C:/Program Files (x86)/TBB/include/tbb/flow_graph.h
  -- Installing: C:/Program Files (x86)/TBB/include/tbb/flow_graph_abstractions.h
  -- Installing: C:/Program Files (x86)/TBB/include/tbb/global_control.h
  -- Installing: C:/Program Files (x86)/TBB/include/tbb/info.h
  -- Installing: C:/Program Files (x86)/TBB/include/tbb/memory_pool.h
  -- Installing: C:/Program Files (x86)/TBB/include/tbb/null_mutex.h
  -- Installing: C:/Program Files (x86)/TBB/include/tbb/null_rw_mutex.h
  -- Installing: C:/Program Files (x86)/TBB/include/tbb/parallel_for.h
  -- Installing: C:/Program Files (x86)/TBB/include/tbb/parallel_for_each.h
  -- Installing: C:/Program Files (x86)/TBB/include/tbb/parallel_invoke.h
  -- Installing: C:/Program Files (x86)/TBB/include/tbb/parallel_pipeline.h
  -- Installing: C:/Program Files (x86)/TBB/include/tbb/parallel_reduce.h
  -- Installing: C:/Program Files (x86)/TBB/include/tbb/parallel_scan.h
  -- Installing: C:/Program Files (x86)/TBB/include/tbb/parallel_sort.h
  -- Installing: C:/Program Files (x86)/TBB/include/tbb/partitioner.h
  -- Installing: C:/Program Files (x86)/TBB/include/tbb/profiling.h
  -- Installing: C:/Program Files (x86)/TBB/include/tbb/queuing_mutex.h
  -- Installing: C:/Program Files (x86)/TBB/include/tbb/queuing_rw_mutex.h
  -- Installing: C:/Program Files (x86)/TBB/include/tbb/scalable_allocator.h
  -- Installing: C:/Program Files (x86)/TBB/include/tbb/spin_mutex.h
  -- Installing: C:/Program Files (x86)/TBB/include/tbb/spin_rw_mutex.h
  -- Installing: C:/Program Files (x86)/TBB/include/tbb/task.h
  -- Installing: C:/Program Files (x86)/TBB/include/tbb/task_arena.h
  -- Installing: C:/Program Files (x86)/TBB/include/tbb/task_group.h
  -- Installing: C:/Program Files (x86)/TBB/include/tbb/task_scheduler_observer.h
  -- Installing: C:/Program Files (x86)/TBB/include/tbb/tbb.h
  -- Installing: C:/Program Files (x86)/TBB/include/tbb/tbbmalloc_proxy.h
  -- Installing: C:/Program Files (x86)/TBB/include/tbb/tbb_allocator.h
  -- Installing: C:/Program Files (x86)/TBB/include/tbb/tick_count.h
  -- Installing: C:/Program Files (x86)/TBB/include/tbb/version.h
  -- Installing: C:/Program Files (x86)/TBB/lib/cmake/TBB/TBBTargets.cmake
  -- Installing: C:/Program Files (x86)/TBB/lib/cmake/TBB/TBBTargets-release.cmake
  -- Installing: C:/Program Files (x86)/TBB/lib/cmake/TBB/TBBConfig.cmake
  -- Installing: C:/Program Files (x86)/TBB/lib/cmake/TBB/TBBConfigVersion.cmake
  -- Installing: C:/Program Files (x86)/TBB/share/doc/TBB/README.md
  CMake Error at src/tbb/cmake_install.cmake:61 (file):
    file INSTALL cannot find
    "D:/tbb/build/msvc_19.28_cxx_64_md_release/tbb12.lib": File exists.
  Call Stack (most recent call first):

Try this from the source directory instead of the existing build commands.

cmake --build build -j 4 --config Release
cmake --install build

joaander avatar Apr 27 '21 19:04 joaander

Try this from the source directory instead of the existing build commands.

cmake --build build -j 4 --config Release
cmake --install build

@joaander I tried a few variations of your suggestion but I think I am still having the same problem. I am unsure what the last lines mean. The messages <path> File exists and cannot find <path> are confusing me as to whether the library is actually there or not.

  CMake Error at src/tbb/cmake_install.cmake:61 (file):
    file INSTALL cannot find
    "D:/tbb/build/msvc_19.28_cxx_64_md_release/tbb12.lib": File exists.

bdice avatar Apr 27 '21 22:04 bdice

Yes, that message is confusing. Scroll up a little bit and you'll see:

Creating library D:/tbb/build/msvc_19.28_cxx_64_md_debug/tbb12_debug.lib and object D:/tbb/build/msvc_19.28_cxx_64_md_debug/tbb12_debug.exp

It seems that the build command is building the Debug configuration. Then when the install command tries to install the Release configuration, the file is missing. Note that MSVC projects work differently than makefiles or ninja build files. One project file includes all build configurations (Debug, Release, RelWithDebInfo, ...).

I'm going to try adding the Release configuration option to the build command and see if that helps.

joaander avatar Apr 28 '21 12:04 joaander

That worked for the TBB and freud builds.

Next error: tests are failing -

 =================================== ERRORS ====================================
  ________________________ ERROR collecting test session ________________________
  users\runneradmin\appdata\local\temp\tmpk896zw18\lib\site-packages\_pytest\runner.py:311: in from_call
      result: Optional[TResult] = func()
  users\runneradmin\appdata\local\temp\tmpk896zw18\lib\site-packages\_pytest\runner.py:341: in <lambda>
      call = CallInfo.from_call(lambda: list(collector.collect()), "collect")
  users\runneradmin\appdata\local\temp\tmpk896zw18\lib\site-packages\_pytest\main.py:690: in collect
      for direntry in visit(str(argpath), self._recurse):
  users\runneradmin\appdata\local\temp\tmpk896zw18\lib\site-packages\_pytest\pathlib.py:613: in visit
      yield from visit(entry.path, recurse)
  users\runneradmin\appdata\local\temp\tmpk896zw18\lib\site-packages\_pytest\pathlib.py:598: in visit
      for entry in os.scandir(path):
  E   PermissionError: [WinError 5] Access is denied: 'c:\\Documents and Settings'

The error isn't very clear. Maybe pytest is trying to create temporary files in a directory the VM doesn't allow writing to?

joaander avatar Apr 28 '21 12:04 joaander

Maybe pytest is trying to create temporary files in a directory the VM doesn't allow writing to?

Yes, that's my best guess as well. I've tried setting pytest's --rootdir, a new version of pytest that I thought might have addressed a related bug, and am currently testing using {project} instead of {package} for the cibuildwheel testing directory. I'm not sure what else to try. Internet searches didn't return any relevant results for the error message.

bdice avatar Apr 29 '21 16:04 bdice

Yeah it is weird. Originally I thought of trying the basetemp option: https://docs.pytest.org/en/6.2.x/tmpdir.html?highlight=tmp#the-default-base-temporary-directory - but this error seems to occur during test discovery and before it gets to any possible tmp* fixtures.

joaander avatar Apr 29 '21 17:04 joaander

This is the code in pytest that seems to be triggering a search of the C:\Documents and Settings directory: https://github.com/pytest-dev/pytest/blob/992c403fc86724a3c971486399576e60ce9791ee/src/_pytest/main.py#L695-L724

I'm not sure how to see those trace messages, but they may help offer some explanation.

You could try listing a specific file to test as an argument to pytest and see if that makes a difference. You could also try invoking with python -m pytest as that modifies the search behavior in subtle ways.

joaander avatar Apr 29 '21 17:04 joaander

Update: I am skipping pytest on Windows, and settling for making import freud succeed work with a repaired wheel first. I added a repair command using delvewheel and it now detects tbb12.dll. However it is not finding freud.dll and needs another --add-path command that indicates the path to the built freud.dll file so that it can be repaired and included.

delvewheel is still very early in its development and while I think it's possible to make freud work with delvewheel, I'm not yet fully committed to that solution for Windows wheel repairs. I'm specifically expecting that some transitive repairs between freud.dll and tbb12.dll might be needed in the delvewheel package, like what I contributed to auditwheel. scikit-learn and other popular packages with DLLs have some package-specific steps for manual inclusion and repair, as described in this blog post.

bdice avatar May 08 '21 21:05 bdice

This is still a draft, I'm just trying to update GitHub's changeset view. 😕

bdice avatar Nov 28 '21 00:11 bdice

Closing as stale.

bdice avatar Jun 28 '23 16:06 bdice