hannorein / rebound

💫 An open-source multi-purpose N-body code.
https://rebound.readthedocs.io/
GNU General Public License v3.0
820 stars 217 forks source link

D8021 : invalid numeric argument '/Wno-unknown-pragmas' in Windows VS-Code #692

Closed DarkSky7 closed 1 year ago

DarkSky7 commented 1 year ago

I found webpages explaining that this build/install error (via 'pip install rebound') is thrown when GCC doesn't recognize a pragma, but (as you'll see in the partial build transcript below), the VisualStudio compiler is being used. Maybe it needs a cmake tweak - what's your recommendation? Thanks, Mike

"C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -DLIBREBOUND -Isrc -IC:\Programs\Python311\include -IC:\Programs\Python311\Include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\cppwinrt" /Tcsrc/binarydiff.c /Fobuild\temp.win-amd64-cpython-311\Release\src/binarydiff.obj -fstrict-aliasing -O3 -std=c99 -Wno-unknown-pragmas -DGITHASH=8cfdd5ec370452803a6fc5cbf3176adca8bcfa82 -DLIBREBOUND -D_GNU_SOURCE -fPIC cl : Command line error D8021 : invalid numeric argument '/Wno-unknown-pragmas' error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\bin\HostX86\x64\cl.exe' failed with exit code 2

hannorein commented 1 year ago

It looks like you're trying to use REBOUND on Windows. Have you read the note about windows here: https://rebound.readthedocs.io/en/latest/quickstart_installation/ ?

DarkSky7 commented 1 year ago

Yes, I did. Perhaps there's something wrong with how my environment is set up?

In addition to the error described in Issue #692 (attempting to 'pip install rebound'), when I try to build librebound.so, I get:

C:/Programs(x86)/GnuWin32/bin/make -C src /usr/bin/sh: -c: line 0: syntax error near unexpected token x86' /usr/bin/sh: -c: line 0:C:/Programs(x86)/GnuWin32/bin/make -C src ' make: *** [librebound] Error 1

That's kind of strange because the top-level Makefile doesn't mention 'x86'. I apologize for my ineptitude, I've been away from software development for a couple of decades and consequently a little rusty, especially on a Windows platform. Any suggestions would be greatly appreciated.

Thanks, Mike

On Wed, Jun 7, 2023 at 4:59 AM Hanno Rein @.***> wrote:

It looks like you're trying to use REBOUND on Windows. Have you read the note about windows here: https://rebound.readthedocs.io/en/latest/quickstart_installation/ ?

— Reply to this email directly, view it on GitHub https://github.com/hannorein/rebound/issues/692#issuecomment-1580663546, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARPYOQWY5LK4BILAK2X4I5DXKBUK5ANCNFSM6AAAAAAY5DNN7Q . You are receiving this because you authored the thread.Message ID: @.***>

hannorein commented 1 year ago

I'm not very familiar with windows, but it looks to me as if you're not using the Windows Subsystem for Linux (WSL).

DarkSky7 commented 1 year ago

Thanks for the suggestion - I verified that WSL (Debian in my case) is installed and up to date, but apparently that wasn't the problem; I still stuck as you can see below...

The make triggered by 'pip install rebound' - bombs like this: $ pip install rebound Collecting rebound Using cached rebound-3.24.3.tar.gz (295 kB) Installing build dependencies ... done Getting requirements to build wheel ... done Installing backend dependencies ... done Preparing metadata (pyproject.toml) ... done Building wheels for collected packages: rebound Building wheel for rebound (pyproject.toml) ... error error: subprocess-exited-with-error

× Building wheel for rebound (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [28 lines of output] fatal: not a git repository (or any of the parent directories): .git running bdist_wheel running build running build_py creating build creating build\lib.win-amd64-cpython-311 creating build\lib.win-amd64-cpython-311\rebound copying rebound\citations.py -> build\lib.win-amd64-cpython-311\rebound copying rebound\data.py -> build\lib.win-amd64-cpython-311\rebound copying rebound\horizons.py -> build\lib.win-amd64-cpython-311\rebound copying rebound\interruptible_pool.py -> build\lib.win-amd64-cpython-311\rebound copying rebound\particle.py -> build\lib.win-amd64-cpython-311\rebound copying rebound\plotting.py -> build\lib.win-amd64-cpython-311\rebound copying rebound\simulation.py -> build\lib.win-amd64-cpython-311\rebound copying rebound\simulationarchive.py -> build\lib.win-amd64-cpython-311\rebound copying rebound\tools.py -> build\lib.win-amd64-cpython-311\rebound copying rebound\units.py -> build\lib.win-amd64-cpython-311\rebound copying rebound\widget.py -> build\lib.win-amd64-cpython-311\rebound copying rebound__init__.py -> build\lib.win-amd64-cpython-311\rebound copying rebound\rebound.h -> build\lib.win-amd64-cpython-311\rebound running build_ext building 'librebound' extension creating build\temp.win-amd64-cpython-311 creating build\temp.win-amd64-cpython-311\Release creating build\temp.win-amd64-cpython-311\Release\src "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -DLIBREBOUND -Isrc -IC:\Programs\Python311\include -IC:\Programs\Python311\Include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\cppwinrt" /Tcsrc/binarydiff.c /Fobuild\temp.win-amd64-cpython-311\Release\src/binarydiff.obj -fstrict-aliasing -O3 -std=c99 -Wno-unknown-pragmas -DGITHASH=8cfdd5ec370452803a6fc5cbf3176adca8bcfa82 -DLIBREBOUND -D_GNU_SOURCE -fPIC cl : Command line error D8021 : invalid numeric argument '/Wno-unknown-pragmas' error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\bin\HostX86\x64\cl.exe' failed with exit code 2 [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for rebound Failed to build rebound ERROR: Could not build wheels for rebound, which is required to install pyproject.toml-based projects

The make of librebound.so bombs like this: C:/Programs(x86)/GnuWin32/bin/make -C src fatal: not a git repository (or any of the parent directories): .git make[1]: Entering directory `C:/Programs/rebound/src' "Compiling source file rebound.c ..." cc -c -std=c99 -Wpointer-arith -D_GNU_SOURCE -O3 -Wno-unknown-pragmas -fPIC -DLIBREBOUND -DGITHASH='0000000000gitnotfound0000000000000000000' -o rebound.o rebound.c process_begin: CreateProcess(NULL, cc -c -std=c99 -Wpointer-arith -D_GNU_SOURCE -O3 -Wno-unknown-pragmas -fPIC -DLIBREBOUND -DGITHASH=0000000000gitnotfound0000000000000000000 -o rebound.o rebound.c, ...) failed. make (e=2): The system cannot find the file specified. make[1]: *** [rebound.o] Error 2

On Wed, Jun 7, 2023 at 8:15 AM Hanno Rein @.***> wrote:

I'm not very familiar with windows, but it looks to me as if you're not using the Windows Subsystem for Linux (WSL).

— Reply to this email directly, view it on GitHub https://github.com/hannorein/rebound/issues/692#issuecomment-1581038678, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARPYOQRM5TUKCK2AROQO2GLXKCLKRANCNFSM6AAAAAAY5DNN7Q . You are receiving this because you authored the thread.Message ID: @.***>

hannorein commented 1 year ago

I'm afraid I have no experience with Windows. But judging by the error messages and the paths that appear therein (C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.3013...) it doesn't look like you're using WSL. These paths do not exist in a unix-like environment.

DarkSky7 commented 1 year ago

1) So, with WSL2 installed, running: $ CC=gcc;/mnt/c/Programs/Python311/python.exe -m pip install rebound, I get the exact same result - cl.exe still does the compiling, and (naturally) it still doesn't like /Wno-unknown-pragmas. I then edited rebound's setup.py to eliminate that compiler flag (just in case), but cl.exe STILL gets selected as the compiler AND the setup.py that runs STILL chokes on the /Wno-unknown-pragmas flag, thereby indicating that some other setup.py is doing the build for pip install.

2) Despite the cl.exe compiler burping on the no-unknown-pragmas flag, I still get a librebound.so in the src directory AND a symbolic link to it in /c/Programs/rebound, BUT 'pip show rebound' doesn't think 'pip install rebound' succeeded. Does anyone know how I can manually fake it out?

3) There are 73 #pragmas in the rebound source. Does anyone know which ones would not be supported by cl.exe? If I had to bet from a state of contextual ignorance, I'd put money on '#pragma omp parallel' (there are 46 of those) and/or '#pragma GCC ivdep' (there are 25 of those).

I think there are two possible paths to a successful Windows build: 1) finding out how to get gcc to do the compile/build (lots of carnage on the roadside attempting that); or 2) figuring out which setup.py is ACTUALLY running the build (so it can be edited to remove the no-unknown-pragmas flag), 'cause the one in the rebound directory is definitely NOT running things.

hannorein commented 1 year ago

I don’t have access to a windows machine. But it looks to me as if you’re running the windows version of python. I found this link on how to setup the WSL version of python. https://learn.microsoft.com/en-us/windows/python/web-frameworks

hannorein commented 1 year ago

FWIW: The pragmas are probably not the real issue. Once you fix them, you’ll get other errors about missing system calls.

DarkSky7 commented 1 year ago

Python 3.9 was installed here before WSL2 - apparently, WSL finds PYTHONHOME and associated stuff are present and recognizes that Python is already installed and up to date, so WSL's Python IS Wndows' Python. If you think of something, I'll try it. Figuring out which setup.py is really doing the build might help - rebound's setup.py is not the one doing the work.

On Sun, Jun 11, 2023 at 4:51 AM Hanno Rein @.***> wrote:

I don’t have access to a windows machine. But it looks to me as if you’re running the windows version of python. I found this link on how to setup the WSL version of python. https://learn.microsoft.com/en-us/windows/python/web-frameworks

— Reply to this email directly, view it on GitHub https://github.com/hannorein/rebound/issues/692#issuecomment-1586133357, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARPYOQULLI2KMOV777VVTSTXKWWLFANCNFSM6AAAAAAY5DNN7Q . You are receiving this because you authored the thread.Message ID: @.***>

hannorein commented 1 year ago

I don't think you're right here. The issue is not the setup.py file - it's that you're using the windows version of python to try to compile a linux version of REBOUND. This will not work. You need to install python in WSL.

DarkSky7 commented 1 year ago

You're right. WSL doesn't know $PYTHONHOME. After disabling VPN (Debian won't install through a VPN proxy), ...

sudo apt install python3 python3-pip ipython3 /usr/bin/python3.9 -m pip install rebound got me rebound with no complaints.

Sorry for the trouble. I hope we're not claiming that rebound supports windows - WSL is really a linux machine. I'll have to see if I can get VS-code (which I really like) to use the WSL version of python3.9

On Sun, Jun 11, 2023 at 7:06 AM Hanno Rein @.***> wrote:

I don't think you're right here. The issue is not the setup.py file - it's that you're using the windows version of python to try to compile a linux version of REBOUND. This will not work. You need to install python in WSL.

— Reply to this email directly, view it on GitHub https://github.com/hannorein/rebound/issues/692#issuecomment-1586178997, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARPYOQWI2CPPXAKCRCAZSUDXKXGEXANCNFSM6AAAAAAY5DNN7Q . You are receiving this because you authored the thread.Message ID: @.***>

hannorein commented 1 year ago

Glad it worked in the end. I'll close this issue now.