AntonKueltz / fastecdsa

Python library for fast elliptic curve crypto
https://pypi.python.org/pypi/fastecdsa
The Unlicense
264 stars 77 forks source link

Issues Installing in anaconda virtual environment #38

Closed mathcoke closed 5 years ago

mathcoke commented 5 years ago

I followed the instruction in 'installing' section. I'm using now anaconda and working in virtual environment

first, I type followings

$ sudo apt-get install python-dev libgmp3-dev

and this is successful works and follow type that

$ pip install fastecdsa

then I get error

ERROR: Command errored out with exit status 1:
   command: /home/kimjungmin/anaconda3/envs/sage/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-niky0gtn/fastecdsa/setup.py'"'"'; __file__='"'"'/tmp/pip-install-niky0gtn/fastecdsa/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-kmu6bhwv --python-tag cp36
       cwd: /tmp/pip-install-niky0gtn/fastecdsa/
  Complete output (44 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-3.6
  creating build/lib.linux-x86_64-3.6/fastecdsa
  copying fastecdsa/ecdsa.py -> build/lib.linux-x86_64-3.6/fastecdsa
  copying fastecdsa/keys.py -> build/lib.linux-x86_64-3.6/fastecdsa
  copying fastecdsa/__init__.py -> build/lib.linux-x86_64-3.6/fastecdsa
  copying fastecdsa/benchmark.py -> build/lib.linux-x86_64-3.6/fastecdsa
  copying fastecdsa/util.py -> build/lib.linux-x86_64-3.6/fastecdsa
  copying fastecdsa/point.py -> build/lib.linux-x86_64-3.6/fastecdsa
  copying fastecdsa/curve.py -> build/lib.linux-x86_64-3.6/fastecdsa
  creating build/lib.linux-x86_64-3.6/fastecdsa/encoding
  copying fastecdsa/encoding/sec1.py -> build/lib.linux-x86_64-3.6/fastecdsa/encoding
  copying fastecdsa/encoding/asn1.py -> build/lib.linux-x86_64-3.6/fastecdsa/encoding
  copying fastecdsa/encoding/pem.py -> build/lib.linux-x86_64-3.6/fastecdsa/encoding
  copying fastecdsa/encoding/__init__.py -> build/lib.linux-x86_64-3.6/fastecdsa/encoding
  copying fastecdsa/encoding/util.py -> build/lib.linux-x86_64-3.6/fastecdsa/encoding
  copying fastecdsa/encoding/der.py -> build/lib.linux-x86_64-3.6/fastecdsa/encoding
  creating build/lib.linux-x86_64-3.6/fastecdsa/tests
  copying fastecdsa/tests/test_p256_ecdsa.py -> build/lib.linux-x86_64-3.6/fastecdsa/tests
  copying fastecdsa/tests/test_signature_encoding.py -> build/lib.linux-x86_64-3.6/fastecdsa/tests
  copying fastecdsa/tests/test_key_recovery.py -> build/lib.linux-x86_64-3.6/fastecdsa/tests
  copying fastecdsa/tests/test_rfc6979_ecdsa.py -> build/lib.linux-x86_64-3.6/fastecdsa/tests
  copying fastecdsa/tests/test_brainpool_ecdh.py -> build/lib.linux-x86_64-3.6/fastecdsa/tests
  copying fastecdsa/tests/__init__.py -> build/lib.linux-x86_64-3.6/fastecdsa/tests
  copying fastecdsa/tests/test_whitespace_parsing.py -> build/lib.linux-x86_64-3.6/fastecdsa/tests
  copying fastecdsa/tests/test_prime_field_curve_math.py -> build/lib.linux-x86_64-3.6/fastecdsa/tests
  copying fastecdsa/tests/test_key_encoding.py -> build/lib.linux-x86_64-3.6/fastecdsa/tests
  copying fastecdsa/tests/test_asn1.py -> build/lib.linux-x86_64-3.6/fastecdsa/tests
  copying fastecdsa/tests/test_nonce_generation.py -> build/lib.linux-x86_64-3.6/fastecdsa/tests
  copying fastecdsa/tests/test_keygen.py -> build/lib.linux-x86_64-3.6/fastecdsa/tests
  running build_ext
  building 'fastecdsa.curvemath' extension
  creating build/temp.linux-x86_64-3.6
  creating build/temp.linux-x86_64-3.6/src
  /home/kimjungmin/anaconda3/envs/sage/bin/x86_64-conda_cos6-linux-gnu-cc -DNDEBUG -fwrapv -O2 -Wall -Wstrict-prototypes -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -fPIC -Isrc/ -I/home/kimjungmin/anaconda3/envs/sage/include/python3.6m -c src/curveMath.c -o build/temp.linux-x86_64-3.6/src/curveMath.o -O2
  In file included from src/curveMath.c:1:0:
  src/curveMath.h:6:10: fatal error: gmp.h: No such file or directory
   #include <gmp.h>
            ^~~~~~~
  compilation terminated.
  error: command '/home/kimjungmin/anaconda3/envs/sage/bin/x86_64-conda_cos6-linux-gnu-cc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for fastecdsa
  Running setup.py clean for fastecdsa
Failed to build fastecdsa
Installing collected packages: fastecdsa
  Running setup.py install for fastecdsa ... error
    ERROR: Command errored out with exit status 1:
     command: /home/kimjungmin/anaconda3/envs/sage/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-niky0gtn/fastecdsa/setup.py'"'"'; __file__='"'"'/tmp/pip-install-niky0gtn/fastecdsa/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-r_9fcsat/install-record.txt --single-version-externally-managed --compile
         cwd: /tmp/pip-install-niky0gtn/fastecdsa/
    Complete output (44 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.6
    creating build/lib.linux-x86_64-3.6/fastecdsa
    copying fastecdsa/ecdsa.py -> build/lib.linux-x86_64-3.6/fastecdsa
    copying fastecdsa/keys.py -> build/lib.linux-x86_64-3.6/fastecdsa
    copying fastecdsa/__init__.py -> build/lib.linux-x86_64-3.6/fastecdsa
    copying fastecdsa/benchmark.py -> build/lib.linux-x86_64-3.6/fastecdsa
    copying fastecdsa/util.py -> build/lib.linux-x86_64-3.6/fastecdsa
    copying fastecdsa/point.py -> build/lib.linux-x86_64-3.6/fastecdsa
    copying fastecdsa/curve.py -> build/lib.linux-x86_64-3.6/fastecdsa
    creating build/lib.linux-x86_64-3.6/fastecdsa/encoding
    copying fastecdsa/encoding/sec1.py -> build/lib.linux-x86_64-3.6/fastecdsa/encoding
    copying fastecdsa/encoding/asn1.py -> build/lib.linux-x86_64-3.6/fastecdsa/encoding
    copying fastecdsa/encoding/pem.py -> build/lib.linux-x86_64-3.6/fastecdsa/encoding
    copying fastecdsa/encoding/__init__.py -> build/lib.linux-x86_64-3.6/fastecdsa/encoding
    copying fastecdsa/encoding/util.py -> build/lib.linux-x86_64-3.6/fastecdsa/encoding
    copying fastecdsa/encoding/der.py -> build/lib.linux-x86_64-3.6/fastecdsa/encoding
    creating build/lib.linux-x86_64-3.6/fastecdsa/tests
    copying fastecdsa/tests/test_p256_ecdsa.py -> build/lib.linux-x86_64-3.6/fastecdsa/tests
    copying fastecdsa/tests/test_signature_encoding.py -> build/lib.linux-x86_64-3.6/fastecdsa/tests
    copying fastecdsa/tests/test_key_recovery.py -> build/lib.linux-x86_64-3.6/fastecdsa/tests
    copying fastecdsa/tests/test_rfc6979_ecdsa.py -> build/lib.linux-x86_64-3.6/fastecdsa/tests
    copying fastecdsa/tests/test_brainpool_ecdh.py -> build/lib.linux-x86_64-3.6/fastecdsa/tests
    copying fastecdsa/tests/__init__.py -> build/lib.linux-x86_64-3.6/fastecdsa/tests
    copying fastecdsa/tests/test_whitespace_parsing.py -> build/lib.linux-x86_64-3.6/fastecdsa/tests
    copying fastecdsa/tests/test_prime_field_curve_math.py -> build/lib.linux-x86_64-3.6/fastecdsa/tests
    copying fastecdsa/tests/test_key_encoding.py -> build/lib.linux-x86_64-3.6/fastecdsa/tests
    copying fastecdsa/tests/test_asn1.py -> build/lib.linux-x86_64-3.6/fastecdsa/tests
    copying fastecdsa/tests/test_nonce_generation.py -> build/lib.linux-x86_64-3.6/fastecdsa/tests
    copying fastecdsa/tests/test_keygen.py -> build/lib.linux-x86_64-3.6/fastecdsa/tests
    running build_ext
    building 'fastecdsa.curvemath' extension
    creating build/temp.linux-x86_64-3.6
    creating build/temp.linux-x86_64-3.6/src
    /home/kimjungmin/anaconda3/envs/sage/bin/x86_64-conda_cos6-linux-gnu-cc -DNDEBUG -fwrapv -O2 -Wall -Wstrict-prototypes -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -fPIC -Isrc/ -I/home/kimjungmin/anaconda3/envs/sage/include/python3.6m -c src/curveMath.c -o build/temp.linux-x86_64-3.6/src/curveMath.o -O2
    In file included from src/curveMath.c:1:0:
    src/curveMath.h:6:10: fatal error: gmp.h: No such file or directory
     #include <gmp.h>
              ^~~~~~~
    compilation terminated.
    error: command '/home/kimjungmin/anaconda3/envs/sage/bin/x86_64-conda_cos6-linux-gnu-cc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /home/kimjungmin/anaconda3/envs/sage/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-niky0gtn/fastecdsa/setup.py'"'"'; __file__='"'"'/tmp/pip-install-niky0gtn/fastecdsa/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-r_9fcsat/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.

But I have gmp.h header in /home/kimjungmin/anaconda3/envs/sage/include

ironically, In base env, that command

$ pip install fastecdsa

is good works.

I don't know how I can found solution. please help.

AntonKueltz commented 5 years ago

I'm not really familiar with how anaconda works. You need to verify that your C compiler knows how to find the appropriate headers in the environment. A minimal example would be to compile the program below in your environment with gcc <filename> -lgmp

#include <gmp.h>

int main() {
    return 0;
}

Debug errors from there. Most likely the path to your environments specific headers is not known to the C compiler.

AntonKueltz commented 5 years ago

You could also try to fork this and give a -I/path/to/your/headers/folder flag to the compiler as part of the extra_compile_args in setup.py. YMMV.

AntonKueltz commented 5 years ago

Closing as this is an environment issue.