diff --git a/debian/changelog b/debian/changelog index 0abde32ae0ee376a051795ef41858c7d68293bc4..8a96a5eea7c31f340376cc24d273586b0c0f0dc6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,5 +1,7 @@ python-defaults (2.6.6-11) UNRELEASED; urgency=low + * dh_python2 and pycompile: read /usr/share/python/debian_defaults to get + default Python version and a List of supported Python versions * dh_python2: - fix parsing .pyinstall files (a space between file name and module name is now required) diff --git a/debpython/version.py b/debpython/version.py index cf032f99f5c2348962cfef34491b2bb8978b242d..7a858cb65fc1da3979ef8797bab4716a4a30fbf1 100644 --- a/debpython/version.py +++ b/debpython/version.py @@ -19,15 +19,38 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. +import logging import re -from os.path import exists +from ConfigParser import SafeConfigParser +from os.path import exists, dirname, join from types import GeneratorType +# will be overriden via debian_defaults file few lines later SUPPORTED = [(2, 5), (2, 6), (2, 7)] DEFAULT = (2, 6) + RANGE_PATTERN = r'(-)?(\d\.\d+)(?:(-)(\d\.\d+)?)?' RANGE_RE = re.compile(RANGE_PATTERN) +log = logging.getLogger(__name__) + +# try to read debian_defaults and get a list of supported Python versions and +# the default one from there +_config = SafeConfigParser() +_config.read(['/usr/share/python/debian_defaults', + join(dirname(__file__), '..', 'debian', 'debian_defaults')]) +try: + DEFAULT = tuple(int(i) for i in _config.get('DEFAULT', + 'default-version')[6:].split('.')) +except: + log.exception('cannot read debian_defaults') +try: + SUPPORTED = tuple(tuple(int(j) for j in i.strip()[6:].split('.'))\ + for i in _config.get('DEFAULT', + 'supported-versions').split(',')) +except: + log.exception('cannot read debian_defaults') + def get_requested_versions(vrange=None, available=None): """Return a set of requested and supported Python versions. diff --git a/dh_python2.rst b/dh_python2.rst index 624e8aa2262c8eb8f57d1577f5c96d71e752f11b..05b4dd64d022787c273c20f6540d15323343f814 100644 --- a/dh_python2.rst +++ b/dh_python2.rst @@ -38,7 +38,7 @@ NOTES In order to support more than one Python version in the same binary package, dh_python2 (unlike dh_pycentral and dh_pysupport) creates symlinks to all supported Python versions at build time. It means binNMU (or sourceful upload -in case of architecture independent packages) are required once a list of +in case of architecture independent packages) is required once a list of supported Python version is changed. It's faster and more robust than its competitors, though.