From d62a6a72ed65e5906dba3ab77a84bcc504fbff4f Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Tue, 7 Jun 2011 23:38:01 -0400 Subject: [PATCH] First pass at upgrading to EAPI 3. --- g_pypi/ebuild.py | 36 +++++++++++++++++++++++++++++++++++- g_pypi/ebuild.tmpl | 15 +++++++++++++-- 2 files changed, 48 insertions(+), 3 deletions(-) diff --git a/g_pypi/ebuild.py b/g_pypi/ebuild.py index 151d984..b33f8f3 100755 --- a/g_pypi/ebuild.py +++ b/g_pypi/ebuild.py @@ -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: diff --git a/g_pypi/ebuild.tmpl b/g_pypi/ebuild.tmpl index 34c112b..26243e7 100644 --- a/g_pypi/ebuild.tmpl +++ b/g_pypi/ebuild.tmpl @@ -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 -- 2.26.2