Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

memprof 0.3.4 miscompiles getsize for python3 if the python2 version was built before #12

Closed
JaviMerino opened this issue Aug 31, 2015 · 2 comments
Assignees

Comments

@JaviMerino
Copy link
Contributor

With memprof 0.3.4, if the python2 version is built before the python3 version, cython doesn't rebuild getsize.c so the python3 extension is miscompiled and barfs when imported:

root@tesla:~/memprof-0.3.4# python setup.py build                                                                
running build
running build_py
copying memprof/mp_utils.py -> build/lib.linux-x86_64-2.7/memprof
running build_ext
cythoning memprof/getsize.pyx to memprof/getsize.c
building 'memprof.getsize' extension
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/memprof
x86_64-linux-gnu-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 memprof/getsize.c -o build/temp.linux-x86_64-2.7/memprof/getsize.o
x86_64-linux-gnu-gcc -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-x86_64-2.7/memprof/getsize.o -o build/lib.linux-x86_64-2.7/memprof/getsize.so
running build_scripts
root@tesla:~/memprof-0.3.4# python3 setup.py build
running build
running build_py
copying memprof/mp_utils.py -> build/lib.linux-x86_64-3.4/memprof
running build_ext
skipping 'memprof/getsize.c' Cython extension (up-to-date)
building 'memprof.getsize' extension
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.4m -c memprof/getsize.c -o build/temp.linux-x86_64-3.4/memprof/getsize.o
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,relro -g -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.4/memprof/getsize.o -o build/lib.linux-x86_64-3.4/memprof/getsize.cpython-34m.so
running build_scripts
root@tesla:~/memprof-0.3.4# python3
Python 3.4.3+ (default, Jul 28 2015, 13:17:50) 
[GCC 4.9.3] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import memprof
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/root/memprof-0.3.4/memprof/__init__.py", line 17, in <module>
    from .memprof import *
  File "/root/memprof-0.3.4/memprof/memprof.py", line 25, in <module>
    from .getsize import getSize, isInteresting
  File "memprof/getsize.pyx", line 2, in init memprof.getsize (memprof/getsize.c:1939)
    import types
NameError: name 'file' is not defined

I think the problem is in "skipping 'memprof/getsize.c' Cython extension (up-to-date)". If I remove memprof/getsize.c, then the python3 extension builds fine and I can run it. This breaks the building of the package in Debian, which creates first the python2 version and then the python3 one.

I've asked this question in stack overflow (https://stackoverflow.com/questions/32296637/regenerate-cython-extension-with-distutils).

@jmdana jmdana self-assigned this Aug 31, 2015
@jmdana
Copy link
Owner

jmdana commented Aug 31, 2015

Thanks Javi for your feedback!

I have added a setup.cfg that should do the trick. Please let me know if that works for you.

PS: Each time that I have to deal with distutils I end up going to the code... very appealing.

@JaviMerino
Copy link
Contributor Author

❤️ e520331 made the trick. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants