diff --git a/debian/changelog b/debian/changelog
index a91ea4e27b1efc4f05254b1f7b71af1161f2650d..66c4b6181120a65126c03e7496fdb2ad6e0e105b 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,12 @@
+python-defaults (2.6.6-4) experimental; urgency=low
+
+  * Add python2.7 as a supported Python version.
+  * python-all{,-dev,-dbg}: Depend on the 2.7 packages.
+  * Run the rtinstall script, when 2.7 became a supported version (2.6.6-4)
+    and python2.7 is installed.
+
+ -- Matthias Klose <doko@debian.org>  Sat, 16 Oct 2010 11:58:31 +0200
+
 python-defaults (2.6.6-3) unstable; urgency=low
 
   * Upload to unstable
diff --git a/debian/control b/debian/control
index 38fecbff620ee6119349c42fc2548dc22405058b..b61b9d2c4416030e334089905469e7b2c3569e10 100644
--- a/debian/control
+++ b/debian/control
@@ -110,9 +110,9 @@ Description: debug build of the Python Interpreter (version 2.6)
 
 Package: python-all
 Architecture: all
-Depends: ${misc:Depends}, python (= ${binary:Version}), python2.5 (>= 2.5.5-6), python2.6 (>= 2.6.5-2)
+Depends: ${misc:Depends}, python (= ${binary:Version}), python2.5 (>= 2.5.5-6), python2.6 (>= 2.6.5-2), python2.7 (>= 2.7-7)
 Description: package depending on all supported Python runtime versions
- The package currently depends on python2.5 and python2.6, in the future,
+ The package currently depends on python2.5, python2.6 and python2.7, in the future,
  dependencies on jython (Python for a JVM) and ironpython (Python for Mono)
  may be added.
  .
@@ -121,9 +121,9 @@ Description: package depending on all supported Python runtime versions
 
 Package: python-all-dev
 Architecture: all
-Depends: ${misc:Depends}, python (= ${binary:Version}), python-all (= ${binary:Version}), python-dev (= ${binary:Version}), python2.5-dev (>= 2.5.5-6), python2.6-dev (>= 2.6.5-2)
+Depends: ${misc:Depends}, python (= ${binary:Version}), python-all (= ${binary:Version}), python-dev (= ${binary:Version}), python2.5-dev (>= 2.5.5-6), python2.6-dev (>= 2.6.5-2), python2.7-dev (>= 2.7-7)
 Description: package depending on all supported Python development packages
- The package currently depends on python2.5-dev and python2.6-dev, in the
+ The package currently depends on python2.5-dev, python2.6-dev and python2.7-dev, in the
  future, dependencies on jython (Python for a JVM) and ironpython (Python
  for Mono) may be added.
  .
@@ -134,9 +134,9 @@ Package: python-all-dbg
 Architecture: all
 Section: debug
 Priority: extra
-Depends: ${misc:Depends}, python (= ${binary:Version}), python-all (= ${binary:Version}), python-dbg (= ${binary:Version}), python2.5-dbg (>= 2.5.5-6), python2.6-dbg (>= 2.6.5-2)
+Depends: ${misc:Depends}, python (= ${binary:Version}), python-all (= ${binary:Version}), python-dbg (= ${binary:Version}), python2.5-dbg (>= 2.5.5-6), python2.6-dbg (>= 2.6.5-2), python2.7-dbg (>= 2.7-7)
 Description: package depending on all supported Python debugging packages
- The package currently depends on python2.5-dbg and python2.6-dbg, in the
+ The package currently depends on python2.5-dbg, python2.6-dbg and python2.7-dbg, in the
  future, dependencies on jython (Python for a JVM) and ironpython (Python
  for Mono) may be added.
  .
diff --git a/debian/control.in b/debian/control.in
index a90bdb74cbda2bf15f2508f906370b194831e382..1f2b0c4c929ab59b5dbd89770ed929525e913af8 100644
--- a/debian/control.in
+++ b/debian/control.in
@@ -110,9 +110,9 @@ Description: debug build of the Python Interpreter (version @VER@)
 
 Package: python-all
 Architecture: all
-Depends: ${misc:Depends}, python (= ${binary:Version}), python2.5 (>= 2.5.5-6), python2.6 (>= 2.6.5-2)
+Depends: ${misc:Depends}, python (= ${binary:Version}), python2.5 (>= 2.5.5-6), python2.6 (>= 2.6.5-2), python2.7 (>= 2.7-7)
 Description: package depending on all supported Python runtime versions
- The package currently depends on python2.5 and python2.6, in the future,
+ The package currently depends on python2.5, python2.6 and python2.7, in the future,
  dependencies on jython (Python for a JVM) and ironpython (Python for Mono)
  may be added.
  .
@@ -121,9 +121,9 @@ Description: package depending on all supported Python runtime versions
 
 Package: python-all-dev
 Architecture: all
-Depends: ${misc:Depends}, python (= ${binary:Version}), python-all (= ${binary:Version}), python-dev (= ${binary:Version}), python2.5-dev (>= 2.5.5-6), python2.6-dev (>= 2.6.5-2)
+Depends: ${misc:Depends}, python (= ${binary:Version}), python-all (= ${binary:Version}), python-dev (= ${binary:Version}), python2.5-dev (>= 2.5.5-6), python2.6-dev (>= 2.6.5-2), python2.7-dev (>= 2.7-7)
 Description: package depending on all supported Python development packages
- The package currently depends on python2.5-dev and python2.6-dev, in the
+ The package currently depends on python2.5-dev, python2.6-dev and python2.7-dev, in the
  future, dependencies on jython (Python for a JVM) and ironpython (Python
  for Mono) may be added.
  .
@@ -134,9 +134,9 @@ Package: python-all-dbg
 Architecture: all
 Section: debug
 Priority: extra
-Depends: ${misc:Depends}, python (= ${binary:Version}), python-all (= ${binary:Version}), python-dbg (= ${binary:Version}), python2.5-dbg (>= 2.5.5-6), python2.6-dbg (>= 2.6.5-2)
+Depends: ${misc:Depends}, python (= ${binary:Version}), python-all (= ${binary:Version}), python-dbg (= ${binary:Version}), python2.5-dbg (>= 2.5.5-6), python2.6-dbg (>= 2.6.5-2), python2.7-dbg (>= 2.7-7)
 Description: package depending on all supported Python debugging packages
- The package currently depends on python2.5-dbg and python2.6-dbg, in the
+ The package currently depends on python2.5-dbg, python2.6-dbg and python2.7-dbg, in the
  future, dependencies on jython (Python for a JVM) and ironpython (Python
  for Mono) may be added.
  .
diff --git a/debian/debian_defaults b/debian/debian_defaults
index 60564eb0bc99df5d7e7d25e6fd149c0bab44b889..62f7353ff9fa8500a25c90889097e3eb5d96f4fd 100644
--- a/debian/debian_defaults
+++ b/debian/debian_defaults
@@ -3,7 +3,7 @@
 default-version = python2.6
 
 # all supported python versions
-supported-versions = python2.5, python2.6
+supported-versions = python2.5, python2.6, python2.7
 
 # formerly supported python versions
 old-versions = python2.3, python2.4
diff --git a/debian/python.postinst.in b/debian/python.postinst.in
index 83b5da589ac0f35f736f58f18aeca975cb7ce181..826d9cec5b73f6a360b46d897b7261d60aeb432a 100644
--- a/debian/python.postinst.in
+++ b/debian/python.postinst.in
@@ -18,7 +18,7 @@ case "$1" in
 	# run the rtinstall script, when 2.5 became a supported version
         if [ -x /usr/bin/python2.5 ] && [ -n "$2" ] && dpkg --compare-versions $2 lt 2.4.4-3; then
             if [ "$DEBIAN_FRONTEND" != noninteractive ]; then
-		echo "Linking and byte-compiling packages for runtime @PVER@..."
+		echo "Linking and byte-compiling packages for runtime python2.5..."
             fi
             version=$(dpkg -s python2.5-minimal | awk '/^Version:/ {print $2}')
             for hook in /usr/share/python/runtime.d/*.rtinstall; do
@@ -30,7 +30,7 @@ case "$1" in
 	# run the rtinstall script, when 2.6 became a supported version
         if [ -x /usr/bin/python2.6 ] && [ -n "$2" ] && dpkg --compare-versions $2 lt 2.5.4-6; then
             if [ "$DEBIAN_FRONTEND" != noninteractive ]; then
-		echo "Linking and byte-compiling packages for runtime @PVER@..."
+		echo "Linking and byte-compiling packages for runtime python2.6..."
             fi
             version=$(dpkg -s python2.6-minimal | awk '/^Version:/ {print $2}')
             for hook in /usr/share/python/runtime.d/*.rtinstall; do
@@ -39,6 +39,18 @@ case "$1" in
             done
 	fi
 
+	# run the rtinstall script, when 2.7 became a supported version
+        if [ -x /usr/bin/python2.7 ] && [ -n "$2" ] && dpkg --compare-versions $2 lt 2.6.6-4; then
+            if [ "$DEBIAN_FRONTEND" != noninteractive ]; then
+		echo "Linking and byte-compiling packages for runtime python2.7..."
+            fi
+            version=$(dpkg -s python2.7-minimal | awk '/^Version:/ {print $2}')
+            for hook in /usr/share/python/runtime.d/*.rtinstall; do
+		[ -x $hook ] || continue
+		$hook rtinstall python2.7 "$2" "$version"
+            done
+	fi
+
         if [ -n "$2" ] && dpkg --compare-versions $2 lt 2.6.4-1~; then
 	    oldv=$(echo $2 | sed 's/^\(...\).*/\1/')
 	    if [ "$DEBIAN_FRONTEND" != noninteractive ]; then
@@ -96,7 +108,22 @@ case "$1" in
 		$hook rtinstall python2.6 "$oldversion" "$newversion"
 	    done
 	fi
-	rm -f /var/lib/python/python2.5_already_installed
+	rm -f /var/lib/python/python2.6_already_installed
+
+	if [ -f /var/lib/python/python2.7_already_installed ] \
+	   && [ ! -f /var/lib/python/python2.7_installed ]
+	then
+	    if [ "$DEBIAN_FRONTEND" != noninteractive ]; then
+		echo "Linking and byte-compiling packages for runtime python2.7..."
+	    fi
+	    oldversion=$(cat /var/lib/python/python2.7_already_installed)
+	    newversion=$(dpkg -s python2.7-minimal | awk '/^Version:/ {print $2}')
+	    for hook in /usr/share/python/runtime.d/*.rtinstall; do
+		[ -x $hook ] || continue
+		$hook rtinstall python2.7 "$oldversion" "$newversion"
+	    done
+	fi
+	rm -f /var/lib/python/python2.7_already_installed
 
 	rmdir --ignore-fail-on-non-empty /var/lib/python 2>/dev/null || true
 esac
diff --git a/debian/python.preinst.in b/debian/python.preinst.in
index 720a6feea7bfead3e2d5b7dc17963ad2224de4c6..47c7290bd3ca918db2e028cdeb79f4431b51ff28 100644
--- a/debian/python.preinst.in
+++ b/debian/python.preinst.in
@@ -46,6 +46,14 @@ case "$1" in
 	    mkdir -p /var/lib/python
 	    echo "$version" > /var/lib/python/python2.6_already_installed
 	fi
+
+	# 2.6.6-4 is the first version, which adds python2.7 as supported
+	# version; need to run an rtinstall python2.7 in the postinst.
+        if dpkg --compare-versions $2 lt 2.6.6-4 && [ -x /usr/bin/python2.7 ]; then
+	    version=$(dpkg -s python2.7-minimal | awk '/^Version:/ {print $2}')
+	    mkdir -p /var/lib/python
+	    echo "$version" > /var/lib/python/python2.7_already_installed
+	fi
 esac
 
 #DEBHELPER#
diff --git a/debpython/version.py b/debpython/version.py
index 45792de517be663857212c1c4c2027e6baff7851..c7eda6d1db801e376f2c1ef894bb71ac4a61dbd1 100644
--- a/debpython/version.py
+++ b/debpython/version.py
@@ -23,7 +23,7 @@ import re
 from os.path import exists
 from types import GeneratorType
 
-SUPPORTED = [(2, 5), (2, 6)]
+SUPPORTED = [(2, 5), (2, 6), (2, 7)]
 DEFAULT = (2, 6)
 RANGE_PATTERN = r'(-)?(\d\.\d+)(?:(-)(\d\.\d+)?)?'
 RANGE_RE = re.compile(RANGE_PATTERN)