Skip to content
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

Windows Support #17

Closed
Pebaz opened this issue Jan 12, 2020 · 23 comments · May be fixed by #18
Closed

Windows Support #17

Pebaz opened this issue Jan 12, 2020 · 23 comments · May be fixed by #18

Comments

@Pebaz
Copy link

Pebaz commented Jan 12, 2020

Is there any way this library can be compiled to work on Windows?

Is it technically feasible or possible?

@Moult
Copy link

Moult commented May 13, 2020

@Pebaz and @jf--- is it possible to go one step further and from this provide a conda build for Windows? Right now fcl is on conda only for Linux and Mac.

Edit: sorry, maybe this doesn't belong in python-fcl, but rather in fcl itself? flexible-collision-library/fcl#429

@Moult
Copy link

Moult commented May 14, 2020

Actually, perhaps the best person to ping is @mmatl - based on this comment flexible-collision-library/fcl#70 (comment) and from what I've seen (please correct me if wrong), the PyPi pip install on Linux basically makes it work out of the box without needing to compile FCL or do any other magic. If this could be extended to work on Mac and Windows too... that would be amazing! How simple would this be? Can I contribute in any way?

@Moult
Copy link

Moult commented May 15, 2020

Just an update, firstly thank you very much @Pebaz for all your work on adding a Windows build script and documentation in your PR #18

I was able to build it on Windows, but the script didn't work out of the box. The build script installs eigen, libccd, octomap with no problems, but when it comes to installing fcl, at the end of the installation process at this line https://github.com/Pebaz/python-fcl/blob/master/requirements/build_win32.ps1#L91 I find that at this point in the script, it actually hasn't created C:\Program Files (x86)\fcl\{include,lib}. This means that the next step in the script, which runs setup.py fails (https://github.com/Pebaz/python-fcl/blob/master/setup.py#L28).

I worked around it by manually creating the fcl dir in Program Files and manually creating the include and lib folders based on the build artifacts and bit of guessing. After this step, it works and I can import fcl in Python 3.7!

I then ended up with an fcl directory with 4 dll files inside, a ccd.dll dynamicedt3d.dll octomap.dll and octomath.dll.

However, I then tried copying over this fcl dir onto another Windows computer to see if it would run there, but it failed with ImportError: DLL load failed: The specified module could not be found.. To debug this, I used Dependency Walker to check what DLLs loaded and which did not. Dependency Walker complained about a bunch of missing api-ms-core*.dll files but from what I read online that is due to Dependency Walker being out of date and I'm testing on the latest Windows OS. However, it did point out some missing DLLs, so I copied over vcruntime140_1.dll vcruntime140.dll and then it worked. I am not experienced in this so I don't know if this is the right approach ;)

I have uploaded my build here, if others may find it useful:

https://blenderbim.org/builds/fcl-py37-win.zip

I think it is possible to turn it into a *.whl package and submit to PyPi with just a tiny bit more work ... I am happy to help with testing and reporting my experience but I don't have experience to finish this off...

@Pebaz
Copy link
Author

Pebaz commented May 15, 2020

Hello @Moult !
I have not had time to look into this but I will soon!
I really appreciate your kind words and will hopefully have some time to debug this over the weekend. 🏝️

@Pebaz
Copy link
Author

Pebaz commented May 16, 2020

Hello again @Moult !

I believe I was able to figure out why the build script did not work for you.

I was able to reproduce the error by running the script in a normal PowerShell prompt. However, when I ran it as Administrator, the script executed just fine and I was able to install FCL successfully.

I made a few changes to the Readme as well as the build script to denote that an Administrator prompt is necessary to build successfully. Also, I identified why you had the same error when copying your build over to a new machine. In order for FCL to work, it needs access to the C runtime DLLs which you later copied over. I ran into this same issue and was able to resolve it by first installing the MSVC compiler. It's really easy on Unix platforms because they already come with libc. On Win32, you have to install MSVC to get it to work.

I went one step further and created a redistributable Wheel and upload it to PyPi as python-fcl-win32.

In order to facilitate this, I had to create a separate setup-win32.py so that when I uploaded to PyPi the project name would be unique.

Anyway, let me know if the new python-fcl-win32 wheel does not work and I will look into it further. I have tested it on a new Windows box and it worked correctly.

Have a great rest of your weekend!

Moult added a commit to IfcOpenShell/IfcOpenShell that referenced this issue May 16, 2020
Use PyPi windows build of fcl instead. BerkeleyAutomation/python-fcl#17
@Moult
Copy link

Moult commented May 16, 2020

@Pebaz I checked and I did run PowerShell as administator - after all, it did create eigen, libccd, octomap artifacts in C:\Program Files (x86)... just not for fcl for some reason.

I tested your wheel and it works great! Thank you again!

Thanks for going the extra step and uploading to PyPi! I am now using your PyPi distribution for the software I'm building! For anyone interested, I'm building https://blenderbim.org/ the BlenderBIM Add-on, an add-on to Blender which provides BIM capabilities for architects, engineers, and those in the construction industry. The fcl library lets people perform collision / clash detection when coordinating building models :) Your work has been invaluable!

The only steps left are Mac support (I don't know how simple this is, perhaps it just needs a Mac environment and that's it...) and for everybody to start cleaning the fork of the fork of the fork of the fork of this library and pull all the improvements together :)

@Moult
Copy link

Moult commented Mar 6, 2021

@Pebaz sorry to bother, but do you think by any chance you could help release a version for Python 3.9 to PyPi? If you're busy, I'm also happy to learn how to do this myself and contribute a build with your guidance :) The reason I ask is that Blender is moving to Python 3.9, and I am building a tool that integrates fcl with Blender.

@Pebaz
Copy link
Author

Pebaz commented Mar 11, 2021

Hello @Moult ! I will look into this!

@Pebaz
Copy link
Author

Pebaz commented Mar 11, 2021

I was successfully able to install python-fcl-win32 using Python 3.9 on Windows without uploading a new package.

Have you experienced any issues installing on Python 3.9?

@ConorMesser
Copy link

I am running into an error when trying to use the python-fcl-win32 build using Python 3.6. I get a ModuleNotFoundError on trying to import the fcl package.

image

Can anyone help me with this issue? The package works fine when I run my package in Linux, but I am trying to add Windows compatability.

@Pebaz
Copy link
Author

Pebaz commented Apr 22, 2021

@ConorMesser

This could be occurring due to your local installation of Python being compiled with a different compiler than python-fcl-win32. The pre-built binaries distributed in python-fcl-win32 are compiled with MSVC. In order to use them, Python must also be compiled with MSVC.

You can determine this by doing:

>>> import sys
>>> sys.version
3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)]
                                                  ^
                                                  |
                                          MSC == MSVC, not sure why they left out the V

If you need to use MingW or something else on Windows other than MSVC, you will have to clone this repo and follow the build instructions carefully listed here.

One other thing that could be the issue is that the python-fcl-win32 pre-built binaries are 64-bit, so if you're using a 32-bit version of Python it will simply ignore them, which could also result in the "missing module" error message.

@ConorMesser
Copy link

Sorry for getting back to this late. I confirmed that I am running MSVC and a 64-bit version of Python, so not sure why the pre-built binaries in python-fcl-win32 aren't working for me.

I also tried installing the library from source (following your build instructions) and got the same error at the end of it. I don't know what else to try.

@Pebaz
Copy link
Author

Pebaz commented May 6, 2021

Can you confirm that the site-packages folder in the virtual environment contains a PYD file for FCL? If there is no PYD file in that directory, there might be something in the build or installation process that is silently failing.

I know it's a bit hacky, but can you confirm that you are running the build script in an Admin PowerShell prompt when compiling from sources? Also, try running the setup-win32.py script directly (after commenting out the build script lines at the bottom that delete the FCL dependency libs in C:/Program Files) and it should find the necessary dependencies and install locally.

It may be worth trying to install the prebuilt binaries onto your system Python rather than in a virtual environment just to rule out any virtual environment related issues.

I'll try to help as best I can, let me know if any of these things work! :)

@ConorMesser
Copy link

I can confirm there is a PYD file for FCL in the virtual environment: fcl.cp37-win_amd64.pyd is the file. Here is the contents of the fcl directory in the virutal environment:
d----- 5/8/2021 11:48 AM __pycache__ -a---- 5/8/2021 11:47 AM 36864 ccd.dll -a---- 5/8/2021 11:47 AM 3851 collision_data.py -a---- 5/8/2021 11:47 AM 9216 dynamicedt3d.dll -a---- 5/8/2021 11:47 AM 3705856 fcl.cp37-win_amd64.pyd -a---- 5/8/2021 11:47 AM 29656 fcl.pyx -a---- 5/8/2021 11:47 AM 15841 fcl_defs.pxd -a---- 5/8/2021 11:47 AM 103936 octomap.dll -a---- 5/8/2021 11:47 AM 849 octomap_defs.pxd -a---- 5/8/2021 11:47 AM 9728 octomath.dll -a---- 5/8/2021 11:47 AM 280 std_defs.pxd -a---- 5/8/2021 11:47 AM 24 version.py -a---- 5/8/2021 11:47 AM 590 __init__.py

Tried installing the pre-built binaries on my system Python. Still same error. I am importing fcl in my script correctly, right? I just have import fcl or import fcl.collision_data as fcd and run the script from the command line with python test_fcl.py which results in the error.

Trying to run the setup-win32.py directly (after commenting out the lib deletion, and running in Admin PowerShell) results in this error:
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.28.29910\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2

@Pebaz
Copy link
Author

Pebaz commented May 12, 2021

@ConorMesser I'm going to try to look into this more closely today if I have time. Since MSVC is failing, I'd say there's probably some sort of misconfiguration in there somewhere. While I try to reproduce the error locally, can you provide these details so it can help me reason about the problem (sorry if they've already been provided!):

  • Python Version
  • Python Architecture
  • C Compiler Used To Compile Python
  • System Version
  • System Architecture
  • C Compiler Installed On System (and used by Python when installing)
  • C Compiler Version
  • CMake Version

I'll try my best to figure out what's wrong here. While I'm doing that, can you try to update your MSVC installation to use the MS Build Tools or whatever is the latest (compatible) thing? I've got a slightly outdated MS Build Tools and it's working but there could be an issue there so wanted to make sure those were up to date.

@Pebaz
Copy link
Author

Pebaz commented May 12, 2021

If possible, can you also post the entire (scrubbed) output from the requirements/build_win32.ps1 script?
Additionally the output from setup-win32.py assuming python setup-win32.py install?

@Pebaz
Copy link
Author

Pebaz commented May 12, 2021

@ConorMesser I've given it a go, and I just can't seem to figure out why the compilation would fail.

Just one more thing, are you doing these sequences of actions?

  1. Running build_win32.ps1 to build necessary dependencies in admin PowerShell
  2. Running python setup-win32.py install directly after

@CyrilWaechter
Copy link

CyrilWaechter commented Jul 27, 2021

@Pebaz Thanks a lot. Your work gave me some hints on windows. I reworked your script and combined it with pull request for 0.6.1.
See:

For some reason fcl is correctly compiled locally on windows but not on ci (github actions).

@sethzhao506
Copy link

sethzhao506 commented Aug 26, 2021

Hi, I met the same issue as @ConorMesser, do we have any solutions for this yet @Pebaz?

Error message:

import fcl
Traceback (most recent call last):
File "", line 1, in
File "D:\Anaconda\lib\site-packages\fcl_init_.py", line 1, in
from .fcl import CollisionObject, CollisionGeometry, Transform, TriangleP, Box, Sphere, Ellipsoid, Capsule, Cone, Cylinder, Halfspace, Plane, BVHModel, OcTree, DynamicAABBTreeCollisionManager, collide, continuousCollide, distance, defaultCollisionCallback, defaultDistanceCallback
ModuleNotFoundError: No module named 'fcl.fcl'
import sys
sys.version
'3.8.3 (default, Jul 2 2020, 17:30:36) [MSC v.1916 64 bit (AMD64)]'

@CyrilWaechter
Copy link

@sethzhao506 It probably means that python-fcl is not correctly compiled on your system. You might like to use precompiled version from https://github.com/CyrilWaechter/python-fcl/releases/tag/v0.6.1

@sethzhao506
Copy link

@sethzhao506 It probably means that python-fcl is not correctly compiled on your system. You might like to use precompiled version from https://github.com/CyrilWaechter/python-fcl/releases/tag/v0.6.1

Thank you so much! For anyone who might encounter, I download the wheel file and pip install the wheel file according to specific version of python.

@PrincessSaladin
Copy link

@sethzhao506 It probably means that python-fcl is not correctly compiled on your system. You might like to use precompiled version from https://github.com/CyrilWaechter/python-fcl/releases/tag/v0.6.1
Thank you so much!(I installed the vision of python3.8, and it is working well) I also found the download links in PyPi:
https://pypi.org/project/python-fcl/0.6.1/#files

@mjd3
Copy link

mjd3 commented Jul 1, 2022

This should be addressed by #29; thanks everyone for your hard work on that!

@mjd3 mjd3 closed this as completed Jul 1, 2022
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 a pull request may close this issue.

7 participants