Skip to content

Improved MEX Compilation#172

Closed
jjangsangy wants to merge 15 commits intoarokem:masterfrom
jjangsangy:master
Closed

Improved MEX Compilation#172
jjangsangy wants to merge 15 commits intoarokem:masterfrom
jjangsangy:master

Conversation

@jjangsangy
Copy link

Features

  • Autodetect installed MATLAB bin directory with get_matlab_bin() function.
  • messenger is a fully fledged helper module for pymatbridge
    • Meaning you can call code from messenger just like any module.
# From Root Directory
>>> import messenger
>>> messenger.get_matlab_bin()
'/Applications/MATLAB_R2014a.app/bin'
  • messenger module is also a callable application, and is a direct replacement for make.py.
>>> python -m messenger --help

usage: messenger [-h] [--static] {matlab,octave}

positional arguments:
  {matlab,octave}  target to be built

optional arguments:
  -h, --help       show this help message and exit
  --static         staticly link libzmq

etc...

  • Code is more DRY
    • local.cfg files are deprecated. Now only single authoritative config.ini file in root directory.
  • Use get_matlab_env() for inspecting underlying installed matlab architecture.
  • Use fetch_zmq() to download libzmq source code

Still not Implemented

  • Code for comparing against python, host and matlab architectures.
  • Dynamic linking of libzmq headers and library using DYLD_LIBRARY_PATH DYLD_FRAMEWORK_PATH.
  • Updated Documentation

@jjangsangy
Copy link
Author

On first try! Booya!

@blink1073
Copy link
Collaborator

Pretty awesome job @jjangsangy! I'll let @isbadawi chime in since he's a fellow builder.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be cfg.read(config). Can't build Octave because of this.

There are two other places where you read config.ini. You should probably reuse this function everywhere.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also this used to return a dict. The octave path uses % get_config() and this won't work with a ConfigParser instance.

@isbadawi
Copy link
Collaborator

Lots of little nits, but OK overall. I do like the one config file better.

@jjangsangy
Copy link
Author

Ya, thanks a lot for going through and finding all those mistakes. Always nice to get code reviewed!

Went ahead and refactored out all the details.

get_config() now actually returns a dict for the host platform. I just pass that around now instead of having every function re-calculate those values.

@jjangsangy
Copy link
Author

Crap! forgot a comma!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will reintroduce a problem I had running pymatbridge with 32 bit python on 64 bit Windows.
If you are running 32 bit python on 64 bit windows sys.maxsize > 2**32 gives False while platform.machine().endswith('64') returns True.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mmagnuski Thanks for bringing that up!

Planning on dealing with that soon. The issue is that we actually have 3 different architectures.

  1. Operating System Architecture
  2. Python Architecture
  3. Matlab Architecture

I just built get_matlab_env() which will return the MATLAB arch, so now all we have to do is figure out which combinations of these 3 are okay to run under.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, the only one that matters for the mex file is the Matlab Architecture, which must in turn match the ZMQ Architecture.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@blink1073 But using a 64-bit compiled MEX running on a 32-bit Python interpreter is bound to be bad right? I'm not too familiar with the build process for windows so I'll have to go look into this one.

ZMQ Architecture? Or do you mean the version of the ZMQ installation?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My point is that we start Matlab in a subprocess and talk to it over sockets, so it doesn't matter if the architectures match.
There are 64bit and 32bit downloads for ZMQ on Windows, for example.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh I see, that makes sense.

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

Successfully merging this pull request may close these issues.

5 participants