HEAAN-Python icon indicating copy to clipboard operation
HEAAN-Python copied to clipboard

Problems installing PyHEAAN

Open CarlosMoralesSal opened this issue 4 years ago • 20 comments

Hello,

I am trying to follow all steps to install PyHEAAN. when I am installing the ntl . I have this error after run the makefile:

GMP version check (6.2.0/6.1.2) *** version number mismatch: inconsistency between gmp.h and libgmp . How can I solve this?. I would love to work with PyHEAAN but it is so difficult because there is no step by step clear. Could you help with this?. Thanks

CarlosMoralesSal avatar Jul 04 '20 15:07 CarlosMoralesSal

For your error, just go to download, choose correct [version 6.1.2] (https://gmplib.org/download/gmp/gmp-6.1.2.tar.lz) and compile. We need to build a shared lib, then the python interpreter can find it. main steps:

  1. build a Shared NTL lib, which you need to change the NTL's source src/DoConfig line 10 'Shared' to on and change the path in setup.py line 19 to it. The latest NTL lib(11.4.3) need GMP and gf2x, so just refer to this

  2. Add -fPIC in HEAAN/HEAAN/lib/src/subdir.mk line 59, and build the HEAAN lib.

  3. in /src run python3 setup.py build_ext -i build the PyHEAAN.

I admitted that's a little complicated, I will improve it later.

Huelse avatar Jul 04 '20 15:07 Huelse

Thanks for your clarification @Huelse , I love your repository.

CarlosMoralesSal avatar Jul 04 '20 15:07 CarlosMoralesSal

@Huelse , the problem with the installation continues. When I am on the lasts steps I have this error, when I do the make or setup: CMake Error at /home/hermes/Escritorio/PYHEAAN/pybind11/build/pybind11Config.cmake:100 (include): include could not find load file:

pybind11Tools

Call Stack (most recent call first): CMakeLists.txt:15 (find_package)

CMake Error at /home/hermes/Escritorio/PYHEAAN/pybind11/build/pybind11Config.cmake:108 (include): include could not find load file:

/home/hermes/Escritorio/PYHEAAN/pybind11/build/pybind11Targets.cmake

Call Stack (most recent call first): CMakeLists.txt:15 (find_package)

CMake Error at /home/hermes/Escritorio/PYHEAAN/pybind11/build/pybind11Config.cmake:110 (find_package): No "FindPythonLibsNew.cmake" found in CMAKE_MODULE_PATH. Call Stack (most recent call first): CMakeLists.txt:15 (find_package)

CMake Warning (dev) at /home/hermes/Escritorio/PYHEAAN/pybind11/build/pybind11Config.cmake:110 (find_package): FindPythonLibsNew.cmake must either be part of this project itself, in this case adjust CMAKE_MODULE_PATH so that it points to the correct location inside its source tree.

Or it must be installed by a package which has already been found via find_package(). In this case make sure that package has indeed been found and adjust CMAKE_MODULE_PATH to contain the location where that package has installed FindPythonLibsNew.cmake. This must be a location provided by that package. This error in general means that the buildsystem of this project is relying on a Find-module without ensuring that it is actually available.

Call Stack (most recent call first): CMakeLists.txt:15 (find_package) This warning is for project developers. Use -Wno-dev to suppress it.

-- Configuring incomplete, errors occurred! See also "/home/hermes/Escritorio/PYHEAAN/src/CMakeFiles/CMakeOutput.log".

I have follow everything, even I have run this command: cmake -Dpybind11_DIR=/home/hermes/Escritorio/PYHEAAN/pybind11/build . and nothing.

CarlosMoralesSal avatar Jul 05 '20 11:07 CarlosMoralesSal

Have you run pip3 install pybind11? if not, try to install it. sometimes the find_package may not work well, you could try to build and install the latest CMake. or use add_subdirectory instead of find_package.

Huelse avatar Jul 05 '20 12:07 Huelse

Nope, it doesn't work with pip3 install, I will try with conda as well.

CarlosMoralesSal avatar Jul 05 '20 13:07 CarlosMoralesSal

How about trying to run python install setup.py in the pybind11 folder?

Huelse avatar Jul 05 '20 13:07 Huelse

Nothing hermes@hermes-VirtualBox:~/Escritorio/PYHEAAN/pybind11$ python3 install setup.py python3: can't open file 'install': [Errno 2] No such file or directory I am using as well python3.7 by the way

CarlosMoralesSal avatar Jul 05 '20 13:07 CarlosMoralesSal

My bad, the order is wrong, python3 setup.py install or download a new pybind11

Huelse avatar Jul 05 '20 14:07 Huelse

After doing that and run again the cmake . , I have this: hermes@hermes-VirtualBox:~/Escritorio/PYHEAAN/src$ cmake -Dpybind11_DIR=/home/hermes/Escritorio/PYHEAAN/pybind11/build . CMake Error at /home/hermes/Escritorio/PYHEAAN/pybind11/build/pybind11Config.cmake:100 (include): include could not find load file:

pybind11Tools

Call Stack (most recent call first): CMakeLists.txt:15 (find_package)

CMake Error at /home/hermes/Escritorio/PYHEAAN/pybind11/build/pybind11Config.cmake:108 (include): include could not find load file:

/home/hermes/Escritorio/PYHEAAN/pybind11/build/pybind11Targets.cmake

Call Stack (most recent call first): CMakeLists.txt:15 (find_package)

CMake Error at /home/hermes/Escritorio/PYHEAAN/pybind11/build/pybind11Config.cmake:110 (find_package): No "FindPythonLibsNew.cmake" found in CMAKE_MODULE_PATH. Call Stack (most recent call first): CMakeLists.txt:15 (find_package)

CMake Warning (dev) at /home/hermes/Escritorio/PYHEAAN/pybind11/build/pybind11Config.cmake:110 (find_package): FindPythonLibsNew.cmake must either be part of this project itself, in this case adjust CMAKE_MODULE_PATH so that it points to the correct location inside its source tree.

Or it must be installed by a package which has already been found via find_package(). In this case make sure that package has indeed been found and adjust CMAKE_MODULE_PATH to contain the location where that package has installed FindPythonLibsNew.cmake. This must be a location provided by that package. This error in general means that the buildsystem of this project is relying on a Find-module without ensuring that it is actually available.

Call Stack (most recent call first): CMakeLists.txt:15 (find_package) This warning is for project developers. Use -Wno-dev to suppress it.

-- Configuring incomplete, errors occurred! See also "/home/hermes/Escritorio/PYHEAAN/src/CMakeFiles/CMakeOutput.log".

CarlosMoralesSal avatar Jul 05 '20 14:07 CarlosMoralesSal

What's your cmake's version?

Huelse avatar Jul 05 '20 14:07 Huelse

cmake version 3.13.4

CarlosMoralesSal avatar Jul 05 '20 14:07 CarlosMoralesSal

Now I have this: rmes/Escritorio/pybind11-2.4.3/build/mock_install/share/cmake/pybind11 CMake Warning: No source or binary directory provided. Both will be assumed to be the same as the current working directory, but note that this warning will become a fatal error in future CMake releases.

-- Found PythonInterp: /usr/bin/python3.7 (found version "3.7.5") -- Found PythonLibs: /usr/lib/x86_64-linux-gnu/libpython3.7m.so -- Performing Test HAS_FLTO -- Performing Test HAS_FLTO - Success -- LTO enabled -- Configuring done -- Generating done -- Build files have been written to: /home/hermes/Escritorio/PYHEAAN/src

And when I run the test.py with python3 test.py Traceback (most recent call last): File "test.py", line 1, in from HEAAN import * ModuleNotFoundError: No module named 'HEAAN'

CarlosMoralesSal avatar Jul 05 '20 14:07 CarlosMoralesSal

if you create a build folder, the HEAAN..so is in it. just move it out.

python3 setup.py install can be global use.

Huelse avatar Jul 05 '20 14:07 Huelse

running install running build running build_ext building 'HEAAN' extension x86_64-linux-gnu-gcc -pthread -Wno-unused-result -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/usr/include/python3.7 -I../pybind11/include -I/usr/local/include -I../HEAAN/src -I/usr/include/python3.7m -c wrapper.cpp -o build/temp.linux-x86_64-3.7/wrapper.o -std=c++11 wrapper.cpp:9:10: fatal error: HEAAN.h: No existe el archivo o el directorio 9 | #include "HEAAN.h" | ^~~~~~~~~ compilation terminated. error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

CarlosMoralesSal avatar Jul 05 '20 14:07 CarlosMoralesSal

Change the path of HEAAN, in setup.py line 16, '../HEAAN/src' to '../HEAAN/HEAAN/src' and line 19 '../HEAAN/lib/libHEAAN.a' to '../HEAAN/HEAAN/lib/libHEAAN.a' I will fix it later.

Huelse avatar Jul 05 '20 14:07 Huelse

I got to run the test but:

hermes@hermes-VirtualBox:~/Escritorio/PYHEAAN/src$ python3 test.py 
Segmentation violation ('core generated')
hermes@hermes-VirtualBox:~/Escritorio/PYHEAAN/src$ 

CarlosMoralesSal avatar Jul 05 '20 15:07 CarlosMoralesSal

It's hard to find out the problem. I tried both ways to build the PYHEAAN. It works well in my environment(Ubuntu18.04 with py3.6.9). You need to make sure that HEAAN.a is compiled with -fPIC args, and in NTL's src, you have change Shared to on in the DoConfig. Then check the path in setup.py or CMakelists.txt. If something the compiler can't find, change it to the absolute path. This repository will be improved later, if you don't hurry, just wait for a few days.

Huelse avatar Jul 06 '20 07:07 Huelse

I'm going to try with Ubuntu 18.04

CarlosMoralesSal avatar Jul 06 '20 16:07 CarlosMoralesSal

@Huelse , after installing on Ubuntu 18.04 after running the test.py I got this error and I see this library on my /usr/local/lib sudo python3 test.py Traceback (most recent call last): File "test.py", line 1, in from HEAAN import * ImportError: libntl.so.43: cannot open shared object file: No such file or directory

I did what is written on FAQs and I got Segmentation Fault as result after run the test.py

CarlosMoralesSal avatar Jul 07 '20 09:07 CarlosMoralesSal

Sorry for that, I forgot to commit the latest change for a long time, there is missing base64.cpp in the setup.py. Now, just try the latest version, I just committed.

Huelse avatar Jul 07 '20 10:07 Huelse