Skip to content

Commit a4cebfe

Browse files
author
mgotz
committed
added conda_requirements.txt for easier installation on conda and added this to the readme.
also automated the detection of the pyqt version, as to avoid the need for a QT_API environment variable if using PyQt5.
1 parent abaa5ea commit a4cebfe

File tree

4 files changed

+58
-27
lines changed

4 files changed

+58
-27
lines changed

README.md

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,28 @@ In addition, there is GUI, which is run from the gui.main.run, with the run.py o
88

99
## Installation
1010

11-
The GUI is built on PyQt4, which can not be specified as a real dependency because it is not on PyPi.
12-
It requires a working Qt4 installation and needs to be installed via system repositories.
13-
Most python instalations should come with it as spyder also uses it, but maybe very recent installations forgo it for the newer PyQt5, which offers more flexible licensing.
14-
Maybe a future version will also support PyQt5 or PySide, but at the moment this only works with PyQt4.
15-
16-
Download and switch to the extracted directory. Then run
11+
The GUI is built on PyQt, PyQt4 and PyQt5 both should work.
12+
However, at least PyQt4 can not be specified as a real dependency because it is not on PyPi.
13+
Therefore, you should take care of installing those beforehand.
14+
Most Python installations should come with one of them installed, as the Spyder IDE also uses it.
15+
16+
If you use conda (probably the best way to go on Windows) it's best if you install the dependencies through conda, before installing EBT_evaluation.
17+
This is because the EBT_evalauation whill use pip to resolve its dependencies and you will end up with a mix of conda and pip packages.
18+
Use
19+
> conda install --yes --file conda_requirements.txt
20+
to install all the conda available packages.
21+
22+
Subesquently, download EBT_avaluation and switch to the extracted directory. Then run
1723
> pip install . --process-dependency-links --allow-all-external
1824
1925
This will trigger a depreciation warning, but there is no other way for external dependencies and it has been depreciated but not removed for several years.
2026
It should install the EBT_evaluation and all its dependencies, including my own modules from github.
21-
In addition it will create a script/executable called *EBT-evaluation*.
27+
If your installation uses pip to manage all of pyhton, i.e. you are on Linux, then this command alone should do it all, no need for the conda_requirements.txt.
28+
29+
If you installed the conda_requirements beforehand this should only pull mg_* modules and the formlayout modules.
30+
If it installs additional stuff through pip than that you may want to uninstall those modules with pip and reinstall them using conda.
31+
32+
In addition the installation will create a script/executable called *EBT-evaluation*.
2233
You can use this script/executable to directly run the GUI, on Linux just call EBT-evaluation from the terminal, on Winows the .exe should be in python-directory/Scripts.
2334

2435
If pip is somehow unavailable
@@ -31,7 +42,8 @@ However, pip is most likely to get all the dependencies correctly figured out.
3142

3243
If none of these work, you can also download the dependencies manually and install them.
3344
Get the PyGUITools and PyDataProcessing repositories from my github and install them using their respective setup.py.
34-
Then install the EBTtools and resolve all other dependencies, primarily those should be PyQt4, matplotlib, scipy and pillow.
35-
The GUI can be run using the creaed *EBT-evaluation* script/executable or using the run.py.
45+
Then install the EBTtools and resolve all other dependencies, primarily those should be PyQt4/5, matplotlib, scipy and pillow.
46+
On Python2.7 also future and configparser.
47+
The GUI can be run using the created *EBT-evaluation* script/executable or using the run.py.
3648

3749
If all fails, copy the mg directories in those repositories into the same directory as the run.py and then it should find what it needs.

conda_requirements.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
matplotlib>=2.0.0
2+
scipy>=0.18.1
3+
numpy>=1.12.1
4+
pillow>=5.0.0
5+
pyqt>=5.0
6+
sip>=4.0.0
7+
future>=0.16.0

ebttools/gui/__init__.py

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,39 @@
1-
#enusre usage of PyQt4 and avoid something using PyQt5 instead
2-
#a perfect, future version would be able to use either PyQt4 or PyQt5
31
import os
4-
#enable compatibility to both pyqt4 and pyqt5 and load the proper modules
5-
_modname = os.environ.setdefault('QT_API', 'pyqt')
6-
assert _modname in ('pyqt', 'pyqt5')
72

3+
defaultAPI = 'pyqt'
4+
5+
#ensure API v2 for pyqt (native python data types) pyqt5 only offers this API
6+
#hopefully setting it for PyQt5 does not cause errors
7+
import sip
8+
API_NAMES = ("QDate", "QDateTime", "QString", "QTextStream", "QTime", "QUrl",
9+
"QVariant")
10+
API_VERSION = 2
11+
for name in API_NAMES:
12+
sip.setapi(name, API_VERSION)
13+
14+
#check whether an environment variable is set to choose pyqt version.
15+
#If not try what is installed and set the default
16+
if not "QT_API" in os.environ:
17+
try:
18+
import PyQt4
19+
defaultAPI = 'pyqt'
20+
except ImportError:
21+
try:
22+
import PyQt5
23+
defaultAPI = 'pyqt5'
24+
except ImportError:
25+
raise ImportError("The EBT GUI needs either PyQt4 or PyQt5 and neither was found")
26+
27+
#set the environment variable and ensure that it was either pyqt or pyqt5
28+
_modname = os.environ.setdefault('QT_API', defaultAPI)
29+
assert _modname in ('pyqt', 'pyqt4', 'pyqt5')
830

931
from matplotlib import use
10-
1132

1233
if os.environ['QT_API'] == 'pyqt5':
1334
use("Qt5Agg", warn=False) #set the matplotlib backend and don't warn if already set
1435

1536
else:
16-
#ensure API v2 for pyqt (native python data types) pyqt5 only offers this
17-
#API, therefore its not needed there
18-
import sip
19-
API_NAMES = ("QDate", "QDateTime", "QString", "QTextStream", "QTime", "QUrl",
20-
"QVariant")
21-
API_VERSION = 2
22-
for name in API_NAMES:
23-
sip.setapi(name, API_VERSION)
24-
25-
2637
use("Qt4Agg", warn=False) #set the matplotlib backend and don't warn if already set
2738

2839

setup.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@ def read(fname):
2929
'scipy',
3030
'numpy',
3131
'pillow',
32+
'configparser;python_version<"3.2"',
3233
'mg_dataprocessing>=1.0.0',
33-
'mg_pyguitools>=1.0.0'],
34+
'mg_pyguitools>=1.1.1'],
3435

35-
dependency_links=["https://github.com/mgotz/PyGUITools/tarball/master#egg=mg_pyguitools-1.0.0",
36+
dependency_links=["https://github.com/mgotz/PyGUITools/tarball/master#egg=mg_pyguitools-1.1.1",
3637
"https://github.com/mgotz/PyDataProcessing/tarball/master#egg=mg_dataprocessing-1.0.0"],
3738

3839
entry_points = {"gui_scripts":["EBT-evaluation = ebttools.gui.main:run"]}

0 commit comments

Comments
 (0)