Hi, Python's build system (at least for 2.6.6) is not 32/64-bit aware in the sense that it always uses "lib" as the default lib/modules/config path.
This patch handles this "problem" through the libdir configure variable. For example: --libdir=\${prefix}/lib64 --libdir=\${prefix}/lib This also changes the builtin paths that Python uses to look for lib/modules depending on what's set in the build.
Index: Python-2.6.6/Makefile.pre.in =================================================================== --- Python-2.6.6.orig/Makefile.pre.in +++ Python-2.6.6/Makefile.pre.in @@ -91,7 +91,8 @@ LIBDIR= @libdir@ MANDIR= @mandir@ INCLUDEDIR= @includedir@ CONFINCLUDEDIR= $(exec_prefix)/include -SCRIPTDIR= $(prefix)/lib +SCRIPTDIR= @libdir@ +LIB= $(shell echo $(LIBDIR) | egrep -o "\/lib$$|\/lib64$$" | sed "s/\///g") # Detailed destination directories BINLIBDEST= $(LIBDIR)/python$(VERSION) @@ -419,7 +420,7 @@ libpython$(VERSION).so: $(LIBRARY_OBJS) fi libpython$(VERSION).dylib: $(LIBRARY_OBJS) - $(CC) -dynamiclib -Wl,-single_module $(LDFLAGS) -undefined dynamic_lookup -Wl,-install_name,$(prefix)/lib/libpython$(VERSION).dylib -Wl,-compatibility_version,$(VERSION) -Wl,-current_version,$(VERSION) -o $@ $(LIBRARY_OBJS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST); \ + $(CC) -dynamiclib -Wl,-single_module $(LDFLAGS) -undefined dynamic_lookup -Wl,-install_name,$(LIBDIR)/libpython$(VERSION).dylib -Wl,-compatibility_version,$(VERSION) -Wl,-current_version,$(VERSION) -o $@ $(LIBRARY_OBJS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST); \ libpython$(VERSION).sl: $(LIBRARY_OBJS) @@ -507,6 +508,7 @@ Modules/getpath.o: $(srcdir)/Modules/get $(CC) -c $(PY_CFLAGS) -DPYTHONPATH='"$(PYTHONPATH)"' \ -DPREFIX='"$(prefix)"' \ -DEXEC_PREFIX='"$(exec_prefix)"' \ + -DLIBDIR='"$(LIB)"' \ -DVERSION='"$(VERSION)"' \ -DVPATH='"$(VPATH)"' \ -o $@ $(srcdir)/Modules/getpath.c @@ -514,7 +516,6 @@ Modules/getpath.o: $(srcdir)/Modules/get Modules/python.o: $(srcdir)/Modules/python.c $(MAINCC) -c $(PY_CFLAGS) -o $@ $(srcdir)/Modules/python.c - $(GRAMMAR_H) $(GRAMMAR_C): $(PGEN) $(GRAMMAR_INPUT) -...@$(INSTALL) -d Include -$(PGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C) @@ -1050,8 +1051,8 @@ frameworkinstallstructure: $(LDLIBRARY) # Install a number of symlinks to keep software that expects a normal unix # install (which includes python-config) happy. frameworkinstallmaclib: - ln -fs "../../../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(prefix)/lib/python$(VERSION)/config/libpython$(VERSION).a" - ln -fs "../../../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(prefix)/lib/python$(VERSION)/config/libpython$(VERSION).dylib" + ln -fs "../../../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(LIBDIR)/python$(VERSION)/config/libpython$(VERSION).a" + ln -fs "../../../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(LIBDIR)/python$(VERSION)/config/libpython$(VERSION).dylib" cd Mac && $(MAKE) installmacsubtree DESTDIR="$(DESTDIR)" # This installs the IDE, the Launcher and other apps into /Applications Index: Python-2.6.6/Modules/getpath.c =================================================================== --- Python-2.6.6.orig/Modules/getpath.c +++ Python-2.6.6/Modules/getpath.c @@ -116,9 +116,13 @@ #define EXEC_PREFIX PREFIX #endif +#ifndef LIBDIR +#define LIBDIR lib +#endif + #ifndef PYTHONPATH -#define PYTHONPATH PREFIX "/lib/python" VERSION ":" \ - EXEC_PREFIX "/lib/python" VERSION "/lib-dynload" +#define PYTHONPATH PREFIX "/" LIBDIR "/python" VERSION ":" \ + EXEC_PREFIX "/" LIBDIR "/python" VERSION "/lib-dynload" #endif #ifndef LANDMARK @@ -129,7 +133,7 @@ static char prefix[MAXPATHLEN+1]; static char exec_prefix[MAXPATHLEN+1]; static char progpath[MAXPATHLEN+1]; static char *module_search_path = NULL; -static char lib_python[] = "lib/python" VERSION; +static char lib_python[] = LIBDIR "/python" VERSION; static void reduce(char *dir) @@ -524,7 +528,7 @@ calculate_path(void) } else strncpy(zip_path, PREFIX, MAXPATHLEN); - joinpath(zip_path, "lib/python00.zip"); + joinpath(zip_path, LIBDIR "/python00.zip"); bufsz = strlen(zip_path); /* Replace "00" with version */ zip_path[bufsz - 6] = VERSION[0]; zip_path[bufsz - 5] = VERSION[2]; Index: Python-2.6.6/Lib/distutils/command/build_ext.py =================================================================== --- Python-2.6.6.orig/Lib/distutils/command/build_ext.py +++ Python-2.6.6/Lib/distutils/command/build_ext.py @@ -225,7 +225,8 @@ class build_ext (Command): if sys.platform[:6] == 'cygwin' or sys.platform[:6] == 'atheos': if sys.executable.startswith(os.path.join(sys.exec_prefix, "bin")): # building third party extensions - self.library_dirs.append(os.path.join(sys.prefix, "lib", + self.library_dirs.append(os.path.join(sys.prefix, + sysconfig.get_config_var("LIBDIR")[len(sys.prefix)+1:], "python" + get_python_version(), "config")) else: @@ -268,7 +269,7 @@ class build_ext (Command): # Finally add the user include and library directories if requested if self.user: user_include = os.path.join(USER_BASE, "include") - user_lib = os.path.join(USER_BASE, "lib") + user_lib = os.path.join(USER_BASE, sysconfig.get_config_var("LIBDIR")[len(sys.prefix)+1:]) if os.path.isdir(user_include): self.include_dirs.append(user_include) if os.path.isdir(user_lib): Index: Python-2.6.6/Lib/distutils/sysconfig.py =================================================================== --- Python-2.6.6.orig/Lib/distutils/sysconfig.py +++ Python-2.6.6/Lib/distutils/sysconfig.py @@ -119,8 +119,10 @@ def get_python_lib(plat_specific=0, stan prefix = plat_specific and EXEC_PREFIX or PREFIX if os.name == "posix": - libpython = os.path.join(prefix, - "lib", "python" + get_python_version()) +# libpython = os.path.join(prefix, +# get_config_var("LIBDIR")[len(sys.prefix)+1:], +# "python" + get_python_version()) + libpython = os.path.join(sys.path[1][:len(sys.path[1])-13],"python" + get_python_version()) if standard_lib: return libpython else: Index: Python-2.6.6/Lib/pydoc.py =================================================================== --- Python-2.6.6.orig/Lib/pydoc.py +++ Python-2.6.6/Lib/pydoc.py @@ -341,6 +341,7 @@ class Doc: def getdocloc(self, object): """Return the location of module docs or None""" + from distutils.sysconfig import get_config_var try: file = inspect.getabsfile(object) @@ -349,7 +350,7 @@ class Doc: docloc = os.environ.get("PYTHONDOCS", "http://docs.python.org/library") - basedir = os.path.join(sys.exec_prefix, "lib", + basedir = os.path.join(sys.exec_prefix, get_config_var("LIBDIR")[len(sys.prefix)+1:], "python"+sys.version[0:3]) if (isinstance(object, type(os)) and (object.__name__ in ('errno', 'exceptions', 'gc', 'imp', Index: Python-2.6.6/Lib/site.py =================================================================== --- Python-2.6.6.orig/Lib/site.py +++ Python-2.6.6/Lib/site.py @@ -235,6 +235,9 @@ def addusersitepackages(known_paths): # # Don't know what to put here # USER_BASE = '' # USER_SITE = '' + + from distutils.sysconfig import get_config_var + if os.name == "nt": base = os.environ.get("APPDATA") or "~" USER_BASE = env_base if env_base else joinuser(base, "Python") @@ -243,7 +246,7 @@ def addusersitepackages(known_paths): "site-packages") else: USER_BASE = env_base if env_base else joinuser("~", ".local") - USER_SITE = os.path.join(USER_BASE, "lib", + USER_SITE = os.path.join(USER_BASE, get_config_var("LIBDIR")[len(sys.prefix)+1:], "python" + sys.version[:3], "site-packages") @@ -254,6 +257,8 @@ def addusersitepackages(known_paths): def addsitepackages(known_paths): """Add site-packages (and possibly site-python) to sys.path""" + from distutils.sysconfig import get_config_var + sitedirs = [] seen = [] @@ -265,13 +270,13 @@ def addsitepackages(known_paths): if sys.platform in ('os2emx', 'riscos'): sitedirs.append(os.path.join(prefix, "Lib", "site-packages")) elif os.sep == '/': - sitedirs.append(os.path.join(prefix, "lib", + sitedirs.append(os.path.join(prefix, get_config_var("LIBDIR")[len(sys.prefix)+1:], "python" + sys.version[:3], "site-packages")) - sitedirs.append(os.path.join(prefix, "lib", "site-python")) + sitedirs.append(os.path.join(prefix, get_config_var("LIBDIR")[len(sys.prefix)+1:], "site-python")) else: sitedirs.append(prefix) - sitedirs.append(os.path.join(prefix, "lib", "site-packages")) + sitedirs.append(os.path.join(prefix, get_config_var("LIBDIR")[len(sys.prefix)+1:], "site-packages")) if sys.platform == "darwin": # for framework builds *only* we add the standard Apple Index: Python-2.6.6/Lib/trace.py =================================================================== --- Python-2.6.6.orig/Lib/trace.py +++ Python-2.6.6/Lib/trace.py @@ -663,6 +663,7 @@ def _err_exit(msg): def main(argv=None): import getopt + from distutils.sysconfig import get_config_var if argv is None: argv = sys.argv @@ -759,10 +760,10 @@ def main(argv=None): # should I also call expanduser? (after all, could use $HOME) s = s.replace("$prefix", - os.path.join(sys.prefix, "lib", + os.path.join(sys.prefix, get_config_var("LIBDIR")[len(sys.prefix)+1:], "python" + sys.version[:3])) s = s.replace("$exec_prefix", - os.path.join(sys.exec_prefix, "lib", + os.path.join(sys.exec_prefix, get_config_var("LIBDIR")[len(sys.prefix)+1:], "python" + sys.version[:3])) s = os.path.normpath(s) ignore_dirs.append(s)
_______________________________________________ Patches mailing list Patches@python.org http://mail.python.org/mailman/listinfo/patches