Closed GoogleCodeExporter closed 9 years ago
Several questions.
What is the output of the following commands?
which python
python -c "import sys;print sys.maxsize"
arch -x86_64 python -c "import sys;print sys.maxsize"
I have attached a very simple C extension. Can you trying compiling with Python
2.7 and Python 3? I'd like to see the output of the builds.
What is the origin of the different versions? Are they both included with OSX,
or from python.org, or??
Original comment by casevh
on 1 Mar 2013 at 3:57
Attachments:
1-which python: /opt/local/bin/python
2-python -c "import sys;print sys.maxsize": 9223372036854775807
3-arch -x86_64 python -c "import sys;print sys.maxsize": 9223372036854775807
4-test result:
python setup.py install
running install
running build
running build_ext
building 'case' extension
creating build
creating build/temp.macosx-10.8-intel-2.7
clang -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common
-fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG
-Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -Os -Wall
-Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe
-I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c
case.c -o build/temp.macosx-10.8-intel-2.7/case.o
clang: warning: argument unused during compilation: '-mno-fused-madd'
case.c:7:5: error: use of undeclared identifier 'PyModuleDef_HEAD_INIT'
PyModuleDef_HEAD_INIT,
^
case.c:6:27: error: variable has incomplete type 'struct PyModuleDef'
static struct PyModuleDef case_module = {
^
case.c:6:15: note: forward declaration of 'struct PyModuleDef'
static struct PyModuleDef case_module = {
^
case.c:21:12: warning: implicit declaration of function 'PyModule_Create' is
invalid in C99 [-Wimplicit-function-declaration]
return PyModule_Create(&case_module);
^
1 warning and 2 errors generated.
error: command 'clang' failed with exit status 1
Original comment by Sabx...@gmail.com
on 3 Mar 2013 at 2:22
I have to add that I checked up and import gmpy2 now works, but still warnings
exist in python2.7 and not python3.
Original comment by Sabx...@gmail.com
on 3 Mar 2013 at 2:24
The second output with python3 without any warnings and errors:
python3 setup.py install
running install
running build
running build_ext
building 'case' extension
creating build/temp.macosx-10.8-x86_64-3.3
cc -Wno-unused-result -fno-common -dynamic -DNDEBUG -g -O3 -Wall
-Wstrict-prototypes -I/usr/local/include -I/usr/local/opt/sqlite/include
-I/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/inclu
de/python3.3m -c case.c -o build/temp.macosx-10.8-x86_64-3.3/case.o
creating build/lib.macosx-10.8-x86_64-3.3
cc -bundle -undefined dynamic_lookup -L/usr/local/lib
-L/usr/local/opt/sqlite/lib build/temp.macosx-10.8-x86_64-3.3/case.o -o
build/lib.macosx-10.8-x86_64-3.3/case.so
running install_lib
copying build/lib.macosx-10.8-x86_64-3.3/case.so ->
/usr/local/lib/python3.3/site-packages
running install_egg_info
Writing /usr/local/lib/python3.3/site-packages/case-0.0-py3.3.egg-info
Original comment by Sabx...@gmail.com
on 3 Mar 2013 at 2:29
I've attached a new test extension module that should compile on with both 2.x
and 3.x. The old one was 3.x specific.
When you tried to compile with 2.7, python is found in /opt/local, yet
/opt/local is not listed as one of the include directories (-I). When you
compiled with 3.3, -I/usr/local/include is listed. I'm guessing that "which
python3" will return /usr/local.
I'm guessing that there are two different versions of Python 2.7 on your system
and one of them is using information from the other installation.
Original comment by casevh
on 3 Mar 2013 at 5:31
Attachments:
Thank you very much for your reply. No I get the same for python3:
"which python3": "/usr/local/bin/python3"
Well I try python3 for this new test I get:
python3 setup.py install
running install
running build
running build_ext
building 'case' extension
creating build/temp.macosx-10.8-x86_64-3.3
cc -Wno-unused-result -fno-common -dynamic -DNDEBUG -g -O3 -Wall
-Wstrict-prototypes -I/usr/local/include -I/usr/local/opt/sqlite/include
-I/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/inclu
de/python3.3m -c case.c -o build/temp.macosx-10.8-x86_64-3.3/case.o
creating build/lib.macosx-10.8-x86_64-3.3
cc -bundle -undefined dynamic_lookup -L/usr/local/lib
-L/usr/local/opt/sqlite/lib build/temp.macosx-10.8-x86_64-3.3/case.o -o
build/lib.macosx-10.8-x86_64-3.3/case.so
running install_lib
copying build/lib.macosx-10.8-x86_64-3.3/case.so ->
/usr/local/lib/python3.3/site-packages
running install_egg_info
Removing /usr/local/lib/python3.3/site-packages/case-0.0-py3.3.egg-info
Writing /usr/local/lib/python3.3/site-packages/case-0.0-py3.3.egg-info
Original comment by Sabx...@gmail.com
on 4 Mar 2013 at 2:11
BTW I remember that I had differen python2 versions but I tried to remove them
and only keeping the system python! I might ruined it up as you suggest. Still
trying python gives permission errors thought with sudo I get:
sudo python setup.py install
running install
running build
running build_ext
running install_lib
running install_egg_info
Removing /Library/Python/2.7/site-packages/case-0.0-py2.7.egg-info
Writing /Library/Python/2.7/site-packages/case-0.0-py2.7.egg-info
Original comment by Sabx...@gmail.com
on 4 Mar 2013 at 2:14
Can you start over with a fresh copy of test2.tar.gz, and run the following
commands:
python setup.py build
sudo python setup.py install
And can you send me the output?
Original comment by casevh
on 5 Mar 2013 at 5:47
Here are the outputs:
python setup.py build
running build
running build_ext
building 'case' extension
creating build
creating build/temp.macosx-10.8-intel-2.7
clang -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common
-fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG
-Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -Os -Wall
-Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe
-I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c
case.c -o build/temp.macosx-10.8-intel-2.7/case.o
clang: warning: argument unused during compilation: '-mno-fused-madd'
creating build/lib.macosx-10.8-intel-2.7
clang -bundle -undefined dynamic_lookup -Wl,-F. -arch i386 -arch x86_64
build/temp.macosx-10.8-intel-2.7/case.o -o
build/lib.macosx-10.8-intel-2.7/case.so
--------------------------------------------------
sudo python setup.py install
Password:
running install
running build
running build_ext
running install_lib
copying build/lib.macosx-10.8-intel-2.7/case.so ->
/Library/Python/2.7/site-packages
running install_egg_info
Removing /Library/Python/2.7/site-packages/case-0.0-py2.7.egg-info
Writing /Library/Python/2.7/site-packages/case-0.0-py2.7.egg-info
Original comment by Sabx...@gmail.com
on 6 Mar 2013 at 1:53
Based on the output of the 2.7 compile, it looks like "python" is using the
clang compiler and is compiling a dual-platform (both i386 and x86_64). The 3.3
compile is using 'cc' (which could either be gcc or clang, I'm not sure) but is
only trying to compile a 64-bit version. The gmp, mpfr, and mpc libraries were
compiled with only with x86_64 support.
This article is interesting:
http://stackoverflow.com/questions/5944228/python-build-using-wrong-version-of-g
cc-on-os-x
What is the output when compiling the test extension as follows:
export ARCHFLAGS='-arch x86_64'
python setup.py build --force
I'm trying to remove the -arch i386 option from the build command.
Original comment by casevh
on 6 Mar 2013 at 4:33
I told in my stackoverflow question that I installed gcc4.2 manually beside the
c compiler for xcode! I don't know if such a thing might cause a problem!
So you want me to go through steps Ned Deily provided?
BTW the output is as follows:
python setup.py build --force
running build
running build_ext
building 'case' extension
creating build
creating build/temp.macosx-10.8-x86_64-2.7
clang -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common
-fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG
-Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -Os -Wall
-Wstrict-prototypes -DENABLE_DTRACE -pipe -arch x86_64
-I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c
case.c -o build/temp.macosx-10.8-x86_64-2.7/case.o
clang: warning: argument unused during compilation: '-mno-fused-madd'
creating build/lib.macosx-10.8-x86_64-2.7
clang -bundle -undefined dynamic_lookup -Wl,-F. -arch x86_64
build/temp.macosx-10.8-x86_64-2.7/case.o -o
build/lib.macosx-10.8-x86_64-2.7/case.so
P.S. I found an exisiting python 2.7 installed in applications folder and I
removed it after getting this output!
Original comment by Sabx...@gmail.com
on 7 Mar 2013 at 12:48
Ned Deily's instructions set ARCHFLAGS to build the i386 and x86_64 combined
binary. GMP will only support a pure x86_64 binary. Does setting ARCHFLAGS to
just "-arch x86_64" change anything?
If it doesn't, I'm pretty much out of ideas.
Original comment by casevh
on 7 Mar 2013 at 12:57
This is the output after setting flags:
running build
running build_ext
building 'case' extension
creating build
creating build/temp.macosx-10.8-x86_64-2.7
clang -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common
-fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG
-Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -Os -Wall
-Wstrict-prototypes -DENABLE_DTRACE -pipe -arch x86_64
-I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c
case.c -o build/temp.macosx-10.8-x86_64-2.7/case.o
clang: warning: argument unused during compilation: '-mno-fused-madd'
creating build/lib.macosx-10.8-x86_64-2.7
clang -bundle -undefined dynamic_lookup -Wl,-F. -arch x86_64
build/temp.macosx-10.8-x86_64-2.7/case.o -o
build/lib.macosx-10.8-x86_64-2.7/case.so
Original comment by Sabx...@gmail.com
on 7 Mar 2013 at 1:58
And the install result:
sudo python setup.py install
Password:
running install
running build
running build_ext
building 'case' extension
creating build/temp.macosx-10.8-intel-2.7
clang -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common
-fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG
-Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -Os -Wall
-Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe
-I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c
case.c -o build/temp.macosx-10.8-intel-2.7/case.o
clang: warning: argument unused during compilation: '-mno-fused-madd'
creating build/lib.macosx-10.8-intel-2.7
clang -bundle -undefined dynamic_lookup -Wl,-F. -arch i386 -arch x86_64
build/temp.macosx-10.8-intel-2.7/case.o -o
build/lib.macosx-10.8-intel-2.7/case.so
running install_lib
copying build/lib.macosx-10.8-intel-2.7/case.so ->
/Library/Python/2.7/site-packages
running install_egg_info
Removing /Library/Python/2.7/site-packages/case-0.0-py2.7.egg-info
Writing /Library/Python/2.7/site-packages/case-0.0-py2.7.egg-info
Original comment by Sabx...@gmail.com
on 7 Mar 2013 at 1:59
The output included in your reply #13 behaves as expected: a 64-bit only
version is compiled. The output in #14 implies a combined 32-bit and 64-bit
binary was compiled and then installed.
Did you keep the ARCHFLAGS setting the same before the install command? If you
did, it is likely that sudo did not inherit the new environment variable. You
may need to try the following commands instead:
ARCHFLAGS='-arch x86_64" python setup.py build
sudo ARCHFLAGS='-arch x86_64" python setup.py install
Original comment by casevh
on 7 Mar 2013 at 2:16
I actually set the flags once and then entered the commands. But this time I
but the flag after the sudo as well. So these are the new results:
ARCHFLAGS='-arch x86_64' python setup.py build
running build
running build_ext
building 'case' extension
creating build/temp.macosx-10.8-x86_64-2.7
clang -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common
-fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG
-Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -Os -Wall
-Wstrict-prototypes -DENABLE_DTRACE -pipe -arch x86_64
-I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c
case.c -o build/temp.macosx-10.8-x86_64-2.7/case.o
clang: warning: argument unused during compilation: '-mno-fused-madd'
creating build/lib.macosx-10.8-x86_64-2.7
clang -bundle -undefined dynamic_lookup -Wl,-F. -arch x86_64
build/temp.macosx-10.8-x86_64-2.7/case.o -o
build/lib.macosx-10.8-x86_64-2.7/case.so
sudo ARCHFLAGS='-arch x86_64' python setup.py install
Password:
running install
running build
running build_ext
running install_lib
copying build/lib.macosx-10.8-x86_64-2.7/case.so ->
/Library/Python/2.7/site-packages
running install_egg_info
Removing /Library/Python/2.7/site-packages/case-0.0-py2.7.egg-info
Writing /Library/Python/2.7/site-packages/case-0.0-py2.7.egg-info
which seems to be 64 bit only right?
Original comment by Sabx...@gmail.com
on 9 Mar 2013 at 5:25
The sequence of commands:
ARCHFLAGS='-arch x86_64' python setup.py build
sudo ARCHFLAGS='-arch x86_64' python setup.py install
is creating a 64-bit only library. Can you try those commands with gmpy2?
Original comment by casevh
on 10 Mar 2013 at 5:04
:|
output:
1)
ARCHFLAGS='-arch x86_64' python setup.py build
running build
running build_ext
building 'gmpy2' extension
creating build
creating build/temp.macosx-10.8-x86_64-2.7
creating build/temp.macosx-10.8-x86_64-2.7/src
clang -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common
-fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG
-Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -Os -Wall
-Wstrict-prototypes -DENABLE_DTRACE -pipe -arch x86_64 -DWITHMPFR=1 -DWITHMPC=1
-I/opt/local/include
-I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c
src/gmpy2.c -o build/temp.macosx-10.8-x86_64-2.7/src/gmpy2.o
clang: warning: argument unused during compilation: '-mno-fused-madd'
In file included from src/gmpy2.c:463:
src/gmpy_convert.c:293:41: warning: implicit conversion loses integer precision:
'long' to 'int' [-Wshorten-64-to-32]
if (-1 == mpz_set_str(z, (char*)cp, base)) {
~~~~~~~~~~~ ^~~~
src/gmpy_convert.c:1222:68: warning: implicit conversion loses integer
precision: 'long' to 'int' [-Wshorten-64-to-32]
if (-1 == mpz_set_str(mpq_numref(newob->q), (char*)cp, base)) {
~~~~~~~~~~~ ^~~~
src/gmpy_convert.c:1257:64: warning: implicit conversion loses integer
precision: 'long' to 'int' [-Wshorten-64-to-32]
if (-1 == mpz_set_str(mpq_numref(newob->q), (char*)cp, base)) {
~~~~~~~~~~~ ^~~~
src/gmpy_convert.c:1265:71: warning: implicit conversion loses integer
precision: 'long' to 'int' [-Wshorten-64-to-32]
if (-1 == mpz_set_str(mpq_denref(newob->q), whereslash+1, base)) {
~~~~~~~~~~~ ^~~~
src/gmpy_convert.c:2087:55: warning: implicit conversion loses integer
precision: 'long' to 'int' [-Wshorten-64-to-32]
result->rc = mpfr_strtofr(result->f, cp, &endptr, base,
~~~~~~~~~~~~ ^~~~
src/gmpy_convert.c:2558:66: warning: implicit conversion loses integer
precision: 'long' to 'int' [-Wshorten-64-to-32]
real_rc = mpfr_strtofr(mpc_realref(newob->c), cp, &tempchar, base,
~~~~~~~~~~~~ ^~~~
src/gmpy_convert.c:2573:66: warning: implicit conversion loses integer
precision: 'long' to 'int' [-Wshorten-64-to-32]
imag_rc = mpfr_strtofr(mpc_imagref(newob->c), cp, &tempchar, base,
~~~~~~~~~~~~ ^~~~
In file included from src/gmpy2.c:494:
src/gmpy_mpz.c:117:49: warning: implicit conversion loses integer precision:
'long' to 'int' [-Wshorten-64-to-32]
result = Pympz_To_PyStr((PympzObject*)self, base, 16);
~~~~~~~~~~~~~~ ^~~~
src/gmpy_mpz.c:1901:5: warning: implicit conversion loses integer precision:
'long' to 'int' [-Wshorten-64-to-32]
PARSE_ONE_MPZ_OPT_CLONG(&reps,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/gmpy_args.h:123:20: note: expanded from macro 'PARSE_ONE_MPZ_OPT_CLONG'
*var = clong_From_Integer(PyTuple_GET_ITEM(args, 0)); \
~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from src/gmpy2.c:494:
src/gmpy_mpz.c:1901:5: warning: implicit conversion loses integer precision:
'long' to 'int' [-Wshorten-64-to-32]
PARSE_ONE_MPZ_OPT_CLONG(&reps,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/gmpy_args.h:137:20: note: expanded from macro 'PARSE_ONE_MPZ_OPT_CLONG'
*var = clong_From_Integer(PyTuple_GET_ITEM(args, 1)); \
~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from src/gmpy2.c:495:
src/gmpy_xmpz.c:114:51: warning: implicit conversion loses integer precision:
'long' to 'int' [-Wshorten-64-to-32]
result = Pyxmpz_To_PyStr((PyxmpzObject*)self, base, 0);
~~~~~~~~~~~~~~~ ^~~~
In file included from src/gmpy2.c:500:
src/gmpy_context.c:1076:32: warning: implicit conversion loses integer
precision: 'long' to 'mpfr_rnd_t' [-Wshorten-64-to-32]
self->ctx.mpfr_round = temp;
~ ^~~~
src/gmpy_context.c:1078:32: warning: implicit conversion loses integer
precision: 'long' to 'mpfr_rnd_t' [-Wshorten-64-to-32]
self->ctx.mpfr_round = temp;
~ ^~~~
src/gmpy_context.c:1080:32: warning: implicit conversion loses integer
precision: 'long' to 'mpfr_rnd_t' [-Wshorten-64-to-32]
self->ctx.mpfr_round = temp;
~ ^~~~
src/gmpy_context.c:1082:32: warning: implicit conversion loses integer
precision: 'long' to 'mpfr_rnd_t' [-Wshorten-64-to-32]
self->ctx.mpfr_round = temp;
~ ^~~~
src/gmpy_context.c:1084:32: warning: implicit conversion loses integer
precision: 'long' to 'mpfr_rnd_t' [-Wshorten-64-to-32]
self->ctx.mpfr_round = temp;
~ ^~~~
src/gmpy_context.c:1122:32: warning: implicit conversion loses integer
precision: 'long' to 'mpfr_rnd_t' [-Wshorten-64-to-32]
self->ctx.real_round = temp;
~ ^~~~
src/gmpy_context.c:1153:32: warning: implicit conversion loses integer
precision: 'long' to 'mpfr_rnd_t' [-Wshorten-64-to-32]
self->ctx.imag_round = temp;
~ ^~~~
18 warnings generated.
creating build/lib.macosx-10.8-x86_64-2.7
clang -bundle -undefined dynamic_lookup -Wl,-F. -arch x86_64
build/temp.macosx-10.8-x86_64-2.7/src/gmpy2.o -L/opt/local/lib -lgmp -lmpfr
-lmpc -o build/lib.macosx-10.8-x86_64-2.7/gmpy2.so
2)sudo ARCHFLAGS='-arch x86_64' python setup.py install
running install
running build
running build_ext
running install_lib
copying build/lib.macosx-10.8-x86_64-2.7/gmpy2.so ->
/Library/Python/2.7/site-packages
running install_egg_info
Writing /Library/Python/2.7/site-packages/gmpy2-2.0.0b4-py2.7.egg-info
Original comment by Sabx...@gmail.com
on 11 Mar 2013 at 7:25
I'm fairly certain the warnings listed are benign. I'll try to get them fixed
in the next beta release. You should have a functional gmpy2 installation now.
Original comment by casevh
on 12 Mar 2013 at 6:22
Yes yes sure! As I told you before it was working before but I was not sure it
was without problem or not. Thought this time I didn't get the previos gmpy.so
errors in installation. Thanks you very much indeed.
Original comment by Sabx...@gmail.com
on 12 Mar 2013 at 9:25
I've committed changes that should eliminate those warnings. I should release
b5 fairly soon.
Original comment by casevh
on 13 Mar 2013 at 7:01
Thank you
Original comment by Sabx...@gmail.com
on 14 Mar 2013 at 3:20
Original issue reported on code.google.com by
casevh
on 1 Mar 2013 at 3:49