kdavies4 / ModelicaRes

Set up, analyze, and plot Modelica simulations in Python
http://kdavies4.github.io/ModelicaRes/
Other
51 stars 20 forks source link

Installation requires control #6

Closed xogeny closed 10 years ago

xogeny commented 10 years ago

The line

import modelicares # Only to read the version number

Is a problem because this, by itself, tries to load a bunch of dependencies.

There are two ways to approach this:

  1. Add the control package to the path during setup.py
  2. Skip the import and provide the version number some other way.

If you do 1) there are lots of dependencies. Some are listed in the setup.py file (matplotlib, wx and numpy). Of these, wx is not the correct name for the extension you want. You want wxPython (which installs a package named wx, but is not the same as the PyPI listing for wx). But scipy is also a dependency even though it is not listed. The big problem here is that the mechanisms in setup.py don't kick in to load all these things. In other words, since modelicares is imported into setup.py, all the dependencies have to be installed in advance. On the other hand, if the import wasn't there and pip was used to install modelicares from PyPI, all the dependencies could actually be loaded automatically. Even if you load all of those dependencies, you still have the problem that the control package really needs to be installed first (because the external/control/src directory name doesn't match the package name). After all of this, I eventually gave up on this approach.

Taking approach 2 (which simply means commenting out the import line and substituting the version number ("0.8.1", in my case) into the setup.py script worked perfectly and modelicares installed without issue. Of course, this doesn't address the dependency issue (since a local install doesn't pull in all the dependencies). The issue with the dependencies (that wx should be wxPython that scipy is missing) are not addressed. Also, the control package still needs to be installed manually in that case.

One word of advice...the best way to test for these kinds of issues is to use virtualenv to create a pristine "install". These things come out of the woodwork in such cases.

xogeny commented 10 years ago

To be clear, my recommendation is to take approach 2.

kdavies4 commented 10 years ago

Thanks for the advice. I took option 2 via commit dfd3726.

I also added scipy to the list of dependences and changed wx to wxPython. However, I don't think that wxPython will install correctly via pip. On my system (Ubuntu 13.04), I had to manually install the python-wxgtk2.8 and python-wxtools packages.

I'm not sure I followed the issue with control. The setup.py script seems to automatically install it via external/control.

xogeny commented 10 years ago

You are correctly about wxPython. I had the same problem.

Regarding control, I suspect it works if you install it via pip. But if you clone the repo and try to install it (via python setup.py install), then you need to install it manually. At least that is what I recall.

If you can confirm that this installs OK via pip, then go ahead and close this ticket.

kdavies4 commented 10 years ago

It runs with pip in virtualenv. Thanks for your help.