old_contents: import ctypes
  import numpy as np
  import os
  
  __all__ = ['square']
  
  lib = ctypes.cdll.LoadLibrary("libfoo.so")
  lib.square.restype = ctypes.c_int
  lib.square.argtypes = [ctypes.c_int]
  
  
  def square(value):
      """
      Parameters
      ----------
      value: int
  
      Returns
      --------
      value square
      """
      return lib.square(value)
  
  
new_contents: import ctypes
  import numpy as np
  import os
  import sys
  
  __all__ = ['square']
  
  _path = os.path.dirname(__file__)
  
  libname = None
  if sys.platform.startswith('linux'):
  	libname = 'libfoo.so'
  elif sys.platform == 'darwin':
  	libname = 'libfoo.dylib'
  elif sys.platform.startswith('win'):
  	libname = 'foo.dll'
  if libname ==None:
  	print("Unknow platform", sys.platform) 
  	
  else:
  	lib = ctypes.CDLL(libname)
  
  	lib.square.restype = ctypes.c_int
  	lib.square.argtypes = [ctypes.c_int]
  
  
  	def square(value):
  		"""
  		Parameters
  		----------
  		value: int
  
  		Returns
  		--------
  		value square
  		"""
  		return lib.square(value)
  
subject: Change to cmake to 3.4 and test sys.platform to choose lib extension to resolve import error on MacOSX