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

Failure to install wheel #8

Closed
jonls opened this issue Sep 2, 2015 · 18 comments
Closed

Failure to install wheel #8

jonls opened this issue Sep 2, 2015 · 18 comments

Comments

@jonls
Copy link
Contributor

jonls commented Sep 2, 2015

I have some trouble installing the package from PyPI since the 1.0.0 release. When I install 1.2.0 on OSX it looks like this:

~. env/bin/activate
(env) ~ → pip install swiglpk
You are using pip version 7.0.3, however version 7.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting swiglpk
Installing collected packages: swiglpk
Successfully installed swiglpk-1.2.0
(env) ~ → python
Python 2.7.10 (default, Aug 28 2015, 12:01:26) 
[GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import swiglpk
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/jon/env/lib/python2.7/site-packages/swiglpk.py", line 118, in <module>
    GLP_MAJOR_VERSION = _swiglpk.GLP_MAJOR_VERSION
AttributeError: 'module' object has no attribute 'GLP_MAJOR_VERSION'
>>>

Same error with 1.1.2 and 1.1.3. When I try to install 1.0.0 the bdist_wheel fails and then pip tries to install. For some reason that works fine. I can also do

(env) ~ → pip install swiglpk --no-cache-dir

and the resulting package works fine. It seems that the difference when using --no-cache-dir is that pip uses the install command of setup.py instead of bdist_wheel. For this reason I suspect that there is something up with the bdist_wheel setup.

@phantomas1234
Copy link
Contributor

Weird, I thought I tested installing the release. Let me try again.

@phantomas1234
Copy link
Contributor

I couldn't reproduce the problem and the error looks a lot like something I tried to fix before I released 1.2.0. So I just made a new release. Can you check if you still have the problem?
I also removed the 1.1.2 and 1.1.3 releases from pypi because they're broken (I forgot to remove them earlier).

Here is what I get:

(swiglpk3.4)megatron-5390:~ niso$ pip install swiglpk
Collecting swiglpk
  Downloading swiglpk-1.2.1.tar.gz
Installing collected packages: swiglpk
  Running setup.py install for swiglpk
Successfully installed swiglpk-1.2.1
You are using pip version 6.0.8, however version 7.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
(swiglpk3.4)megatron-5390:~ niso$ python
Python 3.4.3 (default, Mar 23 2015, 04:19:36) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import swiglpk
>>>

@jonls
Copy link
Contributor Author

jonls commented Sep 8, 2015

I still have the same problem with 1.2.1. I think you are not hitting this issue because you are still using pip 6. The new cache system in pip 7 means that pip install will use bdist_wheel to build a cached wheel. This can be disabled with --no-cache-dir as I mentioned above. It still seems to me that bdist_wheel is broken though.

@phantomas1234
Copy link
Contributor

Hmmm, I tried with --no-cache-dir before. Here is what I get with a newer version of pip.

(cameo3.4)megatron-5390:~ niso$ pip uninstall swiglpk
You are using pip version 7.1.0, however version 7.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Uninstalling swiglpk-1.1.2:
  /Users/niko/.virtualenvs/cameo3.4/lib/python3.4/site-packages/swiglpk.egg-link
Proceed (y/n)? y
  Successfully uninstalled swiglpk-1.1.2
(cameo3.4)megatron-5390:~ niso$ pip uninstall swiglpk
You are using pip version 7.1.0, however version 7.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Cannot uninstall requirement swiglpk, not installed
(cameo3.4)megatron-5390:~ niso$ pip install swiglpk
You are using pip version 7.1.0, however version 7.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting swiglpk
  Using cached swiglpk-1.2.1.tar.gz
Building wheels for collected packages: swiglpk
  Running setup.py bdist_wheel for swiglpk
  Stored in directory: /Users/niko/Library/Caches/pip/wheels/56/4d/d4/481102820ae8d1c9958d7eb5e5ff5108c2f9d6c734a350884a
Successfully built swiglpk
Installing collected packages: swiglpk
Successfully installed swiglpk-1.2.1
(cameo3.4)megatron-5390:~ niso$ python
Python 3.4.3 (default, Mar 23 2015, 04:19:36) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import swiglpk
>>> dir(swiglpk)
['GLP_ASN_MAX', 'GLP_ASN_MIN', 'GLP_ASN_MMP', 'GLP_BF_BG', 'GLP_BF_FT', 'GLP_BF_GR', 'GLP_BR_DTH', 'GLP_BR_FFV', 'GLP_BR_LFV', 'GLP_BR_MFV', 'GLP_BR_PCH', 'GLP_BS', 'GLP_BT_BFS',

Indeed, pip > 7.0.0 seems to use bdist_wheel but I am not hitting your problem. I will try reproduce this on another machine and with your exact pip version. Thank you for your patience.

@jonls
Copy link
Contributor Author

jonls commented Sep 10, 2015

I just noticed that you were using Python 3.4 and not Python 2.7 as I was. In Python 3 the issue seems to go away completely so it appears that it is Python 2 specific. I also tested the install on a Linux box with Python 2.7 and it too results in an error, although a different one:

>>> import swiglpk
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/jon/env/lib/python2.7/site-packages/swiglpk.py", line 120, in <module>
    class glp_prob(_object):
  File "/home/jon/env/lib/python2.7/site-packages/swiglpk.py", line 126, in glp_prob
    __swig_setmethods__["_opaque_prob"] = _swiglpk.glp_prob__opaque_prob_set
AttributeError: 'module' object has no attribute 'glp_prob__opaque_prob_set'

@jonls
Copy link
Contributor Author

jonls commented Sep 14, 2015

@phantomas1234 By the way, you accidentally broke the glp_term_hook when you reverted the change. Part of the code in glpk.i is missing in the latest version.

@phantomas1234
Copy link
Contributor

@jonls Hi, I made a new release and removed all the the shenanigans in setup.py. I hope I was also able to fix the broken glpk.i (sorry for that).

@jonls
Copy link
Contributor Author

jonls commented Sep 15, 2015

Thanks. The problem persists in 1.2.3 on OSX/Python 2 with AttributeError: 'module' object has no attribute 'GLP_MAJOR_VERSION' and on Linux/Python 2 with AttributeError: 'module' object has no attribute 'glp_prob__opaque_prob_set'. Interestingly it now also fails on OSX/Python 3 with the same error. Version 1.2.1 did not fail on Python 3. This is with SWIG 3.0.7 and GLPK 4.48 on OSX, and SWIG 1.3.40 and GLPK 4.54 on Linux. The SWIG on Linux is apparently quite old so I'll try a newer version there. It actually works on Travis CI with SWIG 2 so the error on Linux may just be due to the older version.

@jonls
Copy link
Contributor Author

jonls commented Sep 16, 2015

Ok, so testing again on Linux with SWIG 3.0.7 I now also get AttributeError: 'module' object has no attribute 'GLP_MAJOR_VERSION' instead of the error with glp_prob__opaque_prob_set that appeared with SWIG 1.3.40. Any ideas?

@phantomas1234
Copy link
Contributor

@jonls hmmm, I guess I need to try it on a linux machine (or any machine that is not my dev machine). I would be very surprised though if I get the same error given that I am testing swiglpk on travis-ci. Do you have glpk properly installed? I thought the installation should fail if you don't, but your error looks very similar to an error that I've seen before where the copied glpk.h header file (copied into the same dir as setup.py) would be overwritten with no content and consequently no glpk methods were wrapped by swig. Can you please check that there is an glpk_clean.h file in the dir after you run setup.py that actually contains glpk declarations? In any case, bare with me, I'll try my best to investigate this. Also, I just realized that there are egg files available for linux on pypi. Could that be an issue? Is setup.py run if a package is installed from egg or is python just putting the uncompressed archive(?) into site-packages?

@jonls
Copy link
Contributor Author

jonls commented Sep 18, 2015

Ok, here is the setup that I tried today on the Linux machine (SWIG 3.0.7 and GLPK 4.54): I clone swiglpk from Github then I checkout the 1.2.3 tag. I then do python setup.py bdist_wheel. The glpk_clean.h and glpk_wrap.c are not obviously incorrect (empty or otherwise). Then I take the resulting wheel file and try to install it into a clean virtualenv using

pip install ~/swiglpk/dist/swiglpk-1.2.3-cp27-none-linux_x86_64.whl

Then I open Python and try to import and I end up with the AttributeError as before. Since I can reproduce the error without going to PyPI, I don't think the egg on PyPI is the issue.

I have put a copy of the glpk_clean.h and glpk_wrap.c files here: https://gist.github.com/jonls/e6c0acfe728a5f0df3e1

@phantomas1234
Copy link
Contributor

I was able to reproduce the problem on a lubuntu machine when installing from pypi with pip >= 7.1.2 (no issue on OS X however). Can't reproduce the problem when installing from source via python setup.py bdist_wheel as you suggested. Anyways, I think I am getting closer ...

@phantomas1234
Copy link
Contributor

@jonls Ok, I am back from a long paternity leave. Maybe you have already lost interest in this issue? Congrats on your PLoS CB paper btw! Were you planning to add glpk support to PSAMM by using these bindings? I still can only reproduce the problem (the glp_prob__opaque_prob_set one) when installing from PyPI and not when running python setup.py bdist_wheel and subsequently pip install path/to/swiglpk-....whl like you described. If you want you can get the wheel I generated here. I am curious if you still get the problem. Now, I don't even know where to start with the PyPI issue ... Still no issue on OS X either.
pip install swiglpk --no-cache-dir also does not solve the issue for me (as it did for you at some point).

@phantomas1234
Copy link
Contributor

Ok, I just realized that I also get the "GLP_MAJOR_VERSION" issue on OS X with python 3.5 when installing directly from pypi

@phantomas1234
Copy link
Contributor

This is btw where the original custom build and install commands came from http://stackoverflow.com/questions/12491328/python-distutils-not-include-the-swig-generated-module

@jonls
Copy link
Contributor Author

jonls commented Feb 10, 2016

@phantomas1234 Thanks! I'm still interested in solving this issue and eventually adding support for GLPK in PSAMM. I'll take a look at this again when I have some time.

@phantomas1234
Copy link
Contributor

@jonls I think I fixed the bdist_wheel problem. Motivated by this setup.py I wrote a custom CustomBdistWheel cmdclass (these are by the way necessary to ensure that swig is run before anything else so cannot be avoided ...). Can you install swiglpk==1.2.12 from pypi and confirm that the issues are gone? It would make me so happy since it has started to annoy other people as well biosustain/cameo#46.

@jonls
Copy link
Contributor Author

jonls commented Feb 29, 2016

@phantomas1234 Thanks! This seems to work now on OSX with Python 2.7.

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