CC for python distutils to build c - python

I was trying to build c through python distutils. I want to replace CC with gcc and follow this page
CC=gcc python setup.py build
Then I got
gcc -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c hello.c -o build/temp.linux-x86_64-2.7/hello.o
creating build/lib.linux-x86_64-2.7
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -Wl,-z,relro -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/hello.o -o build/lib.linux-x86_64-2.7/hello.so
CC only changed to gcc on first stage, and it would become original x86_64-linux-gnu-gcc, I am not sure is there anything missing, thanks.

You must set "CC" with
os.environ["CC"] = "GCC"
However, this sometimes does not work in windows and involves some changes in the config files.
Create file "C:\Python27\Lib\distutils\distutils.cfg" and write this inside
Then insert the following code:
[build]
compiler = gcc
Remove all instances of "-mno-cygwin" gcc option from file "C:\Python27\Lib\distutils\cygwinccompiler.py":
In the same file convert this:
self.set_executables(compiler='gcc -mno-cygwin -O -Wall',
compiler_so='gcc -mno-cygwin -mdll -O -Wall',
compiler_cxx='g++ -mno-cygwin -O -Wall',
linker_exe='gcc -mno-cygwin',
linker_so='%s -mno-cygwin %s %s'
% (self.linker_dll, shared_option,
entry_point))
to this:
self.set_executables(compiler='gcc -O -Wall',
compiler_so='gcc -mdll -O -Wall',
compiler_cxx='g++ -O -Wall',
linker_exe='gcc',
linker_so='%s %s %s'
% (self.linker_dll, shared_option,
entry_point))

I found the answer here, LDSHARED is the variable I need.
The full command would be like this
CC=gcc LDSHARED=gcc -pthread -shared python setup.py build

Related

pip3 install jupyterlab fail on WSL2.0 under windows 10 arm64

Ubuntu 20.04 on WSL 2.0 under windows 10 ARM64 (Surface Pro X with WSL2.0).
pip3 install jupyterlab // failure
Building wheels for collected packages: argon2-cffi
Building wheel for argon2-cffi (PEP 517) ... error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3.8 /usr/local/lib/python3.8/dist-packages/pip/_vendor/pep517/in_process/_in_process.py build_wheel /tmp/tmp5k32hshp
cwd: /tmp/pip-install-jo5pljfy/argon2-cffi_f65af512bd344c9b956794545e86c839
Complete output (39 lines):
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-aarch64-3.8
creating build/lib.linux-aarch64-3.8/argon2
copying src/argon2/__main__.py -> build/lib.linux-aarch64-3.8/argon2
copying src/argon2/exceptions.py -> build/lib.linux-aarch64-3.8/argon2
copying src/argon2/_password_hasher.py -> build/lib.linux-aarch64-3.8/argon2
copying src/argon2/_ffi_build.py -> build/lib.linux-aarch64-3.8/argon2
copying src/argon2/low_level.py -> build/lib.linux-aarch64-3.8/argon2
copying src/argon2/_utils.py -> build/lib.linux-aarch64-3.8/argon2
copying src/argon2/_legacy.py -> build/lib.linux-aarch64-3.8/argon2
copying src/argon2/__init__.py -> build/lib.linux-aarch64-3.8/argon2
running build_clib
building 'argon2' library
creating build/temp.linux-aarch64-3.8
creating build/temp.linux-aarch64-3.8/extras
creating build/temp.linux-aarch64-3.8/extras/libargon2
creating build/temp.linux-aarch64-3.8/extras/libargon2/src
creating build/temp.linux-aarch64-3.8/extras/libargon2/src/blake2
aarch64-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 -Iextras/libargon2/src/../include -Iextras/libargon2/src/blake2 -c extras/libargon2/src/argon2.c -o build/temp.linux-aarch64-3.8/extras/libargon2/src/argon2.o
aarch64-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 -Iextras/libargon2/src/../include -Iextras/libargon2/src/blake2 -c extras/libargon2/src/blake2/blake2b.c -o build/temp.linux-aarch64-3.8/extras/libargon2/src/blake2/blake2b.o
aarch64-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 -Iextras/libargon2/src/../include -Iextras/libargon2/src/blake2 -c extras/libargon2/src/core.c -o build/temp.linux-aarch64-3.8/extras/libargon2/src/core.o
aarch64-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 -Iextras/libargon2/src/../include -Iextras/libargon2/src/blake2 -c extras/libargon2/src/encoding.c -o build/temp.linux-aarch64-3.8/extras/libargon2/src/encoding.o
aarch64-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 -Iextras/libargon2/src/../include -Iextras/libargon2/src/blake2 -c extras/libargon2/src/ref.c -o build/temp.linux-aarch64-3.8/extras/libargon2/src/ref.o
aarch64-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 -Iextras/libargon2/src/../include -Iextras/libargon2/src/blake2 -c extras/libargon2/src/thread.c -o build/temp.linux-aarch64-3.8/extras/libargon2/src/thread.o
aarch64-linux-gnu-gcc-ar rcs build/temp.linux-aarch64-3.8/libargon2.a build/temp.linux-aarch64-3.8/extras/libargon2/src/argon2.o build/temp.linux-aarch64-3.8/extras/libargon2/src/blake2/blake2b.o build/temp.linux-aarch64-3.8/extras/libargon2/src/core.o build/temp.linux-aarch64-3.8/extras/libargon2/src/encoding.o build/temp.linux-aar aarch64-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 -Iextras/libargon2/include -I/usr/include/python3.8 -c build/temp.linux-aarch64-3.8/_ffi.c -o build/temp.linux-aarch64-3.8/build/temp.linux-aarch64-3.8/_ffi.o
build/temp.linux-aarch64-3.8/_ffi.c:50:14: fatal error: pyconfig.h: No such file or directory
50 | # include <pyconfig.h>
| ^~~~~~~~~~~~
compilation terminated.
error: command 'aarch64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for argon2-cffi
Failed to build argon2-cffi
ERROR: Could not build wheels for argon2-cffi which use PEP 517 and cannot be installed directly
How can I build argon2-cffi successfully?
I solved it following these steps:
sudo apt install -y build-essential python3.8-dev // ubuntu 20.04
pip3 install pep517 // or python3.8 -m pip install pep517
pip3 install jupyterlab // successfully

set compile flags when installing Python + C++ project

When pip-installing a Python project with C++ parts,
pip3 install . --verbose --user
the typical compile line will be something like
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/eigen3/ -I/usr/local/include/python3.7 -I/home/nschloe/.local/include/python3.7m -I/usr/include/python3.7m -c src/generate.cpp -o build/temp.linux-x86_64-3.7/src/generate.o
Explicitly setting CFLAGS like
OPT="" CFLAGS="" pip3 install . --verbose --user
results in
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/eigen3/ -I/usr/local/include/python3.7 -I/home/nschloe/.local/include/python3.7m -I/usr/include/python3.7m -c src/generate.cpp -o build/temp.linux-x86_64-3.7/src/generate.o
retaining most of the flags.
Question: Where are all the compiler options set? More specifically: How can I remove -g? (It's eating too much memory.)

Disabling Compiler Optimizations when Building CPython

I've been following along with Philip Guo's excellent series about CPython's internals and have been walking through the interpreter's code with GDB. Unfortunately, GDB seems to skip around quite a bit when I step through the code, executing instructions out of order (a series of assignment operations for example, nothing fancy).
From what I understand, this is because of compiler optimizations. Indeed, CPython's configure file seems to default to -O2. This is shown to be the case when compiling Python 2.7.15 with ./configure and make:
gcc -pthread -c -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I. -IInclude -I./Include -DPy_BUILD_CORE -o Modules/python.o ./Modules/python.c
gcc -pthread -c -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I. -IInclude -I./Include -DPy_BUILD_CORE -o Parser/acceler.o Parser/acceler.c
gcc -pthread -c -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I. -IInclude -I./Include -DPy_BUILD_CORE -o Parser/grammar1.o Parser/grammar1.c
gcc -pthread -c -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I. -IInclude -I./Include -DPy_BUILD_CORE -o Parser/listnode.o Parser/listnode.c
...
I tried fixing this by configuring without optimizations via ./configure CFLAGS="-g -O0" and compiling with make again, which works (note the change from -fno-strict-aliasing -g -O2 to -fno-strict-aliasing -g -O0 on each line):
gcc -pthread -c -fno-strict-aliasing -g -O0 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I. -IInclude -I./Include -DPy_BUILD_CORE -o Modules/python.o ./Modules/python.c
gcc -pthread -c -fno-strict-aliasing -g -O0 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I. -IInclude -I./Include -DPy_BUILD_CORE -o Parser/acceler.o Parser/acceler.c
gcc -pthread -c -fno-strict-aliasing -g -O0 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I. -IInclude -I./Include -DPy_BUILD_CORE -o Parser/grammar1.o Parser/grammar1.c
gcc -pthread -c -fno-strict-aliasing -g -O0 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I. -IInclude -I./Include -DPy_BUILD_CORE -o Parser/listnode.o Parser/listnode.c
...
Unfortunately, GDB still jumps around when I step through the code. For completeness, here's the command I'm running with GDB:
gdb --args ./python test.py
The contents of test.py are just some basic arithmetic and print functions, which isn't really relevant.
My understanding of at least one of these steps must be incomplete. Am I setting the optimization flag incorrectly? Is GDB jumping between instructions due to some other reason? Any advice would be greatly appreciated. Thanks!
tl;dr: You want the configure setting --with-pydebug.
You've got an -O3 on the command line that comes after the -O2, so changing the -O2 to -O0 doesn't do any good; the -O3 still overrides it. You need to figure out where the -O3 is coming from and remove it.
If you look at the generated Makefile, you should see something like this:
# Compiler options
OPT= -DNDEBUG -g -fwrapv -O3 -Wall
# ...
# Avoid assigning CFLAGS, LDFLAGS, etc. so users can use them on the
# command line to append to these values without stomping the pre-set
# values.
PY_CFLAGS= $(BASECFLAGS) $(OPT) $(CONFIGURE_CFLAGS) $(CFLAGS) $(EXTRA_CFLAGS)
You can, of course, just edit the generated Makefile to change the -O3 to -O0. But if you look inside the configure script and Makefile.pre, you can see where this comes from: it's the default value, only replaced in this case:
case $ac_cv_prog_cc_g in
yes)
if test "$Py_DEBUG" = 'true' ; then
# Optimization messes up debuggers, so turn it off for
# debug builds.
if "$CC" -v --help 2>/dev/null |grep -- -Og > /dev/null; then
OPT="-g -Og -Wall"
else
OPT="-g -O0 -Wall"
fi
else
OPT="-g $WRAP -O3 -Wall"
fi
;;
This also sets the right flags for other compilers besides gcc.
However, the main effect of --with-pydebug is to enable Py_DEBUG—which you probably want if you're source-debugging CPython, but it is a separate thing from -O0, which is what you were actually asking about. So, if you want only -O0, as far as I know, the only thing you can do is edit the Makefile (or come up with some complicated set of env variables and configure arguments that tricks it into doing a debug build but then not enabling Py_DEBUG).

Makefile:107: recipe for target '_shtns.so' failed

I am having a problem while trying to compile the shtns library with python support. I do:
./configure --prefix=$HOME/local --enable-python
make
and I get:
(...)
building '_shtns' extension
gcc -march=native -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-lMBuS3/python2.7-2.7.12=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/home/david/.local/lib/python2.7/site-packages/numpy/core/include -I/usr/include/python2.7 -c shtns_numpy_wrap.c -o build/temp.linux-x86_64-2.7/shtns_numpy_wrap.o -fopenmp
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-lMBuS3/python2.7-2.7.12=. -fstack-protector-strong -Wformat -Werror=format-security -L/home/david/local/lib -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-lMBuS3/python2.7-2.7.12=. -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/shtns_numpy_wrap.o sht_init.o sht_fly.o sht_omp.o -L/home/david/local/lib -lfftw3_omp -lfftw3 -lm -o build/lib.linux-x86_64-2.7/_shtns.so -L/home/david/local/lib
/usr/bin/ld: /home/david/local/lib/libfftw3.a(assert.o): relocation R_X86_64_PC32 against symbol `stdout##GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
Makefile:107: recipe for target '_shtns.so' failed
make: *** [_shtns.so] Error 1
I think those are the relevant lines. It suggests to compile using the -fpic flag, but that is already in my CFLAGS environment variable, as you can see in the first gcc line. The problem is with the 'x86_64-linux-gnu-gcc' bit. Any suggestions?

How to install polyglot on Raspberry Pi? - problems with compatibility

I want to install this on my Raspberry Pi 2 (Raspbian):
http://polyglot.readthedocs.org/en/latest/Installation.html
Unfortunately, when I did sudo pip install polyglot I got the following error:
pi#raspberrypi:~ $ sudo pip install -U git+https://github.com/aboSamoor/polyglot.git#master
Downloading/unpacking git+https://github.com/aboSamoor/polyglot.git#master
Cloning https://github.com/aboSamoor/polyglot.git (to master) to /tmp/pip-97dbqD-build
Running setup.py (path:/tmp/pip-97dbqD-build/setup.py) egg_info for package from git+https://github.com/aboSamoor/polyglot.git#master
warning: no previously-included files matching '__pycache__' found under directory '*'
warning: no previously-included files matching '*.py[co]' found under directory '*'
Downloading/unpacking futures>=2.1.6 (from polyglot==15.10.03)
Downloading futures-3.0.5-py2-none-any.whl
Downloading/unpacking PyICU>=1.8 (from polyglot==15.10.03)
Downloading PyICU-1.9.2.tar.gz (175kB): 175kB downloaded
Running setup.py (path:/tmp/pip-build-FkLuG4/PyICU/setup.py) egg_info for package PyICU
Downloading/unpacking pycld2>=0.3 (from polyglot==15.10.03)
Downloading pycld2-0.31.tar.gz (14.3MB): 14.3MB downloaded
Running setup.py (path:/tmp/pip-build-FkLuG4/pycld2/setup.py) egg_info for package pycld2
Requirement already up-to-date: morfessor>=2.0.2a1 in /usr/local/lib/python2.7/dist-packages/Morfessor-2.0.2alpha3-py2.7.egg (from polyglot==15.10.03)
Downloading/unpacking six>=1.7.3 from https://pypi.python.org/packages/py2.py3/s/six/six-1.10.0-py2.py3-none-any.whl#md5=3ab558cf5d4f7a72611d59a81a315dc8 (from polyglot==15.10.03)
Downloading six-1.10.0-py2.py3-none-any.whl
Downloading/unpacking wheel>=0.23.0 from https://pypi.python.org/packages/py2.py3/w/wheel/wheel-0.29.0-py2.py3-none-any.whl#md5=d7db45db5c131af262b8ffccde46a88a (from polyglot==15.10.03)
Downloading wheel-0.29.0-py2.py3-none-any.whl (66kB): 66kB downloaded
Installing collected packages: futures, PyICU, pycld2, six, wheel, polyglot
Running setup.py install for PyICU
building '_icu' extension
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c dateformat.cpp -o build/temp.linux-armv7l-2.7/dateformat.o -DPYICU_VER="1.9.2"
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
In file included from dateformat.cpp:24:0:
common.h:33:20: fatal error: Python.h: No such file or directory
#include <Python.h>
^
compilation terminated.
error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1
Complete output from command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-FkLuG4/PyICU/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-kNR6VT-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build/lib.linux-armv7l-2.7
copying icu.py -> build/lib.linux-armv7l-2.7
copying PyICU.py -> build/lib.linux-armv7l-2.7
copying docs.py -> build/lib.linux-armv7l-2.7
running build_ext
building '_icu' extension
creating build/temp.linux-armv7l-2.7
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c dateformat.cpp -o build/temp.linux-armv7l-2.7/dateformat.o -DPYICU_VER="1.9.2"
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
In file included from dateformat.cpp:24:0:
common.h:33:20: fatal error: Python.h: No such file or directory
#include <Python.h>
^
compilation terminated.
error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1
----------------------------------------
Cleaning up...
Command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-FkLuG4/PyICU/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-kNR6VT-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip-build-FkLuG4/PyICU
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in <module>
load_entry_point('pip==1.5.6', 'console_scripts', 'pip')()
File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 248, in main
return command.main(cmd_args)
File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 161, in main
text = '\n'.join(complete_log)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 42: ordinal not in range(128)
I believe this is a problem with PYCLD2? It is for 64bit system?
How to solve this problem?
#edit
After executing: sudo apt-get install python-dev
I got:
pi#raspberrypi:~ $ sudo pip install polyglot
Requirement already satisfied (use --upgrade to upgrade): polyglot in /usr/local/lib/python2.7/dist-packages/polyglot-15.10.03-py2.7.egg
Requirement already satisfied (use --upgrade to upgrade): futures>=2.1.6 in /usr/local/lib/python2.7/dist-packages (from polyglot)
Downloading/unpacking PyICU>=1.8 (from polyglot)
Downloading PyICU-1.9.2.tar.gz (175kB): 175kB downloaded
Running setup.py (path:/tmp/pip-build-y6_Rht/PyICU/setup.py) egg_info for package PyICU
Downloading/unpacking pycld2>=0.3 (from polyglot)
Downloading pycld2-0.31.tar.gz (14.3MB): 14.3MB downloaded
Running setup.py (path:/tmp/pip-build-y6_Rht/pycld2/setup.py) egg_info for package pycld2
Requirement already satisfied (use --upgrade to upgrade): morfessor>=2.0.2a1 in /usr/local/lib/python2.7/dist-packages/Morfessor-2.0.2alpha3-py2.7.egg (from polyglot)
Requirement already satisfied (use --upgrade to upgrade): six>=1.7.3 in /usr/lib/python2.7/dist-packages (from polyglot)
Requirement already satisfied (use --upgrade to upgrade): wheel>=0.23.0 in /usr/lib/python2.7/dist-packages (from polyglot)
Installing collected packages: PyICU, pycld2
Running setup.py install for PyICU
building '_icu' extension
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c dateformat.cpp -o build/temp.linux-armv7l-2.7/dateformat.o -DPYICU_VER="1.9.2"
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c char.cpp -o build/temp.linux-armv7l-2.7/char.o -DPYICU_VER="1.9.2"
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c errors.cpp -o build/temp.linux-armv7l-2.7/errors.o -DPYICU_VER="1.9.2"
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c numberformat.cpp -o build/temp.linux-armv7l-2.7/numberformat.o -DPYICU_VER="1.9.2"
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c charset.cpp -o build/temp.linux-armv7l-2.7/charset.o -DPYICU_VER="1.9.2"
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c normalizer.cpp -o build/temp.linux-armv7l-2.7/normalizer.o -DPYICU_VER="1.9.2"
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c transliterator.cpp -o build/temp.linux-armv7l-2.7/transliterator.o -DPYICU_VER="1.9.2"
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c unicodeset.cpp -o build/temp.linux-armv7l-2.7/unicodeset.o -DPYICU_VER="1.9.2"
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c shape.cpp -o build/temp.linux-armv7l-2.7/shape.o -DPYICU_VER="1.9.2"
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c collator.cpp -o build/temp.linux-armv7l-2.7/collator.o -DPYICU_VER="1.9.2"
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c _icu.cpp -o build/temp.linux-armv7l-2.7/_icu.o -DPYICU_VER="1.9.2"
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c iterators.cpp -o build/temp.linux-armv7l-2.7/iterators.o -DPYICU_VER="1.9.2"
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c tzinfo.cpp -o build/temp.linux-armv7l-2.7/tzinfo.o -DPYICU_VER="1.9.2"
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c search.cpp -o build/temp.linux-armv7l-2.7/search.o -DPYICU_VER="1.9.2"
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c layoutengine.cpp -o build/temp.linux-armv7l-2.7/layoutengine.o -DPYICU_VER="1.9.2"
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c calendar.cpp -o build/temp.linux-armv7l-2.7/calendar.o -DPYICU_VER="1.9.2"
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c idna.cpp -o build/temp.linux-armv7l-2.7/idna.o -DPYICU_VER="1.9.2"
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c spoof.cpp -o build/temp.linux-armv7l-2.7/spoof.o -DPYICU_VER="1.9.2"
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c common.cpp -o build/temp.linux-armv7l-2.7/common.o -DPYICU_VER="1.9.2"
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
common.cpp: In function ‘void _stopDecode(const void*, UConverterToUnicodeArgs*, const char*, int32_t, UConverterCallbackReason, UErrorCode*)’:
common.cpp:62:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
const int len = length < sizeof(stop->chars) - 1 ? length : sizeof(stop->chars) - 1;
^
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c format.cpp -o build/temp.linux-armv7l-2.7/format.o -DPYICU_VER="1.9.2"
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c regex.cpp -o build/temp.linux-armv7l-2.7/regex.o -DPYICU_VER="1.9.2"
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c locale.cpp -o build/temp.linux-armv7l-2.7/locale.o -DPYICU_VER="1.9.2"
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
locale.cpp: In function ‘int t_locale_init(t_locale*, PyObject*, PyObject*)’:
locale.cpp:323:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (len < sizeof(code))
^
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c bases.cpp -o build/temp.linux-armv7l-2.7/bases.o -DPYICU_VER="1.9.2"
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c script.cpp -o build/temp.linux-armv7l-2.7/script.o -DPYICU_VER="1.9.2"
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
c++ -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wl,-z,relro -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-armv7l-2.7/dateformat.o build/temp.linux-armv7l-2.7/char.o build/temp.linux-armv7l-2.7/errors.o build/temp.linux-armv7l-2.7/numberformat.o build/temp.linux-armv7l-2.7/charset.o build/temp.linux-armv7l-2.7/normalizer.o build/temp.linux-armv7l-2.7/transliterator.o build/temp.linux-armv7l-2.7/unicodeset.o build/temp.linux-armv7l-2.7/shape.o build/temp.linux-armv7l-2.7/collator.o build/temp.linux-armv7l-2.7/_icu.o build/temp.linux-armv7l-2.7/iterators.o build/temp.linux-armv7l-2.7/tzinfo.o build/temp.linux-armv7l-2.7/search.o build/temp.linux-armv7l-2.7/layoutengine.o build/temp.linux-armv7l-2.7/calendar.o build/temp.linux-armv7l-2.7/idna.o build/temp.linux-armv7l-2.7/spoof.o build/temp.linux-armv7l-2.7/common.o build/temp.linux-armv7l-2.7/format.o build/temp.linux-armv7l-2.7/regex.o build/temp.linux-armv7l-2.7/locale.o build/temp.linux-armv7l-2.7/bases.o build/temp.linux-armv7l-2.7/script.o -licui18n -licuuc -licudata -licule -o build/lib.linux-armv7l-2.7/_icu.so
Running setup.py install for pycld2
building 'pycld2._pycld2' extension
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Icld2/internal -Icld2/public -I/usr/include/python2.7 -c cld2/internal/cldutil.cc -o build/temp.linux-armv7l-2.7/cld2/internal/cldutil.o -w -O2 -m64 -fPIC
arm-linux-gnueabihf-gcc: error: unrecognized command line option ‘-m64’
error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1
Complete output from command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-y6_Rht/pycld2/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-pSIInS-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build/lib.linux-armv7l-2.7
creating build/lib.linux-armv7l-2.7/pycld2
copying pycld2/__init__.py -> build/lib.linux-armv7l-2.7/pycld2
running build_ext
building 'pycld2._pycld2' extension
creating build/temp.linux-armv7l-2.7
creating build/temp.linux-armv7l-2.7/cld2
creating build/temp.linux-armv7l-2.7/cld2/internal
creating build/temp.linux-armv7l-2.7/bindings
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Icld2/internal -Icld2/public -I/usr/include/python2.7 -c cld2/internal/cldutil.cc -o build/temp.linux-armv7l-2.7/cld2/internal/cldutil.o -w -O2 -m64 -fPIC
arm-linux-gnueabihf-gcc: error: unrecognized command line option ‘-m64’
error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1
----------------------------------------
Cleaning up...
Command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-y6_Rht/pycld2/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-pSIInS-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip-build-y6_Rht/pycld2
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in <module>
load_entry_point('pip==1.5.6', 'console_scripts', 'pip')()
File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 248, in main
return command.main(cmd_args)
File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 161, in main
text = '\n'.join(complete_log)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 42: ordinal not in range(128)
I managed to solve this problem.
First you need to do is to download polyglot's source code:
git clone https://github.com/aboSamoor/polyglot
Then edit setup.py:
nano polyglot/pycld2/setup.py
Change this line:
extra_compile_args=['-w', '-O2', '-m64', '-fPIC'],
to:
extra_compile_args=['-w', '-O2', '-fPIC'],
Install PYCLD2:
sudo ./setup.py install
Install polyglot:
cd ..
sudo ./setup.py install

Categories