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

Install from source creates corrupted python package #38

Closed
breznak opened this issue Aug 31, 2015 · 4 comments
Closed

Install from source creates corrupted python package #38

breznak opened this issue Aug 31, 2015 · 4 comments

Comments

@breznak
Copy link

breznak commented Aug 31, 2015

Hi,
I'm trying to install from source, during compilation everything looks fine, but I get error when I try to import from the produced module.
(Ubuntu 14.04, python 2.7, clean virtualenv):

Install:

mmm@mmm-U2442:~/devel/fastcache$ virtualenv demo
New python executable in demo/bin/python
Installing setuptools, pip...done.
mmm@mmm-U2442:~/devel/fastcache$ source demo/bin/activate
(demo)mmm@mmm-U2442:~/devel/fastcache$ python --version
Python 2.7.6
(demo)mmm@mmm-U2442:~/devel/fastcache$ pip list
argparse (1.2.1)
pip (1.5.4)
setuptools (2.2)
wsgiref (0.1.2)
(demo)mmm@mmm-U2442:~/devel/fastcache$ git pull
Already up-to-date.
(demo)mmm@mmm-U2442:~/devel/fastcache$ python setup.py build
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/fastcache
copying fastcache/__init__.py -> build/lib.linux-x86_64-2.7/fastcache
copying fastcache/benchmark.py -> build/lib.linux-x86_64-2.7/fastcache
creating build/lib.linux-x86_64-2.7/fastcache/tests
copying fastcache/tests/test_thread.py -> build/lib.linux-x86_64-2.7/fastcache/tests
copying fastcache/tests/__init__.py -> build/lib.linux-x86_64-2.7/fastcache/tests
copying fastcache/tests/test_clrucache.py -> build/lib.linux-x86_64-2.7/fastcache/tests
copying fastcache/tests/test_functools.py -> build/lib.linux-x86_64-2.7/fastcache/tests
running build_ext
building 'fastcache._lrucache' extension
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/src
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c src/_lrucache.c -o build/temp.linux-x86_64-2.7/src/_lrucache.o
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 -D_FORTIFY_SOURCE=2 -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/src/_lrucache.o -o build/lib.linux-x86_64-2.7/fastcache/_lrucache.so
(demo)mmm@mmm-U2442:~/devel/fastcache$ echo $?
0
(demo)mmm@mmm-U2442:~/devel/fastcache$ python setup.py install 
running install
running build
running build_py
running build_ext
running install_lib
creating /home/mmm/devel/fastcache/demo/lib/python2.7/site-packages/fastcache
copying build/lib.linux-x86_64-2.7/fastcache/__init__.py -> /home/mmm/devel/fastcache/demo/lib/python2.7/site-packages/fastcache
creating /home/mmm/devel/fastcache/demo/lib/python2.7/site-packages/fastcache/tests
copying build/lib.linux-x86_64-2.7/fastcache/tests/test_thread.py -> /home/mmm/devel/fastcache/demo/lib/python2.7/site-packages/fastcache/tests
copying build/lib.linux-x86_64-2.7/fastcache/tests/__init__.py -> /home/mmm/devel/fastcache/demo/lib/python2.7/site-packages/fastcache/tests
copying build/lib.linux-x86_64-2.7/fastcache/tests/test_clrucache.py -> /home/mmm/devel/fastcache/demo/lib/python2.7/site-packages/fastcache/tests
copying build/lib.linux-x86_64-2.7/fastcache/tests/test_functools.py -> /home/mmm/devel/fastcache/demo/lib/python2.7/site-packages/fastcache/tests
copying build/lib.linux-x86_64-2.7/fastcache/benchmark.py -> /home/mmm/devel/fastcache/demo/lib/python2.7/site-packages/fastcache
copying build/lib.linux-x86_64-2.7/fastcache/_lrucache.so -> /home/mmm/devel/fastcache/demo/lib/python2.7/site-packages/fastcache
byte-compiling /home/mmm/devel/fastcache/demo/lib/python2.7/site-packages/fastcache/__init__.py to __init__.pyc
byte-compiling /home/mmm/devel/fastcache/demo/lib/python2.7/site-packages/fastcache/tests/test_thread.py to test_thread.pyc
byte-compiling /home/mmm/devel/fastcache/demo/lib/python2.7/site-packages/fastcache/tests/__init__.py to __init__.pyc
byte-compiling /home/mmm/devel/fastcache/demo/lib/python2.7/site-packages/fastcache/tests/test_clrucache.py to test_clrucache.pyc
byte-compiling /home/mmm/devel/fastcache/demo/lib/python2.7/site-packages/fastcache/tests/test_functools.py to test_functools.pyc
byte-compiling /home/mmm/devel/fastcache/demo/lib/python2.7/site-packages/fastcache/benchmark.py to benchmark.pyc
running install_egg_info
running egg_info
writing dependency_links to fastcache.egg-info/dependency_links.txt
writing fastcache.egg-info/PKG-INFO
writing top-level names to fastcache.egg-info/top_level.txt
reading manifest file 'fastcache.egg-info/SOURCES.txt'
writing manifest file 'fastcache.egg-info/SOURCES.txt'
Copying fastcache.egg-info to /home/mmm/devel/fastcache/demo/lib/python2.7/site-packages/fastcache-1.0.2-py2.7.egg-info
running install_scripts
(demo)mmm@mmm-U2442:~/devel/fastcache$ pip list
argparse (1.2.1)
fastcache (1.0.2)
pip (1.5.4)
setuptools (2.2)
wsgiref (0.1.2)

Run:

(demo)mmm@mmm-U2442:~/devel/fastcache$ python -c "import fastcache"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "fastcache/__init__.py", line 27, in <module>
    from ._lrucache import clru_cache
ImportError: No module named _lrucache

The package from pip works.
Thanks,

@breznak
Copy link
Author

breznak commented Aug 31, 2015

I noticed my virtualenv comes with rather dated versions of packages, so I've upgraded pip, setuptools, virtualenv to the latest...with no change unfortunately.

@pbrady
Copy link
Owner

pbrady commented Aug 31, 2015

It looks like you may be importing fastcache from the base directory rather than the build/install directory. This works with pure python packages but not with c-extensions. After running setup.py install try something like:

mkdir tmp; cd tmp; python -c "import fastcache"

@breznak
Copy link
Author

breznak commented Aug 31, 2015

Awesome @pbrady ! Yes, the err only occurs when I try to import from the root of the git repo, from any other path it works fine. Closing as resolved, thanks.

@breznak breznak closed this as completed Aug 31, 2015
@pbrady
Copy link
Owner

pbrady commented Sep 1, 2015

No problem. I've done the same thing many things.

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

No branches or pull requests

2 participants