Get M2Crypto for Mac OS X

Recently i have been trying to get saltstack( Great configuration management software for CloudOps, ITOps and DevOps )  up and running on my mac. It is very easy to get started with it on a linux box but on mac it became a nightmare due to its dependancy: M2Crypto. It took a lot of time and i went through many posts, documentation and errors after errors but finally got M2Crypto running.

For M2Crypto to run perfectly you have to go through list of its own requirements:

  1. OpenSSL headers
  2. PSRE ( Pearl Compatible Regular Expressions ) for SWIG
  3. Swig
  4. Finally Build M2Crypto

Befor getting started you must ensure that you have Xcode Developers tools installed.You probably have these installed already, but if not, they’re on your OS install discs, or you can download them from Apple. Once they’re installed, you should have a working C compiler. Test with

  • $ gcc
  • i686-apple-darwin9-gcc-4.0.1: no input files

Now lets start with OpenSSL headers. Grab the latest OpenSSL package from here. Now, unpack and build it. You might want to put the kettle on, this takes a little while. ( Replace x.x.x with current version of the download that you prefer )

  • tar xzf openssl-x.x.x.tar.gz
  • cd openssl-x-x-x
  • ./config --prefix=/usr/local
  • make && make test
  • sudo make install

Now to get Swig ( converter from C, C++ codes to several platforms for example Java, Python … ) we need PCRE first.

Download tar.gz of pcre.The way of installing is very straight forward :

  • tar xzf pcre-x.x.x.tar.gz
  • cd pcre-x-x-x
  • ./configure
  • make
  • sudo make install

Similarly download Swig tar.gz file and follow same procedure again:

  • tar xzf swig-x.x.x.tar.gz
  • cd swig-x-x-x
  • ./configure
  • make
  • sudo make install

OK. All else done time for the real deal.you need to download M2Crypto. Grab the source, and install it as follows:

  • tar xzf M2Crypto-x.x
  • cd M2Crypto-x.x
  • python setup.py build build_ext --openssl=/usr/local
  • sudo python setup.py install build_ext --openssl=/usr/local

Finally to test your installation, simply do the following:

$ python
Python 2.7.6 (r251:54863, Feb 17 2015, 19:35:17) 
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import M2Crypto
>>>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s