ibarrond / Pyfhel

PYthon For Homomorphic Encryption Libraries, perform encrypted computations such as sum, mult, scalar product or matrix multiplication in Python, with NumPy compatibility. Uses SEAL/PALISADE as backends, implemented using Cython.
https://pyfhel.readthedocs.io/
Apache License 2.0
486 stars 78 forks source link

Building wheel for Pyfhel failed (installation error) #157

Closed Bogdanzz96 closed 1 year ago

Bogdanzz96 commented 1 year ago

Description I get an error when trying to install Pyfhel 3.3.1.

Code To Reproduce Error

PS C:\> pip install -v pyfhel
Using pip 22.3.1 from c:\users\bogda\appdata\local\programs\python\python37\lib\site-packages\pip (python 3.7)
Collecting pyfhel
  Using cached Pyfhel-3.3.1.tar.gz (48.6 MB)
  Running command pip subprocess to install build dependencies
  Collecting setuptools<=60.9
    Using cached setuptools-60.9.0-py3-none-any.whl (1.1 MB)
  Collecting wheel
    Using cached wheel-0.38.4-py3-none-any.whl (36 kB)
  Collecting cython==3.0.0a10
    Using cached Cython-3.0.0a10-py2.py3-none-any.whl (1.1 MB)
  Collecting numpy==1.21
    Using cached numpy-1.21.0-cp37-cp37m-win_amd64.whl (13.9 MB)
  Collecting cmake>=3.15
    Using cached cmake-3.24.3-py2.py3-none-win_amd64.whl (31.5 MB)
  Collecting toml>=0.10
    Using cached toml-0.10.2-py2.py3-none-any.whl (16 kB)
  Installing collected packages: cmake, wheel, toml, setuptools, numpy, cython
  Successfully installed cmake-3.24.3 cython-3.0.0a10 numpy-1.21.0 setuptools-60.9.0 toml-0.10.2 wheel-0.38.4
  Installing build dependencies ... done
  Running command Getting requirements to build wheel
  Compiling Pyfhel/Pyfhel.pyx because it depends on C:\Users\bogda\AppData\Local\Temp\pip-build-env-hri2nal2\overlay\Lib\site-packages\Cython\Includes\libcpp\vector.pxd.
  Compiling Pyfhel/PyCtxt.pyx because it depends on C:\Users\bogda\AppData\Local\Temp\pip-build-env-hri2nal2\overlay\Lib\site-packages\Cython\Includes\libcpp\vector.pxd.
  Compiling Pyfhel/PyPtxt.pyx because it depends on C:\Users\bogda\AppData\Local\Temp\pip-build-env-hri2nal2\overlay\Lib\site-packages\Cython\Includes\libcpp\vector.pxd.
  Compiling Pyfhel/PyPoly.pyx because it depends on C:\Users\bogda\AppData\Local\Temp\pip-build-env-hri2nal2\overlay\Lib\site-packages\Cython\Includes\libcpp\vector.pxd.
  [1/4] Cythonizing Pyfhel/PyCtxt.pyx
  [2/4] Cythonizing Pyfhel/PyPoly.pyx
  [3/4] Cythonizing Pyfhel/PyPtxt.pyx
  [4/4] Cythonizing Pyfhel/Pyfhel.pyx
  running egg_info
  writing Pyfhel.egg-info\PKG-INFO
  writing dependency_links to Pyfhel.egg-info\dependency_links.txt
  writing requirements to Pyfhel.egg-info\requires.txt
  writing top-level names to Pyfhel.egg-info\top_level.txt
  cimporting numpy version '1.21.0'
  reading manifest file 'Pyfhel.egg-info\SOURCES.txt'
  reading manifest template 'MANIFEST.in'
  adding license file 'LICENSE.txt'
  Getting requirements to build wheel ... done
  Running command Preparing metadata (pyproject.toml)
  running dist_info
  writing C:\Users\bogda\AppData\Local\Temp\pip-modern-metadata-oy6hn0rb\Pyfhel.egg-info\PKG-INFO
  writing dependency_links to C:\Users\bogda\AppData\Local\Temp\pip-modern-metadata-oy6hn0rb\Pyfhel.egg-info\dependency_links.txt
  writing requirements to C:\Users\bogda\AppData\Local\Temp\pip-modern-metadata-oy6hn0rb\Pyfhel.egg-info\requires.txt
  writing top-level names to C:\Users\bogda\AppData\Local\Temp\pip-modern-metadata-oy6hn0rb\Pyfhel.egg-info\top_level.txt
  cimporting numpy version '1.21.0'
  reading manifest file 'C:\Users\bogda\AppData\Local\Temp\pip-modern-metadata-oy6hn0rb\Pyfhel.egg-info\SOURCES.txt'
  reading manifest template 'MANIFEST.in'
  warning: no previously-included files matching 'Pyfhel\backend\palisade\**' found anywhere in distribution
  adding license file 'LICENSE.txt'
  creating 'C:\Users\bogda\AppData\Local\Temp\pip-modern-metadata-oy6hn0rb\Pyfhel.dist-info'
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: numpy==1.21 in c:\users\bogda\appdata\local\programs\python\python37\lib\site-packages (from pyfhel) (1.21.0)
Building wheels for collected packages: pyfhel
  Running command Building wheel for pyfhel (pyproject.toml)
  running bdist_wheel
  running build
  running build_py
  running build_clib
  building 'SEAL' cmake-based library
  Traceback (most recent call last):
    File "c:\users\bogda\appdata\local\programs\python\python37\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 351, in <module>
      main()
    File "c:\users\bogda\appdata\local\programs\python\python37\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 333, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "c:\users\bogda\appdata\local\programs\python\python37\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 250, in build_wheel
      metadata_directory)
    File "C:\Users\bogda\AppData\Local\Temp\pip-build-env-hri2nal2\overlay\Lib\site-packages\setuptools\build_meta.py", line 245, in build_wheel
      wheel_directory, config_settings)
    File "C:\Users\bogda\AppData\Local\Temp\pip-build-env-hri2nal2\overlay\Lib\site-packages\setuptools\build_meta.py", line 229, in _build_with_temp_dir
      self.run_setup()
    File "C:\Users\bogda\AppData\Local\Temp\pip-build-env-hri2nal2\overlay\Lib\site-packages\setuptools\build_meta.py", line 174, in run_setup
      exec(compile(code, __file__, 'exec'), locals())
    File "setup.py", line 689, in <module>
      'build_clib' : SuperBuildClib},
    File "C:\Users\bogda\AppData\Local\Temp\pip-build-env-hri2nal2\overlay\Lib\site-packages\setuptools\__init__.py", line 155, in setup
      return distutils.core.setup(**attrs)
    File "C:\Users\bogda\AppData\Local\Temp\pip-build-env-hri2nal2\overlay\Lib\site-packages\setuptools\_distutils\core.py", line 148, in setup
      return run_commands(dist)
    File "C:\Users\bogda\AppData\Local\Temp\pip-build-env-hri2nal2\overlay\Lib\site-packages\setuptools\_distutils\core.py", line 163, in run_commands
      dist.run_commands()
    File "C:\Users\bogda\AppData\Local\Temp\pip-build-env-hri2nal2\overlay\Lib\site-packages\setuptools\_distutils\dist.py", line 967, in run_commands
      self.run_command(cmd)
    File "C:\Users\bogda\AppData\Local\Temp\pip-build-env-hri2nal2\overlay\Lib\site-packages\setuptools\_distutils\dist.py", line 986, in run_command
      cmd_obj.run()
    File "C:\Users\bogda\AppData\Local\Temp\pip-build-env-hri2nal2\overlay\Lib\site-packages\wheel\bdist_wheel.py", line 325, in run
      self.run_command("build")
    File "C:\Users\bogda\AppData\Local\Temp\pip-build-env-hri2nal2\overlay\Lib\site-packages\setuptools\_distutils\cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "C:\Users\bogda\AppData\Local\Temp\pip-build-env-hri2nal2\overlay\Lib\site-packages\setuptools\_distutils\dist.py", line 986, in run_command
      cmd_obj.run()
    File "C:\Users\bogda\AppData\Local\Temp\pip-build-env-hri2nal2\overlay\Lib\site-packages\setuptools\_distutils\command\build.py", line 135, in run
      self.run_command(cmd_name)
    File "C:\Users\bogda\AppData\Local\Temp\pip-build-env-hri2nal2\overlay\Lib\site-packages\setuptools\_distutils\cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "C:\Users\bogda\AppData\Local\Temp\pip-build-env-hri2nal2\overlay\Lib\site-packages\setuptools\_distutils\dist.py", line 986, in run_command
      cmd_obj.run()
    File "C:\Users\bogda\AppData\Local\Temp\pip-build-env-hri2nal2\overlay\Lib\site-packages\setuptools\_distutils\command\build_clib.py", line 115, in run
      self.build_libraries(self.libraries)
    File "setup.py", line 294, in build_libraries
      self.build_cmake_lib(lib_name, build_info)
    File "setup.py", line 330, in build_cmake_lib
      self.run_cmake_cli(source_dir, build_dir, cmake_opts)
    File "setup.py", line 500, in run_cmake_cli
      , cwd=build_dir)
    File "setup.py", line 151, in run_command
      **kwargs,
    File "c:\users\bogda\appdata\local\programs\python\python37\lib\subprocess.py", line 756, in __init__
      restore_signals, start_new_session)
    File "c:\users\bogda\appdata\local\programs\python\python37\lib\subprocess.py", line 1100, in _execute_child
      args = list2cmdline(args)
    File "c:\users\bogda\appdata\local\programs\python\python37\lib\subprocess.py", line 511, in list2cmdline
      needquote = (" " in arg) or ("\t" in arg) or not arg
  TypeError: argument of type 'WindowsPath' is not iterable
  error: subprocess-exited-with-error

  × Building wheel for pyfhel (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> See above for output.

  note: This error originates from a subprocess, and is likely not a problem with pip.
  full command: 'c:\users\bogda\appdata\local\programs\python\python37\python.exe' 'c:\users\bogda\appdata\local\programs\python\python37\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py' build_wheel 'C:\Users\bogda\AppData\Local\Temp\tmphl1xilck'
  cwd: C:\Users\bogda\AppData\Local\Temp\pip-install-nrwf9ebs\pyfhel_4e15c35b546b43e59df9bff79c3df0a7
  Building wheel for pyfhel (pyproject.toml) ... error
  ERROR: Failed building wheel for pyfhel
Failed to build pyfhel
ERROR: Could not build wheels for pyfhel, which is required to install pyproject.toml-based projects```

Environment variables:

PS C:\Users\bogda> echo $Env:PATH
C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64\compiler;C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin;C:\Program Files\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\dotnet\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC;C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools;C:\Users\bogda\AppData\Local\Programs\Python\Python37\Scripts\;C:\Users\bogda\AppData\Local\Programs\Python\Python37\;C:\Users\bogda\AppData\Local\Microsoft\WindowsApps;C:\Users\bogda\AppData\Local\Programs\Microsoft VS Code\bin

Setup:

ibarrond commented 1 year ago

Hmmm, not sure what the issue is, but I encourage you to try more recent Python versions (Python 3.7 will be deprecated in 2023). Pyfhel worked correctly in Python 3.8, 3.9 and 3.10.

ibarrond commented 1 year ago

I confirm that this is a known issue in Python<=3.8 that was patched for Python3.8.

If you must absolutely use your current Python version, then add the following line afher this block of code:

https://github.com/ibarrond/Pyfhel/blob/4a480be3072503c3549f0e2e90eb8303b11e3220/setup.py#L483-L485

source_dir, build_dir = str(source_dir), str(build_dir)

On our side, we will be deprecating Python 3.7 in future versions of Pyfhel.

Bogdanzz96 commented 1 year ago

Thanks for this!

It's not a must having 3.7, just switched to 3.8 and it built successfully.