From 6f409bff4e4f39ff79d589ceba4788e7fabcfc48 Mon Sep 17 00:00:00 2001 From: Jesus Rivero Date: Fri, 1 Aug 2008 01:11:14 +0000 Subject: [PATCH] Fixed g-pypi to replace dots in package name. git-svn-id: http://g-pypi.googlecode.com/svn/trunk@15 118783bc-b352-0410-bbc3-0f610f6f7ae8 --- g_pypi/cli.py | 1 + g_pypi/ebuild.py | 30 +++++++++++++++++++++--------- g_pypi/enamer.py | 20 ++++++++++++++------ 3 files changed, 36 insertions(+), 15 deletions(-) diff --git a/g_pypi/cli.py b/g_pypi/cli.py index f9e0da3..047452d 100755 --- a/g_pypi/cli.py +++ b/g_pypi/cli.py @@ -251,6 +251,7 @@ class GPyPI(object): download_url = self.get_uri() try: ebuild = Ebuild(self.package_name, self.version, download_url) + except portage_exception.InvalidVersionString: self.logger.error("Can't determine PV, use -v to set it: %s-%s" % \ (self.package_name, self.version)) diff --git a/g_pypi/ebuild.py b/g_pypi/ebuild.py index cde41ee..e56e3a4 100755 --- a/g_pypi/ebuild.py +++ b/g_pypi/ebuild.py @@ -99,12 +99,20 @@ class Ebuild: self.options.pv = "9999" self.vars['esvn_repo_uri'] = download_url self.add_inherit("subversion") + + if up_pn.find('.') > -1: + self.vars['python_modname'] = self.options.my_pn = up_pn + up_pn = self.filter_pkgname(up_pn) + self.options.pn = up_pn + ebuild_vars = enamer.get_vars(download_url, up_pn, up_pv, self.options.pn, - self.options.pv, self.options.my_pn, self.options.my_pv) + self.options.pv, self.options.my_pn, self.options.my_pv, self.options.my_p) + for key in ebuild_vars.keys(): if not self.vars.has_key(key): self.vars[key] = ebuild_vars[key] - self.vars['p'] = '%s-%s' % (self.vars['pn'], self.vars['pv']) + + self.vars['p'] = '%s-%s' % (self.vars['pn'], self.vars['pv']) def set_metadata(self, metadata): """Set metadata""" @@ -141,6 +149,7 @@ class Ebuild: self.vars['my_pn'] = ebuild_vars['my_pn'] else: self.vars['my_pn'] = '' + if ebuild_vars.has_key('my_pv'): self.vars['my_pv'] = ebuild_vars['my_pv'] else: @@ -287,7 +296,7 @@ class Ebuild: pkg_name = req.project_name.lower() if not len(req.specs): self.add_setuptools_depend(req) - self.add_rdepend("dev-python/%s" % pkg_name) + self.add_rdepend("dev-python/%s" % self.filter_pkgname(pkg_name)) added_dep = True #No version of requirement was specified so we only add #dev-python/pkg_name @@ -306,29 +315,29 @@ class Ebuild: #for turbogears has >=2.2,<3.0 which would translate to #portage's =dev-python/cherrypy-2.2* self.logger.warn(" **** Requirement %s has multi-specs ****" % req) - self.add_rdepend("dev-python/%s" % pkg_name) + self.add_rdepend("dev-python/%s" % self.filter_pkgname(pkg_name)) break #Requirement.specs is a list of (comparator,version) tuples if comparator == "==": comparator = "=" if valid_cpn("%sdev-python/%s-%s" % (comparator, pkg_name, ver)): - self.add_rdepend("%sdev-python/%s-%s" % (comparator, pkg_name, ver)) + self.add_rdepend("%sdev-python/%s-%s" % (comparator, self.filter_pkgname(pkg_name), ver)) else: self.logger.info(\ "Invalid PV in dependency: (Requirement %s) %sdev-python/%s-%s" \ % (req, comparator, pkg_name, ver) ) - installed_pv = get_installed_ver("dev-python/%s" % pkg_name) + installed_pv = get_installed_ver("dev-python/%s" % self.filter_pkgname(pkg_name)) if installed_pv: self.add_rdepend(">=dev-python/%s-%s" % \ - (pkg_name, installed_pv)) + (self.filter_pkgname(pkg_name), installed_pv)) else: #If we have it installed, use >= installed version #If package has invalid version and we don't have #an ebuild in portage, just add PN to DEPEND, no #version. This means the dep ebuild will have to #be created by adding --MY_? options using the CLI - self.add_rdepend("dev-python/%s" % pkg_name) + self.add_rdepend("dev-python/%s" % self.filter_pkgname(pkg_name)) added_dep = True if not added_dep: self.add_warning("Couldn't determine dependency: %s" % req) @@ -432,7 +441,6 @@ class Ebuild: # not self.options.subversion: self.post_unpack() functions['src_test'] = self.get_src_test() - functions['src_install'] = self.get_docs() # *_f variables are formatted text ready for ebuild self.vars['depend_f'] = format_depend(self.vars['depend']) self.vars['rdepend_f'] = format_depend(self.vars['rdepend']) @@ -573,6 +581,9 @@ class Ebuild: self.vars["s"] = "${WORKDIR}/%s" % unpacked_dir + def filter_pkgname(self, pkgname): + return pkgname.replace('.', '-') + def get_portage_license(my_license): """ Map defined classifier license to Portage license @@ -654,3 +665,4 @@ def format_depend(dep_list): middle += "\t%s\n" % dep output += middle + "\t" + dep_list[-1] return output + diff --git a/g_pypi/enamer.py b/g_pypi/enamer.py index fc604a4..905a632 100644 --- a/g_pypi/enamer.py +++ b/g_pypi/enamer.py @@ -281,7 +281,7 @@ def sanitize_uri(uri): """ return uri -def get_vars(uri, up_pn, up_pv, pn="", pv="", my_pn="", my_pv=""): +def get_vars(uri, up_pn, up_pv, pn="", pv="", my_pn="", my_pv="", my_p=""): """ Determine P* and MY_* variables @@ -343,11 +343,6 @@ def get_vars(uri, up_pn, up_pv, pn="", pv="", my_pn="", my_pv=""): pn = pn.lower() p = "%s-%s" % (pn, pv) - #Check if we need to use MY_P based on src's uri - if my_p: - src_uri, my_p_raw = get_myp(uri) - else: - src_uri, my_p, my_p_raw = get_src_uri(uri) #Make sure we have a valid P if not portage_dep.isvalidatom("=dev-python/%s-%s" % (pn, pv)): @@ -372,6 +367,19 @@ def get_vars(uri, up_pn, up_pv, pn="", pv="", my_pn="", my_pv=""): my_p = my_p.replace(pn, "${PN}") my_p = my_p.replace(pv, "${PV}") + if my_pn and not my_p: + if my_pv: + my_p = '%s-%s' % (my_pn, my_pv) + elif not my_pv: + my_p = '%s-%s' % (my_pn, '${PV}') + my_pn = '' + + #Check if we need to use MY_P based on src's uri + if my_p: + src_uri, my_p_raw = get_myp(uri) + else: + src_uri, my_p, my_p_raw = get_src_uri(uri) + return {'pn': pn, 'pv': pv, 'p': p, -- 2.26.2