platform.architecture, __path__, PYTHONPATH, and dist.utils

S

szager

Howdy,

I need to support both 32-bit and 64-bit versions of compiled python
modules that cannot be installed into the default search path of the
python interpreter(s). I use PYTHONPATH to point to the module
installations, but I have a problem: I don't know, a priori, whether
the user will be running a 32-bit or 64-bit python interpreter. So, I
would like to set up a hybrid installation that will be able to load
either version, based on the architecture of the currently-running
interpreter.

** How can I use dist.utils to create a hybrid installation of an
extension module? **

Currently, I'm manually hacking the build results, but my method is
very platform-dependent. It would be nicer to have an automated,
platform-agnostic way to do this.

Here's what I'm doing now:

/path/to/foo/32bit/libfoo.so
/path/to/foo/64bit/libfoo.so

In /path/to/foo/__init__.py:

import os
import platform

# Note that I can't use platform.architecture(),
# because that doesn't work when using embedded python
exe_arch = platform.architecture('/proc/self/exe')

__path__[0] = os.path.join(__path[0]__, exe_arch[0])

from libfoo import *



Thanks in advance,

Stefan Zager
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top