First pass at upgrading to EAPI 3. master
authorW. Trevor King <wking@drexel.edu>
Wed, 8 Jun 2011 03:38:01 +0000 (23:38 -0400)
committerW. Trevor King <wking@drexel.edu>
Wed, 8 Jun 2011 03:43:21 +0000 (23:43 -0400)
g_pypi/ebuild.py
g_pypi/ebuild.tmpl

index 151d9845aacb3b735df09f556aed2931f2aee430..b33f8f35fa163c71995d167133b97f9ec03fd047 100755 (executable)
@@ -77,7 +77,9 @@ class Ebuild:
 
         #Variables that will be passed to the Cheetah template
         self.vars = {
-                'need_python': '',
+                'python_depend': '*',
+                'restrict_python_abis': '',
+                'supported_python_versions': '',
                 'python_modname': '',
                 'description': '',
                 'homepage': '',
@@ -188,6 +190,38 @@ class Ebuild:
 
         self.vars['license'] = "%s" % my_license
 
+        self.get_python_depend()
+
+    def get_python_depend(self):
+        """Generate PYTHON_DEPEND and RESTRICT_PYTHON_ABIS strings
+        """
+        possible_versions = [(2, i) for i in range(2, 8)]
+        possible_versions.extend([(3, i) for i in range(3)])
+
+        allowed_versions = []
+        allowed_version_strings = []
+        start = 'Programming Language :: Python ::'
+        for data in self.metadata.get('classifiers', []):
+            if data.startswith(start):
+                version = data[len(start):].strip()
+                allowed_version_strings.append(version)
+                allowed_versions.append(
+                    [int(x) for x in version.split('.')])
+
+        # TODO: also use PEP 345's Requires-Python
+
+        self.logger.info('supported Python versions: %s' %
+                         ', '.join(sorted(allowed_version_strings)))
+        major_versions = set([v[0] for v in allowed_versions])
+        v3 = 3 in major_versions
+        v2 = 2 in major_versions 
+        # HACK!  need an algorithm for determining these
+        self.vars['python_depend'] = '*:2.6'
+        self.vars['restrict_python_abis'] = '3.*'
+        self.vars['supported_python_versions'] = ', '.join(
+            sorted(allowed_version_strings))
+
     def add_warning(self, warning):
         """Add warning to be shown after ebuild is created"""
         if warning not in self.warnings:
index 34c112b916cd495fc2a52cc5dd94655aa1b6ac12..26243e73462b90dd42c8b2bd1e649e4a6d1c7dc2 100644 (file)
@@ -7,9 +7,20 @@
 #for warn in $warnings:
 \# Warning: $warn
 #end for
+
+#end if
+# API of python.eclass in EAPI > 3 not established (see python.eclass)'
+EAPI="3"
+
+# HACK: PYTHON_DEPEND and RESTRICT_PYTHON_ABIS currently hardcoded.
+#if $supported_python_versions
+# This package claims to support the following versions:
+# $supported_python_versions
 #end if
-#if $need_python
-NEED_PYTHON="$need_python"
+PYTHON_DEPEND="$python_depend"
+SUPPORT_PYTHON_ABIS="1"
+#if $restrict_python_abis
+RESTRICT_PYTHON_ABIS="$restrict_python_abis"
 
 #end if
 #if $python_modname