diff --git a/Lib/ctypes/macholib/dyld.py b/Lib/ctypes/macholib/dyld.py --- a/Lib/ctypes/macholib/dyld.py +++ b/Lib/ctypes/macholib/dyld.py @@ -26,6 +26,7 @@ DEFAULT_LIBRARY_FALLBACK = [ os.path.expanduser("~/lib"), + "@PREFIX@/lib", "/usr/local/lib", "/lib", "/usr/lib", diff --git a/Lib/distutils/sysconfig.py b/Lib/distutils/sysconfig.py --- a/Lib/distutils/sysconfig.py +++ b/Lib/distutils/sysconfig.py @@ -177,7 +177,14 @@ newcc = None if 'CC' in os.environ: - cc = os.environ['CC'] + newcc = os.environ['CC'] + # On OS X, if CC is overridden, use that as the default + # command for LDSHARED as well + if (sys.platform == 'darwin' + and 'LDSHARED' not in os.environ + and ldshared.startswith(cc)): + ldshared = newcc + ldshared[len(cc):] + cc = newcc if 'CXX' in os.environ: cxx = os.environ['CXX'] if 'LDSHARED' in os.environ: diff --git a/Lib/platform.py b/Lib/platform.py --- a/Lib/platform.py +++ b/Lib/platform.py @@ -816,6 +816,15 @@ if info is not None: return info + # If that doesn't work fall back to posix.uname + import posix + major,minor,patch=string.split(posix.uname()[2],'.') + release = '%s.%s.%s' %('10',int(major)-4, minor) + if posix.uname()[4]=='Power Macintosh': + machine='PowerPC' + else: + machine='i386' + # If that also doesn't work return the default values return release,versioninfo,machine diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py --- a/Lib/sysconfig.py +++ b/Lib/sysconfig.py @@ -303,12 +303,6 @@ msg = msg + " (%s)" % e.strerror raise IOError(msg) - # On AIX, there are wrong paths to the linker scripts in the Makefile - # -- these paths are relative to the Python source, but when installed - # the scripts are in another directory. - if _PYTHON_BUILD: - vars['LDSHARED'] = vars['BLDSHARED'] - # There's a chicken-and-egg situation on OS X with regards to the # _sysconfigdata module after the changes introduced by #15298: # get_config_vars() is called by get_platform() as part of the diff --git a/Makefile.pre.in b/Makefile.pre.in --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -479,7 +479,7 @@ 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) @LIBTOOL_CRUFT@ -o $@ $(LIBRARY_OBJS) $(SHLIBS) $(LIBC) $(LDLAST) libpython$(VERSION).sl: $(LIBRARY_OBJS) @@ -866,7 +866,7 @@ # Install the interpreter with $(VERSION) affixed # This goes into $(exec_prefix) altbininstall: $(BUILDPYTHON) - @for i in $(BINDIR) $(LIBDIR); \ + @for i in $(BINDIR) $(LIBDIR) $(LIBPL); \ do \ if test ! -d $(DESTDIR)$$i; then \ echo "Creating directory $$i"; \ @@ -879,9 +879,9 @@ if test -n "$(DLLLIBRARY)" ; then \ $(INSTALL_SHARED) $(DLLLIBRARY) $(DESTDIR)$(BINDIR); \ else \ - $(INSTALL_SHARED) $(LDLIBRARY) $(DESTDIR)$(LIBDIR)/$(INSTSONAME); \ + $(INSTALL_SHARED) $(LDLIBRARY) $(DESTDIR)$(LIBPL)/$(INSTSONAME); \ if test $(LDLIBRARY) != $(INSTSONAME); then \ - (cd $(DESTDIR)$(LIBDIR); $(LN) -sf $(INSTSONAME) $(LDLIBRARY)) \ + (cd $(DESTDIR)$(LIBPL); $(LN) -sf $(INSTSONAME) $(LDLIBRARY)) \ fi \ fi; \ else true; \ diff --git a/Misc/python-config.in b/Misc/python-config.in --- a/Misc/python-config.in +++ b/Misc/python-config.in @@ -46,12 +46,10 @@ elif opt in ('--libs', '--ldflags'): libs = getvar('LIBS').split() + getvar('SYSLIBS').split() libs.append('-lpython'+pyver) - # add the prefix/lib/pythonX.Y/config dir, but only if there is no - # shared library in prefix/lib/. + # add the prefix/lib/pythonX.Y/config dir (fink keeps shared + # library there too) if opt == '--ldflags': - if not getvar('Py_ENABLE_SHARED'): - libs.insert(0, '-L' + getvar('LIBPL')) - if not getvar('PYTHONFRAMEWORK'): - libs.extend(getvar('LINKFORSHARED').split()) + libs.insert(0, '-L' + getvar('LIBPL')) + libs.extend(getvar('LINKFORSHARED').split()) print ' '.join(libs) diff --git a/Misc/python.pc.in b/Misc/python.pc.in --- a/Misc/python.pc.in +++ b/Misc/python.pc.in @@ -1,6 +1,6 @@ prefix=@prefix@ exec_prefix=@exec_prefix@ -libdir=@libdir@ +libdir=@libdir@/python@VERSION@/config includedir=@includedir@ Name: Python diff --git a/Modules/dbmmodule.c b/Modules/dbmmodule.c --- a/Modules/dbmmodule.c +++ b/Modules/dbmmodule.c @@ -19,7 +19,7 @@ static char *which_dbm = "GNU gdbm"; /* EMX port of GDBM */ #endif #elif defined(HAVE_GDBM_NDBM_H) -#include +#include static char *which_dbm = "GNU gdbm"; #elif defined(HAVE_GDBM_DASH_NDBM_H) #include diff --git a/configure b/configure --- a/configure +++ b/configure @@ -5377,7 +5377,7 @@ ;; Darwin*) LDLIBRARY='libpython$(VERSION).dylib' - BLDLIBRARY='-L. -lpython$(VERSION)' + BLDLIBRARY="`pwd`/$LDLIBRARY" RUNSHARED='DYLD_LIBRARY_PATH=`pwd`:${DYLD_LIBRARY_PATH}' ;; AIX*) @@ -8071,8 +8071,8 @@ #ARCH_RUN_32BIT="true" fi - LIBTOOL_CRUFT=$LIBTOOL_CRUFT" -lSystem -lSystemStubs -arch_only ${MACOSX_DEFAULT_ARCH}" - LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' + LIBTOOL_CRUFT=$LIBTOOL_CRUFT" -lSystem -lSystemStubs" + LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(BINLIBDEST)/config/$(INSTSONAME)' LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';; esac @@ -8219,20 +8219,8 @@ LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)' fi ;; Darwin/*) - # Use -undefined dynamic_lookup whenever possible (10.3 and later). - # This allows an extension to be used in any Python - - if test ${MACOSX_DEPLOYMENT_TARGET} '>' 10.2 - then - if test "${enable_universalsdk}"; then - LDFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${LDFLAGS}" - fi - LDSHARED='$(CC) -bundle -undefined dynamic_lookup' - LDCXXSHARED='$(CXX) -bundle -undefined dynamic_lookup' - BLDSHARED="$LDSHARED" - else - LDSHARED='$(CC) -bundle' - LDCXXSHARED='$(CXX) -bundle' + LDSHARED='$(CC) $(LDFLAGS) -bundle' + LDCXXSHARED='$(CXX) $(LDFLAGS) -bundle' if test "$enable_framework" ; then # Link against the framework. All externals should be defined. BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' @@ -8240,11 +8228,10 @@ LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' else # No framework, use the Python app as bundle-loader - BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)' - LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)' - LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)' + BLDSHARED="$LDSHARED "'$(BLDLIBRARY)' + LDSHARED="$LDSHARED "'-L$(BINLIBDEST)/config -lpython$(VERSION)' + LDCXXSHARED="$LDCXXSHARED "'-L$(BINLIBDEST)/config -lpython$(VERSION)' fi - fi ;; Linux*|GNU*|QNX*) LDSHARED='$(CC) -shared' @@ -8634,7 +8621,7 @@ if test "x$ac_cv_lib_intl_textdomain" = xyes; then : $as_echo "#define WITH_LIBINTL 1" >>confdefs.h - +LIBS="-lintl $LIBS" fi @@ -14394,7 +14381,7 @@ if test $ac_sys_system = Darwin then - LIBS="$LIBS -framework CoreFoundation" + LIBS="$LIBS -Wl,-framework,CoreFoundation" fi diff --git a/setup.py b/setup.py --- a/setup.py +++ b/setup.py @@ -264,13 +264,17 @@ longest, g) if missing: + num_missing=len(missing) print print ("Python build finished, but the necessary bits to build " "these modules were not found:") print_three_column(missing) print ("To find the necessary bits, look in setup.py in" " detect_modules() for the module's name.") + print ("(Fink package build should have 5 missing)") print + if num_missing != 5: + sys.exit(1) if self.failed: failed = self.failed[:] @@ -278,6 +282,7 @@ print "Failed to build these modules:" print_three_column(failed) print + sys.exit(1) def build_extension(self, ext): @@ -437,10 +442,8 @@ def detect_modules(self): # Ensure that /usr/local is always used - add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') - add_dir_to_list(self.compiler.include_dirs, '/usr/local/include') - self.add_gcc_paths() - self.add_multiarch_paths() + add_dir_to_list(self.compiler.library_dirs, '@PREFIX@/lib') + add_dir_to_list(self.compiler.include_dirs, '@PREFIX@/include') # Add paths specified in the environment variables LDFLAGS and # CPPFLAGS for header and library files. @@ -919,53 +922,8 @@ # construct a list of paths to look for the header file in on # top of the normal inc_dirs. db_inc_paths = [ - '/usr/include/db4', - '/usr/local/include/db4', - '/opt/sfw/include/db4', - '/usr/include/db3', - '/usr/local/include/db3', - '/opt/sfw/include/db3', - # Fink defaults (http://fink.sourceforge.net/) - '/sw/include/db4', - '/sw/include/db3', + '@PREFIX@/include/db4' ] - # 4.x minor number specific paths - for x in gen_db_minor_ver_nums(4): - db_inc_paths.append('/usr/include/db4%d' % x) - db_inc_paths.append('/usr/include/db4.%d' % x) - db_inc_paths.append('/usr/local/BerkeleyDB.4.%d/include' % x) - db_inc_paths.append('/usr/local/include/db4%d' % x) - db_inc_paths.append('/pkg/db-4.%d/include' % x) - db_inc_paths.append('/opt/db-4.%d/include' % x) - # MacPorts default (http://www.macports.org/) - db_inc_paths.append('/opt/local/include/db4%d' % x) - # 3.x minor number specific paths - for x in gen_db_minor_ver_nums(3): - db_inc_paths.append('/usr/include/db3%d' % x) - db_inc_paths.append('/usr/local/BerkeleyDB.3.%d/include' % x) - db_inc_paths.append('/usr/local/include/db3%d' % x) - db_inc_paths.append('/pkg/db-3.%d/include' % x) - db_inc_paths.append('/opt/db-3.%d/include' % x) - - if cross_compiling: - db_inc_paths = [] - - # Add some common subdirectories for Sleepycat DB to the list, - # based on the standard include directories. This way DB3/4 gets - # picked up when it is installed in a non-standard prefix and - # the user has added that prefix into inc_dirs. - std_variants = [] - for dn in inc_dirs: - std_variants.append(os.path.join(dn, 'db3')) - std_variants.append(os.path.join(dn, 'db4')) - for x in gen_db_minor_ver_nums(4): - std_variants.append(os.path.join(dn, "db4%d"%x)) - std_variants.append(os.path.join(dn, "db4.%d"%x)) - for x in gen_db_minor_ver_nums(3): - std_variants.append(os.path.join(dn, "db3%d"%x)) - std_variants.append(os.path.join(dn, "db3.%d"%x)) - - db_inc_paths = std_variants + db_inc_paths db_inc_paths = [p for p in db_inc_paths if os.path.exists(p)] db_ver_inc_map = {} @@ -1091,12 +1049,7 @@ # We hunt for #define SQLITE_VERSION "n.n.n" # We need to find >= sqlite version 3.0.8 sqlite_incdir = sqlite_libdir = None - sqlite_inc_paths = [ '/usr/include', - '/usr/include/sqlite', - '/usr/include/sqlite3', - '/usr/local/include', - '/usr/local/include/sqlite', - '/usr/local/include/sqlite3', + sqlite_inc_paths = [ '@PREFIX@/include' ] if cross_compiling: sqlite_inc_paths = [] @@ -1110,7 +1063,7 @@ if host_platform == 'darwin': sysroot = macosx_sdk_root() - for d_ in inc_dirs + sqlite_inc_paths: + for d_ in sqlite_inc_paths: d = d_ if host_platform == 'darwin' and is_macosx_sdk_path(d): d = os.path.join(sysroot, d[1:]) @@ -1142,11 +1095,9 @@ sqlite_dirs_to_check = [ os.path.join(sqlite_incdir, '..', 'lib64'), os.path.join(sqlite_incdir, '..', 'lib'), - os.path.join(sqlite_incdir, '..', '..', 'lib64'), - os.path.join(sqlite_incdir, '..', '..', 'lib'), ] sqlite_libfile = self.compiler.find_library_file( - sqlite_dirs_to_check + lib_dirs, 'sqlite3') + sqlite_dirs_to_check, 'sqlite3') if sqlite_libfile: sqlite_libdir = [os.path.abspath(os.path.dirname(sqlite_libfile))] @@ -1267,7 +1218,7 @@ if self.compiler.find_library_file(lib_dirs, 'gdbm_compat'): gdbm_libs.append('gdbm_compat') - if find_file("gdbm/ndbm.h", inc_dirs, []) is not None: + if find_file("ndbm.h", inc_dirs, []) is not None: print "building dbm using gdbm" dbmext = Extension( 'dbm', ['dbmmodule.c'], @@ -1345,6 +1296,7 @@ panel_library = 'panelw' curses_libs = [curses_library] exts.append( Extension('_curses', ['_cursesmodule.c'], + include_dirs=["@PREFIX@/include/ncursesw"], libraries = curses_libs) ) elif curses_library == 'curses' and host_platform != 'darwin': # OSX has an old Berkeley curses, not good enough for @@ -1365,6 +1317,7 @@ if (module_enabled(exts, '_curses') and self.compiler.find_library_file(lib_dirs, panel_library)): exts.append( Extension('_curses_panel', ['_curses_panel.c'], + include_dirs=["@PREFIX@/include/ncursesw"], libraries = [panel_library] + curses_libs) ) else: missing.append('_curses_panel') @@ -1807,19 +1760,11 @@ def detect_tkinter(self, inc_dirs, lib_dirs): # The _tkinter module. - # Rather than complicate the code below, detecting and building - # AquaTk is a separate method. Only one Tkinter will be built on - # Darwin - either AquaTk, if it is found, or X11 based Tk. - if (host_platform == 'darwin' and - self.detect_tkinter_darwin(inc_dirs, lib_dirs)): - return - # Assume we haven't found any of the libraries or include files # The versions with dots are used on Unix, and the versions without # dots on Windows, for detection by cygwin. tcllib = tklib = tcl_includes = tk_includes = None - for version in ['8.6', '86', '8.5', '85', '8.4', '84', '8.3', '83', - '8.2', '82', '8.1', '81', '8.0', '80']: + for version in ['8.4']: tklib = self.compiler.find_library_file(lib_dirs, 'tk' + version) tcllib = self.compiler.find_library_file(lib_dirs, @@ -2043,7 +1988,8 @@ sources=sources, depends=depends) ext_test = Extension('_ctypes_test', - sources=['_ctypes/_ctypes_test.c']) + sources=['_ctypes/_ctypes_test.c'], + extra_compile_args=['-O0']) self.extensions.extend([ext, ext_test]) if not '--with-system-ffi' in sysconfig.get_config_var("CONFIG_ARGS"):