Hi all,

Is there an appropriate way to facilitate loading the appropriate binary (hence, platform dependent) module based on some information from the python interpreter (e.g. sys.version_info, sys.maxsize, platform.system(), platform.architecture()). Is this maybe even something the community could standardise on?

Right now I put several binaries in various folders and change the generated wrapper file, say my_module.py, accordingly [not adapted for py25 and below, just as an example]:
  # Do not make changes to this file unless you know what you are doing--modify
  # the SWIG interface file instead.

+ # TK: NB: Changes are made to facilitate loading appropriate binary for current platform
  from sys import version_info
  if version_info >= (2,6,0):
+     def get_search_path():
+         import os, platform
+         dn = os.path.dirname(__file__)
+         if os.path.exists(os.path.join(dn, 'lib')):
+             dn = os.path.join(dn, 'lib', platform.system(), platform.architecture()[0])
+         return dn
      def swig_import_helper():
-         from os.path import dirname
          import imp
          fp = None
-             fp, pathname, description = imp.find_module('_my_module', [dirname(__file__)])
+             fp, pathname, description = imp.find_module('_my_module', [get_search_path()])
          except ImportError:
              import _my_module
              return _my_module

The reason for doing so being that I want my users to simply be able to say `import my_module` not having to worry about fiddling with sys.path or convoluting their import logic in another way. And at the same time provide them with a universal module that, for example, can be part git/svn repo with users on different platforms.

Have more people thought about bundling libraries for multiple platforms? Curious to hear your thoughts.

PS: I do realize this is a can worms in terms of python versions, glibc versions, etc.