taleinat / fuzzysearch

Find parts of long text or data, allowing for some changes/typos.
MIT License
301 stars 26 forks source link

Build trouble Python 3.4 on Linux #9

Closed jsf80238 closed 9 years ago

jsf80238 commented 9 years ago
$ python
Python 3.4.0 (default, Apr 18 2014, 19:16:28) 
[GCC 4.8.1] on linux

$ python setup.py build
/opt/python/lib/python3.4/distutils/dist.py:260: UserWarning: Unknown distribution option: 'install_requires'
  warnings.warn(msg)
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.4
creating build/lib.linux-x86_64-3.4/fuzzysearch
copying src/fuzzysearch/common.py -> build/lib.linux-x86_64-3.4/fuzzysearch
copying src/fuzzysearch/substitutions_only.py -> build/lib.linux-x86_64-3.4/fuzzysearch
copying src/fuzzysearch/generic_search.py -> build/lib.linux-x86_64-3.4/fuzzysearch
copying src/fuzzysearch/levenshtein.py -> build/lib.linux-x86_64-3.4/fuzzysearch
copying src/fuzzysearch/no_deletions.py -> build/lib.linux-x86_64-3.4/fuzzysearch
copying src/fuzzysearch/levenshtein_ngram.py -> build/lib.linux-x86_64-3.4/fuzzysearch
copying src/fuzzysearch/__init__.py -> build/lib.linux-x86_64-3.4/fuzzysearch
running build_ext
building 'fuzzysearch._substitutions_only' extension
creating build/temp.linux-x86_64-3.4
creating build/temp.linux-x86_64-3.4/src
creating build/temp.linux-x86_64-3.4/src/fuzzysearch
gcc -pthread -Wno-unused-result -Werror=declaration-after-statement -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I. -I/opt/python/include/python3.4m -c src/fuzzysearch/_substitutions_only.c -o build/temp.linux-x86_64-3.4/src/fuzzysearch/_substitutions_only.o
./src/fuzzysearch/_substitutions_only_lp_template.h: In function ‘substitutions_only_find_near_matches_lp_byteslike’:
src/fuzzysearch/_substitutions_only.c:26:5: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
     PyObject *results;       \
     ^
./src/fuzzysearch/_substitutions_only_lp_template.h:44:5: note: in expansion of macro ‘PREPARE’
     PREPARE;
     ^
./src/fuzzysearch/_substitutions_only_ngrams_template.h: In function ‘substitutions_only_find_near_matches_ngrams_byteslike’:
src/fuzzysearch/_substitutions_only.c:26:5: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
     PyObject *results;       \
     ^
./src/fuzzysearch/_substitutions_only_ngrams_template.h:63:5: note: in expansion of macro ‘PREPARE’
     PREPARE;
     ^
cc1: some warnings being treated as errors
==========================================================================
WARNING: The C extensions could not be compiled; speedups are not enabled.
Failure information, if any, is above.
Retrying the build without the C extension now.

running build
running build_py
creating build/lib
creating build/lib/fuzzysearch
copying src/fuzzysearch/common.py -> build/lib/fuzzysearch
copying src/fuzzysearch/substitutions_only.py -> build/lib/fuzzysearch
copying src/fuzzysearch/generic_search.py -> build/lib/fuzzysearch
copying src/fuzzysearch/levenshtein.py -> build/lib/fuzzysearch
copying src/fuzzysearch/no_deletions.py -> build/lib/fuzzysearch
copying src/fuzzysearch/levenshtein_ngram.py -> build/lib/fuzzysearch
copying src/fuzzysearch/__init__.py -> build/lib/fuzzysearch
==========================================================================
WARNING: The C extensions could not be compiled; speedups are not enabled.
Plain-Python installation succeeded.
==========================================================================
taleinat commented 9 years ago

Hi, thanks for submitting this!

First, you need to have setuptools installed in order to properly run python setup.py .... It seems to be running fine in your case without it, since only install_requires doesn't work without setuptools, and the only requirement (six) isn't needed for python setup.py build. But you really should just install setuptools.

Second, it appears your C compiler is more strict than mine. I've fixed my C code to declare all variables at the beginning of function definitions, which is what caused the error.

Could you try building fuzzysearch again (from the master branch) and tell me whether it works now?

taleinat commented 9 years ago

Also, could you mention which version of Linux this is?

jsf80238 commented 9 years ago

Was able to compile, thank you Tal.

$ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 14.04.1 LTS Release: 14.04 Codename: trusty

$ uname -a Linux goldenrule 3.13.0-45-generic #74-Ubuntu SMP Tue Jan 13 19:36:28 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

By the way, I believe setuptools was installed.

$ python -c 'import setuptools' [no error]

taleinat commented 9 years ago

Thanks for the followup. I'm happy that it works!

Regarding setuptools, indeed it was a problem with setup.py. I had already fixed it, but the commit was not yet included in the first version which you used.