aleaxit / gmpy

General Multi-Precision arithmetic for Python 2.6+/3+ (GMP, MPIR, MPFR, MPC)
https://gmpy2.readthedocs.io/en/latest/
GNU Lesser General Public License v3.0
519 stars 86 forks source link

gmpy2 failed to install in Python 3.11 #349

Closed reza-ghazi closed 1 year ago

reza-ghazi commented 1 year ago

Usually, gmpy2 installs in different versions of Python as a charm, but this time has problem if I want to install it in Python 3.11. I know you didn't mention this version in pypi.org, but please check the following, and maybe you can fix that.

Thank you,

This is the installation process in Ubuntu 22.04:

itpro@Black-Panther:~$ pip install gmpy2
Defaulting to user installation because normal site-packages is not writeable
Collecting gmpy2
  Downloading gmpy2-2.1.2.tar.gz (258 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 258.4/258.4 KB 6.0 MB/s eta 0:00:00
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: gmpy2
  Building wheel for gmpy2 (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [29 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-3.11
      creating build/lib.linux-x86_64-3.11/gmpy2
      copying gmpy2/__init__.py -> build/lib.linux-x86_64-3.11/gmpy2
      running egg_info
      writing gmpy2.egg-info/PKG-INFO
      writing dependency_links to gmpy2.egg-info/dependency_links.txt
      writing top-level names to gmpy2.egg-info/top_level.txt
      reading manifest file 'gmpy2.egg-info/SOURCES.txt'
      reading manifest template 'MANIFEST.in'
      adding license file 'COPYING'
      adding license file 'COPYING.LESSER'
      writing manifest file 'gmpy2.egg-info/SOURCES.txt'
      copying gmpy2/__init__.pxd -> build/lib.linux-x86_64-3.11/gmpy2
      copying gmpy2/gmpy2.h -> build/lib.linux-x86_64-3.11/gmpy2
      copying gmpy2/gmpy2.pxd -> build/lib.linux-x86_64-3.11/gmpy2
      running build_ext
      building 'gmpy2.gmpy2' extension
      creating build/temp.linux-x86_64-3.11
      creating build/temp.linux-x86_64-3.11/src
      x86_64-linux-gnu-gcc -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I./src -I/usr/include/python3.11 -I/usr/local/include/python3.11 -c src/gmpy2.c -o build/temp.linux-x86_64-3.11/src/gmpy2.o -DSHARED=1
      src/gmpy2.c:479:10: fatal error: Python.h: No such file or directory
        479 | #include "Python.h"
            |          ^~~~~~~~~~
      compilation terminated.
      error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for gmpy2
  Running setup.py clean for gmpy2
Failed to build gmpy2
Installing collected packages: gmpy2
  Running setup.py install for gmpy2 ... error
  error: subprocess-exited-with-error

  × Running setup.py install for gmpy2 did not run successfully.
  │ exit code: 1
  ╰─> [31 lines of output]
      running install
      /usr/lib/python3/dist-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
        warnings.warn(
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-3.11
      creating build/lib.linux-x86_64-3.11/gmpy2
      copying gmpy2/__init__.py -> build/lib.linux-x86_64-3.11/gmpy2
      running egg_info
      writing gmpy2.egg-info/PKG-INFO
      writing dependency_links to gmpy2.egg-info/dependency_links.txt
      writing top-level names to gmpy2.egg-info/top_level.txt
      reading manifest file 'gmpy2.egg-info/SOURCES.txt'
      reading manifest template 'MANIFEST.in'
      adding license file 'COPYING'
      adding license file 'COPYING.LESSER'
      writing manifest file 'gmpy2.egg-info/SOURCES.txt'
      copying gmpy2/__init__.pxd -> build/lib.linux-x86_64-3.11/gmpy2
      copying gmpy2/gmpy2.h -> build/lib.linux-x86_64-3.11/gmpy2
      copying gmpy2/gmpy2.pxd -> build/lib.linux-x86_64-3.11/gmpy2
      running build_ext
      building 'gmpy2.gmpy2' extension
      creating build/temp.linux-x86_64-3.11
      creating build/temp.linux-x86_64-3.11/src
      x86_64-linux-gnu-gcc -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I./src -I/usr/include/python3.11 -I/usr/local/include/python3.11 -c src/gmpy2.c -o build/temp.linux-x86_64-3.11/src/gmpy2.o -DSHARED=1
      src/gmpy2.c:479:10: fatal error: Python.h: No such file or directory
        479 | #include "Python.h"
            |          ^~~~~~~~~~
      compilation terminated.
      error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> gmpy2

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.

And here is the installation process in Windows 10

PS C:\Users\itpro> pip install gmpy2
Collecting gmpy2
  Using cached gmpy2-2.1.2.tar.gz (258 kB)
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: gmpy2
  Building wheel for gmpy2 (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [28 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build\lib.win-amd64-cpython-311
      creating build\lib.win-amd64-cpython-311\gmpy2
      copying gmpy2\__init__.py -> build\lib.win-amd64-cpython-311\gmpy2
      running egg_info
      writing gmpy2.egg-info\PKG-INFO
      writing dependency_links to gmpy2.egg-info\dependency_links.txt
      writing top-level names to gmpy2.egg-info\top_level.txt
      reading manifest file 'gmpy2.egg-info\SOURCES.txt'
      reading manifest template 'MANIFEST.in'
      adding license file 'COPYING'
      adding license file 'COPYING.LESSER'
      writing manifest file 'gmpy2.egg-info\SOURCES.txt'
      copying gmpy2\__init__.pxd -> build\lib.win-amd64-cpython-311\gmpy2
      copying gmpy2\gmpy2.h -> build\lib.win-amd64-cpython-311\gmpy2
      copying gmpy2\gmpy2.pxd -> build\lib.win-amd64-cpython-311\gmpy2
      running build_ext
      building 'gmpy2.gmpy2' 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
      D:\VS2022\Community\VC\Tools\MSVC\14.33.31629\bin\HostX86\x64\cl.exe /c /nologo /O2 /W3 /GL /DNDEBUG /MD -I./src -IC:\Users\itpro\AppData\Local\Programs\Python\Python311\include -IC:\Users\itpro\AppData\Local\Programs\Python\Python311\Include -ID:\VS2022\Community\VC\Tools\MSVC\14.33.31629\include -ID:\VS2022\Community\VC\Tools\MSVC\14.33.31629\ATLMFC\include -ID:\VS2022\Community\VC\Auxiliary\VS\include "-ID:\Windows Kits\10\include\10.0.22621.0\ucrt" "-ID:\Windows Kits\10\\include\10.0.22621.0\\um" "-ID:\Windows Kits\10\\include\10.0.22621.0\\shared" "-ID:\Windows Kits\10\\include\10.0.22621.0\\winrt" "-ID:\Windows Kits\10\\include\10.0.22621.0\\cppwinrt" /Tcsrc/gmpy2.c /Fobuild\temp.win-amd64-cpython-311\Release\src/gmpy2.obj /DSHARED=1
      gmpy2.c
      C:\Users\itpro\AppData\Local\Temp\pip-install-q1dvbzeh\gmpy2_79f2824f13fb46d99e08d8d2d925f3a5\src\gmpy2.h(79): fatal error C1083: Cannot open include file: 'gmp.h': No such file or directory
      error: command 'D:\\VS2022\\Community\\VC\\Tools\\MSVC\\14.33.31629\\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 gmpy2
  Running setup.py clean for gmpy2
Failed to build gmpy2
Installing collected packages: gmpy2
  Running setup.py install for gmpy2 ... error
  error: subprocess-exited-with-error

  × Running setup.py install for gmpy2 did not run successfully.
  │ exit code: 1
  ╰─> [30 lines of output]
      running install
      C:\Users\itpro\AppData\Local\Programs\Python\Python311\Lib\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
        warnings.warn(
      running build
      running build_py
      creating build
      creating build\lib.win-amd64-cpython-311
      creating build\lib.win-amd64-cpython-311\gmpy2
      copying gmpy2\__init__.py -> build\lib.win-amd64-cpython-311\gmpy2
      running egg_info
      writing gmpy2.egg-info\PKG-INFO
      writing dependency_links to gmpy2.egg-info\dependency_links.txt
      writing top-level names to gmpy2.egg-info\top_level.txt
      reading manifest file 'gmpy2.egg-info\SOURCES.txt'
      reading manifest template 'MANIFEST.in'
      adding license file 'COPYING'
      adding license file 'COPYING.LESSER'
      writing manifest file 'gmpy2.egg-info\SOURCES.txt'
      copying gmpy2\__init__.pxd -> build\lib.win-amd64-cpython-311\gmpy2
      copying gmpy2\gmpy2.h -> build\lib.win-amd64-cpython-311\gmpy2
      copying gmpy2\gmpy2.pxd -> build\lib.win-amd64-cpython-311\gmpy2
      running build_ext
      building 'gmpy2.gmpy2' 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
      D:\VS2022\Community\VC\Tools\MSVC\14.33.31629\bin\HostX86\x64\cl.exe /c /nologo /O2 /W3 /GL /DNDEBUG /MD -I./src -IC:\Users\itpro\AppData\Local\Programs\Python\Python311\include -IC:\Users\itpro\AppData\Local\Programs\Python\Python311\Include -ID:\VS2022\Community\VC\Tools\MSVC\14.33.31629\include -ID:\VS2022\Community\VC\Tools\MSVC\14.33.31629\ATLMFC\include -ID:\VS2022\Community\VC\Auxiliary\VS\include "-ID:\Windows Kits\10\include\10.0.22621.0\ucrt" "-ID:\Windows Kits\10\\include\10.0.22621.0\\um" "-ID:\Windows Kits\10\\include\10.0.22621.0\\shared" "-ID:\Windows Kits\10\\include\10.0.22621.0\\winrt" "-ID:\Windows Kits\10\\include\10.0.22621.0\\cppwinrt" /Tcsrc/gmpy2.c /Fobuild\temp.win-amd64-cpython-311\Release\src/gmpy2.obj /DSHARED=1
      gmpy2.c
      C:\Users\itpro\AppData\Local\Temp\pip-install-q1dvbzeh\gmpy2_79f2824f13fb46d99e08d8d2d925f3a5\src\gmpy2.h(79): fatal error C1083: Cannot open include file: 'gmp.h': No such file or directory
      error: command 'D:\\VS2022\\Community\\VC\\Tools\\MSVC\\14.33.31629\\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: legacy-install-failure

× Encountered error while trying to install package.
╰─> gmpy2

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
casevh commented 1 year ago

I am preparing a final release of gmpy2 2.1.3 which will provide binary wheels for Linux, MacOS, and Windows.

reza-ghazi commented 1 year ago

That's good if it can support python 3.11. I am waiting to see your result.

skirpichev commented 1 year ago

@casevh, 2.1.3 has binary wheels only for Windows on the CPython 3.11.

casevh commented 1 year ago

@skirpichev Argh! Let's see if I can get those built and added to the existing release files.

casevh commented 1 year ago

@skirpichev What's the trick to creating 3.11 builds?

skirpichev commented 1 year ago

@casevh, probably that's because you froze cibuildwheel deps. 3.11 wheels built by default since v2.9.0.

reza-ghazi commented 1 year ago

@cavesh, Thank you for the suggestion. I installed cibuildwheel, and after that, I could install gmpy2 without any problem. So, the issue has been solved.

Thank you again.