Skip to content

Commit 201e02b

Browse files
committed
Merge pull request #217 from brunobeltran/building2
BUILDING: pip and pip3 should work sanely
2 parents 0d2f983 + 9bba7c2 commit 201e02b

File tree

4 files changed

+35
-31
lines changed

4 files changed

+35
-31
lines changed

README.md

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,12 @@ Matlab code together (requires ipython > 0.13).
2222
`pymatbridge` can be installed from [PyPI][1]:
2323

2424
```
25-
$ pip install pymatbridge # sudo may be needed
26-
```
27-
28-
`pymatbridge` communicates with Matlab using zeromq. So before installing
29-
pymatbridge you must have [zmq](http://zeromq.org/intro:get-the-software)
30-
library and [pyzmq](http://zeromq.org/bindings:python) installed on your
31-
machine. These can be installed using
32-
33-
```
34-
$ pip install pyzmq
35-
```
36-
You will also need [Numpy](http://www.numpy.org/), which can be installed
37-
using:
38-
39-
```
40-
$ pip install numpy
25+
$ pip install pymatbridge
4126
```
4227

4328
If you intend to use the Matlab magic extension, you'll also need
4429
[IPython](http://ipython.org/install.html).
4530

46-
Note thatIPython notebooks also depend on `pyzmq` so if you have IPython notebooks
47-
installed, you likely have `pyzmq` already.
48-
4931
Finally, if you want to handle sparse arrays, you will need to install
5032
[Scipy](http://scipy.org/). This can also be installed from PyPI, or using
5133
distributions such as [Anaconda](https://store.continuum.io/cshop/anaconda/) or
@@ -162,6 +144,7 @@ Python and Matlab using the [0MQ](http://zeromq.org/) messaging library. This sh
162144
without any need for compilation on most computers. However, in some cases, you might want
163145
to build the pymatbridge messenger from source. To do so, you will need to follow the instructions below:
164146

147+
165148
### Install zmq library
166149
Please refer to the [official guide](http://zeromq.org/intro:get-the-software) on how to
167150
build and install zmq. On Ubuntu, it is as simple as `sudo apt-get install libzmq3-dev`.

pymatbridge/__init__.py

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
1-
from .pymatbridge import *
2-
from .version import __version__
3-
1+
# We first need to detect if we're being called as part of the setup.py
2+
# procedure itself in a reliable manner.
43
try:
5-
from .publish import *
6-
except ImportError:
7-
pass
4+
__PYMATBRIDGE_SETUP__
5+
except NameError:
6+
__PYMATBRIDGE_SETUP__ = False
87

9-
try:
10-
from .matlab_magic import *
11-
except ImportError:
8+
9+
if __PYMATBRIDGE_SETUP__:
1210
pass
11+
else:
12+
from .pymatbridge import *
13+
from .version import __version__
14+
15+
try:
16+
from .publish import *
17+
except ImportError:
18+
pass
19+
20+
try:
21+
from .matlab_magic import *
22+
except ImportError:
23+
pass

pymatbridge/version.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@
8989
"mexa64/*"]}
9090

9191
REQUIRES = ['pyzmq']
92-
#EXTRAS_REQUIRE = ['numpy', 'scipy', 'ipython']
92+
EXTRAS_REQUIRE = {
93+
'sparse arrays': ["scipy>=0.13.0"],
94+
'ipython': ["ipython>=3.0"],
95+
}
9396

9497
BIN=['scripts/publish-notebook']

setup.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,20 @@
1212
if os.path.exists('MANIFEST'):
1313
os.remove('MANIFEST')
1414

15+
# we need some code from inside the package to build it. use the same hack as
16+
# numpy to selectively import even if we don't have dependencies installed
17+
if sys.version_info[0] >= 3:
18+
import builtins
19+
else:
20+
import __builtin__ as builtins
21+
builtins.__PYMATBRIDGE_SETUP__ = True
1522
# Find the messenger binary file(s) and copy it to /matlab folder.
1623
from pymatbridge.messenger.make import get_messenger_dir
1724
messenger_dir = get_messenger_dir()
1825

1926
for f in glob.glob("./pymatbridge/messenger/%s/messenger.*" % messenger_dir):
2027
shutil.copy(f, "./pymatbridge/matlab")
21-
28+
2229
try:
2330
from setuptools import setup
2431
except ImportError:
@@ -44,7 +51,7 @@
4451
packages=PACKAGES,
4552
package_data=PACKAGE_DATA,
4653
requires=REQUIRES,
47-
#extras_require=EXTRAS_REQUIRE,
54+
extras_require=EXTRAS_REQUIRE,
4855
scripts=BIN
4956
)
5057

0 commit comments

Comments
 (0)