hynek / argon2-cffi

Secure Password Hashes for Python
https://argon2-cffi.readthedocs.io/
MIT License
562 stars 47 forks source link

Doesn't work with pypy #6

Closed LuisUrrutia closed 8 years ago

LuisUrrutia commented 8 years ago

With pypy it's show:

ImportError: No module named argon2._ffi

Like in travis build (same error)

More Log:

/bin/ld: cannot find -llibargon2
collect2: error: ld returned 1 exit status
Traceback (most recent call last):
  File "src/argon2/_ffi_build.py", line 167, in <module>
    ffi.compile()
  File "/opt/pypy-nightly/lib_pypy/cffi/api.py", line 599, in compile
    source_extension=source_extension, **kwds)
  File "/opt/pypy-nightly/lib_pypy/cffi/recompiler.py", line 1255, in recompile
    outputfilename = ffiplatform.compile('.', ext)
  File "/opt/pypy-nightly/lib_pypy/cffi/ffiplatform.py", line 28, in compile
    outputfilename = _build(tmpdir, ext)
  File "/opt/pypy-nightly/lib_pypy/cffi/ffiplatform.py", line 54, in _build
    raise VerificationError('%s: %s' % (e.__class__.__name__, e))
VerificationError: LinkError: command 'cc' failed with exit status 1
hynek commented 8 years ago

What version of PyPy on what platform is that?

Travis is expected to fail because the PyPy is too old (it's actually the cffi that's too old but it's bundled with PyPy and cannot be updated separately).

LuisUrrutia commented 8 years ago

Latest build, i compile it from sources yesterday (25 Jan) and I have: cffi==1.5.0 argon2-cffi==16.0.0 I also tried with 16.1.0dev0

What i know is that the _ffi_build.py file generates _ffi.py when it is run with cffi > 1.0 but for a reason it doesn't.

hynek commented 8 years ago

so you’re checking it out from github?

you have to do: python setup.py build; pip install -e . (make sure you're in a virtualenv)

LuisUrrutia commented 8 years ago

I have the same error, i setup a virtualenv and everything, but i still have the same error:

>>>> import argon2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/vagrant/something/site-packages/argon2/__init__.py", line 5, in <module>
    from . import exceptions, low_level
  File "/vagrant/something/site-packages/argon2/low_level.py", line 17, in <module>
    from ._ffi import ffi, lib
ImportError: No module named argon2._ffi

Something is the virtualenv folder

LS output of /vagrant/something/site-packages/argon2/:

-rw-r--r-- 1 vagrant vagrant 1098 Feb  1 15:32 __init__.py
-rw-r--r-- 1 vagrant vagrant 1396 Feb  1 15:32 __init__.pyc
-rw-r--r-- 1 vagrant vagrant 2145 Feb  1 15:32 __main__.py
-rw-r--r-- 1 vagrant vagrant 2276 Feb  1 15:32 __main__.pyc
-rw-r--r-- 1 vagrant vagrant 4125 Feb  1 15:32 _ffi_build.py
-rw-r--r-- 1 vagrant vagrant 4352 Feb  1 15:32 _ffi_build.pyc
-rw-r--r-- 1 vagrant vagrant 1890 Feb  1 15:32 _legacy.py
-rw-r--r-- 1 vagrant vagrant 1931 Feb  1 15:32 _legacy.pyc
-rw-r--r-- 1 vagrant vagrant 3953 Feb  1 15:32 _password_hasher.py
-rw-r--r-- 1 vagrant vagrant 4157 Feb  1 15:32 _password_hasher.pyc
-rw-r--r-- 1 vagrant vagrant 1881 Feb  1 15:32 _util.py
-rw-r--r-- 1 vagrant vagrant 1656 Feb  1 15:32 _util.pyc
-rw-r--r-- 1 vagrant vagrant  525 Feb  1 15:32 exceptions.py
-rw-r--r-- 1 vagrant vagrant 1075 Feb  1 15:32 exceptions.pyc
-rw-r--r-- 1 vagrant vagrant 5167 Feb  1 15:32 low_level.py
-rw-r--r-- 1 vagrant vagrant 5212 Feb  1 15:32 low_level.pyc

pypy setup.py build output:

Building SSE2-optimized version.
/opt/pypy-nightly/lib-python/2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'cffi_modules'
  warnings.warn(msg)
running build
running build_py
running build_clib
building 'libargon2' library
cc -O2 -fPIC -Wimplicit -Iextras/libargon2/src -Iextras/libargon2/src/blake2 -c extras/libargon2/src/argon2.c -o build/temp.linux-x86_64-2.7/extras/libargon2/src/argon2.o
cc -O2 -fPIC -Wimplicit -Iextras/libargon2/src -Iextras/libargon2/src/blake2 -c extras/libargon2/src/blake2/blake2b.c -o build/temp.linux-x86_64-2.7/extras/libargon2/src/blake2/blake2b.o
cc -O2 -fPIC -Wimplicit -Iextras/libargon2/src -Iextras/libargon2/src/blake2 -c extras/libargon2/src/core.c -o build/temp.linux-x86_64-2.7/extras/libargon2/src/core.o
cc -O2 -fPIC -Wimplicit -Iextras/libargon2/src -Iextras/libargon2/src/blake2 -c extras/libargon2/src/encoding.c -o build/temp.linux-x86_64-2.7/extras/libargon2/src/encoding.o
cc -O2 -fPIC -Wimplicit -Iextras/libargon2/src -Iextras/libargon2/src/blake2 -c extras/libargon2/src/opt.c -o build/temp.linux-x86_64-2.7/extras/libargon2/src/opt.o
cc -O2 -fPIC -Wimplicit -Iextras/libargon2/src -Iextras/libargon2/src/blake2 -c extras/libargon2/src/thread.c -o build/temp.linux-x86_64-2.7/extras/libargon2/src/thread.o
ar -cr build/temp.linux-x86_64-2.7/liblibargon2.a build/temp.linux-x86_64-2.7/extras/libargon2/src/argon2.o build/temp.linux-x86_64-2.7/extras/libargon2/src/blake2/blake2b.o build/temp.linux-x86_64-2.7/extras/libargon2/src/core.o build/temp.linux-x86_64-2.7/extras/libargon2/src/encoding.o build/temp.linux-x86_64-2.7/extras/libargon2/src/opt.o build/temp.linux-x86_64-2.7/extras/libargon2/src/thread.o

pip install -e . output:

Obtaining file:///vagrant/app/Tests/argon2_cffi
Requirement already satisfied (use --upgrade to upgrade): six in /vagrant/something/site-packages (from argon2-cffi==16.1.0.dev0)
Requirement already satisfied (use --upgrade to upgrade): cffi>=1.0.0 in /vagrant/something/site-packages (from argon2-cffi==16.1.0.dev0)
Requirement already satisfied (use --upgrade to upgrade): enum34 in /vagrant/something/site-packages (from argon2-cffi==16.1.0.dev0)
Installing collected packages: argon2-cffi
  Running setup.py develop for argon2-cffi
Successfully installed argon2-cffi-16.0.0
hynek commented 8 years ago
vagrant@trusty64:~$ pypy --version
Python 2.7.10 (4.0.1+dfsg-1~ppa1~ubuntu14.04, Nov 20 2015, 19:34:15)
[PyPy 4.0.1 with GCC 4.8.4]
vagrant@trusty64:~$ cd Projects/argon2_cffi/
vagrant@trusty64:~/Projects/argon2_cffi$ ~/something/bin/pypy setup.py build
Building SSE2-optimized version.
running build
running build_py
creating build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/argon2
copying src/argon2/__init__.py -> build/lib.linux-x86_64-2.7/argon2
copying src/argon2/__main__.py -> build/lib.linux-x86_64-2.7/argon2
copying src/argon2/_ffi_build.py -> build/lib.linux-x86_64-2.7/argon2
copying src/argon2/_legacy.py -> build/lib.linux-x86_64-2.7/argon2
copying src/argon2/_password_hasher.py -> build/lib.linux-x86_64-2.7/argon2
copying src/argon2/_util.py -> build/lib.linux-x86_64-2.7/argon2
copying src/argon2/exceptions.py -> build/lib.linux-x86_64-2.7/argon2
copying src/argon2/low_level.py -> build/lib.linux-x86_64-2.7/argon2
running build_clib
building 'libargon2' library
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/extras
creating build/temp.linux-x86_64-2.7/extras/libargon2
creating build/temp.linux-x86_64-2.7/extras/libargon2/src
creating build/temp.linux-x86_64-2.7/extras/libargon2/src/blake2
cc -O2 -fPIC -Wimplicit -Iextras/libargon2/src -Iextras/libargon2/src/blake2 -c extras/libargon2/src/argon2.c -o build/temp.linux-x86_64-2.7/extras/libargon2/src/argon2.o
cc -O2 -fPIC -Wimplicit -Iextras/libargon2/src -Iextras/libargon2/src/blake2 -c extras/libargon2/src/blake2/blake2b.c -o build/temp.linux-x86_64-2.7/extras/libargon2/src/blake2/blake2b.o
cc -O2 -fPIC -Wimplicit -Iextras/libargon2/src -Iextras/libargon2/src/blake2 -c extras/libargon2/src/core.c -o build/temp.linux-x86_64-2.7/extras/libargon2/src/core.o
cc -O2 -fPIC -Wimplicit -Iextras/libargon2/src -Iextras/libargon2/src/blake2 -c extras/libargon2/src/encoding.c -o build/temp.linux-x86_64-2.7/extras/libargon2/src/encoding.o
cc -O2 -fPIC -Wimplicit -Iextras/libargon2/src -Iextras/libargon2/src/blake2 -c extras/libargon2/src/opt.c -o build/temp.linux-x86_64-2.7/extras/libargon2/src/opt.o
cc -O2 -fPIC -Wimplicit -Iextras/libargon2/src -Iextras/libargon2/src/blake2 -c extras/libargon2/src/thread.c -o build/temp.linux-x86_64-2.7/extras/libargon2/src/thread.o
ar -cr build/temp.linux-x86_64-2.7/liblibargon2.a build/temp.linux-x86_64-2.7/extras/libargon2/src/argon2.o build/temp.linux-x86_64-2.7/extras/libargon2/src/blake2/blake2b.o build/temp.linux-x86_64-2.7/extras/libargon2/src/core.o build/temp.linux-x86_64-2.7/extras/libargon2/src/encoding.o build/temp.linux-x86_64-2.7/extras/libargon2/src/opt.o build/temp.linux-x86_64-2.7/extras/libargon2/src/thread.o
running build_ext
generating cffi module 'build/temp.linux-x86_64-2.7/_ffi.c'
building '_ffi' extension
creating build/temp.linux-x86_64-2.7/build
creating build/temp.linux-x86_64-2.7/build/temp.linux-x86_64-2.7
cc -O2 -fPIC -Wimplicit -O2 -fPIC -Wimplicit -Iextras/libargon2/src -I/home/vagrant/something/include -c build/temp.linux-x86_64-2.7/_ffi.c -o build/temp.linux-x86_64-2.7/build/temp.linux-x86_64-2.7/_ffi.o
cc -shared build/temp.linux-x86_64-2.7/build/temp.linux-x86_64-2.7/_ffi.o -Lbuild/temp.linux-x86_64-2.7 -llibargon2 -llibargon2 -o build/lib.linux-x86_64-2.7/argon2/_ffi.pypy-26-x86_64-linux-gnu.so
vagrant@trusty64:~/Projects/argon2_cffi$ ~/something/bin/pip install -e .
You are using pip version 7.0.1, however version 8.0.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Obtaining file:///home/vagrant/Projects/argon2_cffi
Collecting six (from argon2-cffi==16.1.0.dev0)
  Downloading https://pypi.vm.ag/root/pypi/+f/3ab/558cf5d4f7a72/six-1.10.0-py2.py3-none-any.whl
Requirement already satisfied (use --upgrade to upgrade): cffi>=1.0.0 in /usr/lib/pypy/lib_pypy (from argon2-cffi==16.1.0.dev0)
Collecting enum34 (from argon2-cffi==16.1.0.dev0)
  Downloading https://pypi.vm.ag/root/pypi/+f/a9e/bbad4ce451c12/enum34-1.1.2.zip (49kB)
    100% |████████████████████████████████| 53kB 1.8MB/s
Building wheels for collected packages: enum34
  Running setup.py bdist_wheel for enum34
  Stored in directory: /home/vagrant/.cache/pip/wheels/91/73/70/4c732c7dd1376eba33cac049f1a4e75059081ec681a7f80902
Successfully built enum34
Installing collected packages: six, enum34, argon2-cffi
  Running setup.py develop for argon2-cffi
Successfully installed argon2-cffi enum34-1.1.2 six-1.10.0
vagrant@trusty64:~/Projects/argon2_cffi$ ~/something/bin/pypy
Python 2.7.10 (4.0.1+dfsg-1~ppa1~ubuntu14.04, Nov 20 2015, 19:34:15)
[PyPy 4.0.1 with GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>> import argon2
>>>>
vagrant@trusty64:~/Projects/argon2_cffi$ ll ~/something/site-packages
total 100
drwxrwxr-x 14 vagrant vagrant  4096 Feb  1 16:51 ./
drwxrwxr-x  6 vagrant vagrant  4096 Feb  1 16:51 ../
-rw-rw-r--  1 vagrant vagrant    42 Feb  1 16:51 argon2-cffi.egg-link
-rw-rw-r--  1 vagrant vagrant   224 Feb  1 16:51 easy-install.pth
-rw-rw-r--  1 vagrant vagrant   126 Feb  1 16:49 easy_install.py
drwxrwxr-x  4 vagrant vagrant  4096 Feb  1 16:51 enum/
drwxrwxr-x  2 vagrant vagrant  4096 Feb  1 16:51 enum34-1.1.2.dist-info/
drwxrwxr-x  3 vagrant vagrant  4096 Feb  1 16:49 _markerlib/
drwxrwxr-x 11 vagrant vagrant  4096 Feb  1 16:49 pip/
drwxrwxr-x  2 vagrant vagrant  4096 Feb  1 16:49 pip-7.0.1.dist-info/
drwxrwxr-x  4 vagrant vagrant  4096 Feb  1 16:49 pkg_resources/
drwxrwxr-x  2 vagrant vagrant  4096 Feb  1 16:51 __pycache__/
drwxrwxr-x  4 vagrant vagrant  4096 Feb  1 16:49 setuptools/
drwxrwxr-x  2 vagrant vagrant  4096 Feb  1 16:49 setuptools-16.0.dist-info/
drwxrwxr-x  2 vagrant vagrant  4096 Feb  1 16:51 six-1.10.0.dist-info/
-rw-rw-r--  1 vagrant vagrant 30098 Feb  1 16:51 six.py
drwxrwxr-x  6 vagrant vagrant  4096 Feb  1 16:49 wheel/
drwxrwxr-x  2 vagrant vagrant  4096 Feb  1 16:49 wheel-0.24.0.dist-info/

Not the absence of an argon2 directory in the listing.

My guess is that that virtualenv has a bogus installation of argon2 in it. Create a new one and it should work as you can see above.

LuisUrrutia commented 8 years ago

How did you install pypy in that trusty64? 'cause i did it with ppa:pypy/ppa, but i can't install pip, so i installed it with easy_install but i can't. I installed build-essential too

I tried a fresh ubuntu install i it show me this output with: pypy setup.py install

The build it's ok

writing build/bdist.linux-x86_64/egg/EGG-INFO/native_libs.txt
Traceback (most recent call last):
  File "setup.py", line 159, in <module>
    extras_require=EXTRAS_REQUIRE,
  File "/usr/lib/pypy/lib-python/2.7/distutils/core.py", line 151, in setup
    dist.run_commands()
  File "/usr/lib/pypy/lib-python/2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/usr/lib/pypy/lib-python/2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/usr/local/lib/pypy2.7/dist-packages/distribute-0.6.49-py2.7.egg/setuptools/command/install.py", line 73, in run
    self.do_egg_install()
  File "/usr/local/lib/pypy2.7/dist-packages/distribute-0.6.49-py2.7.egg/setuptools/command/install.py", line 93, in do_egg_install
    self.run_command('bdist_egg')
  File "/usr/lib/pypy/lib-python/2.7/distutils/cmd.py", line 326, in run_command
    self.distribution.run_command(command)
  File "/usr/lib/pypy/lib-python/2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/usr/local/lib/pypy2.7/dist-packages/distribute-0.6.49-py2.7.egg/setuptools/command/bdist_egg.py", line 241, in run
    dry_run=self.dry_run, mode=self.gen_header())
  File "/usr/local/lib/pypy2.7/dist-packages/distribute-0.6.49-py2.7.egg/setuptools/command/bdist_egg.py", line 523, in make_zipfile
    mkpath(os.path.dirname(zip_filename), dry_run=dry_run)
  File "/usr/lib/pypy/lib-python/2.7/distutils/dir_util.py", line 44, in mkpath
    if os.path.isdir(name) or name == '':
  File "/usr/lib/pypy/lib-python/2.7/genericpath.py", line 49, in isdir
    st = os.stat(s)
TypeError: expected string, got NoneType object

The thing i that i don't want a install with virtualenv 'cause i wanna use it in production, with: 1112a2e58336e549f8efb7f2d747f5249f85f6be argon2_cffi 16.0.0

hynek commented 8 years ago

Yes, my pypy is from the pypy ppa.

You don’t need to ever install pip. If you create a virtualenv, you’ll get it for free in the correct version. My suspicion is that your packaging setup is broken. Is your lack of pip the reason why you don’t just take it from PyPI?