Index: trunk/dports/lang/python26/Portfile
===================================================================
--- trunk/dports/lang/python26/Portfile	(revision 40449)
+++ trunk/dports/lang/python26/Portfile	(revision 40449)
@@ -0,0 +1,139 @@
+# $Id$
+
+PortSystem 1.0
+
+name                    python26
+version                 2.6
+revision                0
+set major               2
+set branch              2.6
+categories              lang
+platforms               darwin
+maintainers             nomaintainer
+
+description             An interpreted, object-oriented programming language
+long_description        Python is an interpreted, interactive, object-oriented \
+                        programming language.
+
+homepage                http://www.python.org/
+master_sites            ${homepage}/ftp/python/${version}/ \
+                        ftp://ftp.python.org/pub/python/${version}/ \
+                        ftp://ftp.fastorama.com/mirrors/ftp.python.org/pub/python/${version}/ \
+                        ftp://ftp.python.jp/pub/python/${version}/
+
+distname                Python-${version}
+extract.suffix          .tgz
+
+checksums               md5     d527a4f3176e253dc821c0376744a428 \
+                        sha1    25a2314f3831b31ea1640e9c4e7362bc94c54ca2 \
+                        rmd160  63e16ec4099948632f278c42d95c7c5356b82330
+
+patchfiles              patch-Makefile.pre.in.diff \
+                        patch-setup.py.diff \
+                        patch-Lib-cgi.py.diff
+
+depends_lib             port:gettext
+
+configure.args          --enable-shared \
+                        --enable-framework=${prefix}/Library/Frameworks \
+                        --mandir=${prefix}/share/man \
+                        --without-readline \
+                        --disable-tk \
+                        --enable-ipv6
+
+use_parallel_build      no
+
+post-patch {
+        reinplace "s|__PREFIX__|${prefix}|g" ${worksrcpath}/Lib/cgi.py
+        reinplace "s|/Applications/MacPython|/Applications/MacPorts/MacPython|g" \
+                Mac/Makefile.in Mac/IDLE/Makefile.in \
+                Mac/IDLE/Makefile.in Mac/Tools/Doc/setup.py \
+                Mac/PythonLauncher/Makefile.in \
+                Mac/BuildScript/build-installer.py
+        reinplace "s|xargs -0 rm -r|xargs -0 rm -rf|g" \
+                Mac/PythonLauncher/Makefile.in
+}
+
+build.target            all libpython${branch}.dylib
+
+# TODO: From python24, do we still need this?
+# Workaround for case-sensitive file systems
+post-build {
+    if { ![file exists ${worksrcpath}/python.exe] } {
+        ln -s python ${worksrcpath}/python.exe
+    }
+}
+
+test.run                yes
+test.target             test
+
+destroot.target         frameworkinstall maninstall
+
+post-destroot {
+        set framewpath ${prefix}/Library/Frameworks/Python.framework
+        set framewdir  ${framewpath}/Versions/${branch}
+
+        foreach dir { lib include } {
+            file rename ${destroot}${framewdir}/${dir}/python${branch} ${destroot}${prefix}/${dir}
+            ln -s ${prefix}/${dir}/python${branch} ${destroot}${framewdir}/${dir}/python${branch}
+        }
+
+        file rename ${destroot}${framewdir}/lib/libpython${branch}.dylib ${destroot}${prefix}/lib
+        ln -s ${prefix}/lib/libpython${branch}.dylib ${destroot}${framewdir}/lib/libpython${branch}.dylib
+
+        file rename ${destroot}${prefix}/share/man/man1/python.1 ${destroot}${prefix}/share/man/man1/python${branch}.1
+
+        # delete symlinks without version suffix, use python_select instead to choose version
+        foreach bin { python pythonw idle pydoc smtpd.py python-config } {
+            file delete ${destroot}${prefix}/bin/${bin}
+        }
+        foreach bin [list python${branch} pythonw${branch} idle${branch} pydoc${branch} smtpd${branch}.py python${branch}-config] {
+            file rename -force ${destroot}${framewdir}/bin/${bin} ${destroot}${prefix}/bin
+            ln -s ${prefix}/bin/${bin} ${destroot}${framewdir}/bin/${bin}
+        }
+
+        foreach dir { Headers Resources Python Versions/Current } {
+            file delete ${destroot}${framewpath}/${dir}
+        }
+
+        # install select file for python_select
+        xinstall -m 755 -d ${destroot}${prefix}/etc/select/python
+        xinstall -m 644 ${filespath}/python[string map {. {}} ${branch}] ${destroot}${prefix}/etc/select/python/
+}
+
+post-activate {
+    ui_msg "\nTo fully complete your installation and make python $branch the default, please run
+\n\tsudo port install python_select \
+\n\tsudo python_select $name\n"
+}
+
+platform darwin 7 {
+        # there is no SystemStubs on 10.3
+        post-patch {
+                reinplace "s|-lSystemStubs||g" \
+                        configure configure.in
+        }
+        post-configure {
+                reinplace "s|-lSystemStubs||g" \
+                        Makefile.pre.in Makefile.pre Makefile
+        }
+        # To avoid GCC incompatibility issue. See http://nxg.me.uk/note/2004/restFP/ (by ebgssth@gmail.com, ticket #13322)
+        configure.ldflags-append "-lcc_dynamic"
+}
+
+platform darwin 8 {
+        # TODO: would configure.compiler be more appropriate?
+        configure.args-append           --with-cxx=/usr/bin/g++-4.0
+}
+
+platform darwin 9 {
+        configure.cppflags-append       -D__DARWIN_UNIX03
+}
+
+variant universal {
+        configure.args-append           --enable-universalsdk
+}
+
+livecheck.check         regex
+livecheck.url           ${homepage}download/releases/
+livecheck.regex         Python (${branch}.\[0-9\]+)
Index: trunk/dports/lang/python26/files/patch-Lib-cgi.py.diff
===================================================================
--- trunk/dports/lang/python26/files/patch-Lib-cgi.py.diff	(revision 40449)
+++ trunk/dports/lang/python26/files/patch-Lib-cgi.py.diff	(revision 40449)
@@ -0,0 +1,18 @@
+--- Lib/cgi.py.orig	2006-08-10 19:41:07.000000000 +0200
++++ Lib/cgi.py	2007-08-21 15:36:54.000000000 +0200
+@@ -1,13 +1,6 @@
+-#! /usr/local/bin/python
++#! __PREFIX__/bin/python2.6
+ 
+-# NOTE: the above "/usr/local/bin/python" is NOT a mistake.  It is
+-# intentionally NOT "/usr/bin/env python".  On many systems
+-# (e.g. Solaris), /usr/local/bin is not in $PATH as passed to CGI
+-# scripts, and /usr/local/bin is the default directory where Python is
+-# installed, so /usr/bin/env would be unable to find python.  Granted,
+-# binary installations by Linux vendors often install Python in
+-# /usr/bin.  So let those vendors patch cgi.py to match their choice
+-# of installation.
++# NOTE: /usr/local/bin/python patched for MacPorts installation
+ 
+ """Support module for CGI (Common Gateway Interface) scripts.
+ 
Index: trunk/dports/lang/python26/files/patch-Makefile.pre.in.diff
===================================================================
--- trunk/dports/lang/python26/files/patch-Makefile.pre.in.diff	(revision 40449)
+++ trunk/dports/lang/python26/files/patch-Makefile.pre.in.diff	(revision 40449)
@@ -0,0 +1,26 @@
+--- Makefile.pre.in.orig	2007-09-29 02:15:52.000000000 +0200
++++ Makefile.pre.in	2007-09-29 02:18:57.000000000 +0200
+@@ -373,6 +373,13 @@
+ libpython$(VERSION).sl: $(LIBRARY_OBJS)
+ 	$(LDSHARED) -o $@ $(LIBRARY_OBJS) $(SHLIBS) $(LIBC) $(LIBM)
+ 
++libpython$(VERSION).dylib: $(LIBRARY)
++	/usr/bin/libtool -o $@ -dynamic $(OTHER_LIBTOOL_OPT) \
++		-all_load $(LIBRARY) -single_module \
++		-install_name $(LIBDIR)/$@ \
++		-compatibility_version $(VERSION) \
++		-current_version $(VERSION) -lSystem -lSystemStubs $(LDFLAGS)
++
+ # This rule is here for OPENSTEP/Rhapsody/MacOSX. It builds a temporary
+ # minimal framework (not including the Lib directory and such) in the current
+ # directory.
+@@ -675,6 +682,9 @@
+ 			fi \
+ 		fi; \
+ 	else	true; \
++	fi; \
++	if test -f libpython$(VERSION).dylib; then \
++		$(INSTALL_SHARED) libpython$(VERSION).dylib $(DESTDIR)$(LIBDIR); \
+ 	fi
+ 
+ # Install the manual page
Index: trunk/dports/lang/python26/files/patch-Misc-setuid-prog.c.diff
===================================================================
--- trunk/dports/lang/python26/files/patch-Misc-setuid-prog.c.diff	(revision 40449)
+++ trunk/dports/lang/python26/files/patch-Misc-setuid-prog.c.diff	(revision 40449)
@@ -0,0 +1,16 @@
+--- Misc/setuid-prog.c.orig	Sat Dec 11 14:29:22 2004
++++ Misc/setuid-prog.c	Sat Dec 11 14:30:13 2004
+@@ -70,6 +70,12 @@
+ #define environ _environ
+ #endif
+ 
++#if defined(__APPLE__)
++#include <sys/time.h>
++#include <crt_externs.h>
++#define environ (*_NSGetEnviron())
++#endif
++
+ /* don't change def_IFS */
+ char def_IFS[] = "IFS= \t\n";
+ /* you may want to change def_PATH, but you should really change it in */
+
Index: trunk/dports/lang/python26/files/patch-Modules-posixmodule.c.diff
===================================================================
--- trunk/dports/lang/python26/files/patch-Modules-posixmodule.c.diff	(revision 40449)
+++ trunk/dports/lang/python26/files/patch-Modules-posixmodule.c.diff	(revision 40449)
@@ -0,0 +1,21 @@
+--- Modules/posixmodule.c.orig	Sat Dec 11 14:27:52 2004
++++ Modules/posixmodule.c	Sat Dec 11 14:28:17 2004
+@@ -339,7 +339,7 @@
+ #endif
+ 
+ /* Return a dictionary corresponding to the POSIX environment table */
+-#ifdef WITH_NEXT_FRAMEWORK
++#ifdef __APPLE__
+ /* On Darwin/MacOSX a shared library or framework has no access to
+ ** environ directly, we must obtain it with _NSGetEnviron().
+ */
+@@ -357,7 +357,7 @@
+ 	d = PyDict_New();
+ 	if (d == NULL)
+ 		return NULL;
+-#ifdef WITH_NEXT_FRAMEWORK
++#ifdef __APPLE__
+ 	if (environ == NULL)
+ 		environ = *_NSGetEnviron();
+ #endif
+
Index: trunk/dports/lang/python26/files/patch-configure.diff
===================================================================
--- trunk/dports/lang/python26/files/patch-configure.diff	(revision 40449)
+++ trunk/dports/lang/python26/files/patch-configure.diff	(revision 40449)
@@ -0,0 +1,28 @@
+--- configure.in.orig	2007-09-28 21:07:32.000000000 +0200
++++ configure.in	2007-09-28 21:08:12.000000000 +0200
+@@ -669,6 +669,11 @@
+ 	  BLDLIBRARY='-L. -lpython$(VERSION)'
+ 	  RUNSHARED=DLL_PATH=`pwd`:${DLL_PATH:-/atheos/sys/libs:/atheos/autolnk/lib}
+ 	  ;;
++	Darwin*)
++	  LDLIBRARY='libpython$(VERSION).dylib'
++	  BLDLIBRARY='-L. -lpython$(VERSION)'
++	  RUNSHARED=DYLD_LIBRARY_PATH="`pwd`:${DYLD_LIBRARY_PATH}"
++	  ;;
+   esac
+ else # shared is disabled
+   case $ac_sys_system in
+--- configure.orig	2007-09-28 21:07:26.000000000 +0200
++++ configure	2007-09-28 21:07:33.000000000 +0200
+@@ -3445,6 +3445,11 @@
+ 	  BLDLIBRARY='-L. -lpython$(VERSION)'
+ 	  RUNSHARED=DLL_PATH=`pwd`:${DLL_PATH:-/atheos/sys/libs:/atheos/autolnk/lib}
+ 	  ;;
++	Darwin*)
++	  LDLIBRARY='libpython$(VERSION).dylib'
++	  BLDLIBRARY='-L. -lpython$(VERSION)'
++	  RUNSHARED=DYLD_LIBRARY_PATH="`pwd`:${DYLD_LIBRARY_PATH}"
++	  ;;
+   esac
+ else # shared is disabled
+   case $ac_sys_system in
Index: trunk/dports/lang/python26/files/patch-setup.py.diff
===================================================================
--- trunk/dports/lang/python26/files/patch-setup.py.diff	(revision 40449)
+++ trunk/dports/lang/python26/files/patch-setup.py.diff	(revision 40449)
@@ -0,0 +1,11 @@
+--- setup.py	2006-08-10 01:42:18.000000000 +0200
++++ setup.py	2007-02-17 16:57:24.000000000 +0100
+@@ -15,7 +15,7 @@
+ from distutils.command.install_lib import install_lib
+ 
+ # This global variable is used to hold the list of modules to be disabled.
+-disabled_module_list = []
++disabled_module_list = ["zlib","_hashlib","_ssl","_bsddb","_sqlite3","_tkinter","bz2","gdbm","readline","_curses","_curses_panel"]
+ 
+ def add_dir_to_list(dirlist, dir):
+     """Add the directory 'dir' to the list 'dirlist' (at the front) if
Index: trunk/dports/lang/python26/files/python26
===================================================================
--- trunk/dports/lang/python26/files/python26	(revision 40449)
+++ trunk/dports/lang/python26/files/python26	(revision 40449)
@@ -0,0 +1,12 @@
+bin/python2.6
+bin/pythonw2.6
+bin/python2.6-config
+bin/idle2.6
+bin/pydoc2.6
+bin/smtpd2.6.py
+-
+share/man/man1/python2.6.1.gz
+Library/Frameworks/Python.framework/Versions/2.6
+Library/Frameworks/Python.framework/Versions/2.6/Headers
+Library/Frameworks/Python.framework/Versions/2.6/Resources
+Library/Frameworks/Python.framework/Versions/2.6/Python
