From b6bfc735b630f57b18668152546e17fe46908d8e Mon Sep 17 00:00:00 2001 From: rillig Date: Tue, 25 May 2021 17:44:08 +0000 Subject: url2pkg: generate proper package name for Python dependencies Reported by Brook Milligan via private mail. --- pkgtools/url2pkg/files/url2pkg.py | 19 ++++++++++--------- pkgtools/url2pkg/files/url2pkg_test.py | 8 ++++---- 2 files changed, 14 insertions(+), 13 deletions(-) (limited to 'pkgtools') diff --git a/pkgtools/url2pkg/files/url2pkg.py b/pkgtools/url2pkg/files/url2pkg.py index 78c1b764e47..d6aec574903 100644 --- a/pkgtools/url2pkg/files/url2pkg.py +++ b/pkgtools/url2pkg/files/url2pkg.py @@ -1,5 +1,5 @@ #! @PYTHONBIN@ -# $NetBSD: url2pkg.py,v 1.30 2021/05/25 17:14:44 rillig Exp $ +# $NetBSD: url2pkg.py,v 1.31 2021/05/25 17:44:08 rillig Exp $ # Copyright (c) 2019 The NetBSD Foundation, Inc. # All rights reserved. @@ -712,7 +712,8 @@ class Adjuster: self.todos.append(f'dependency {kind} {value}') def read_dependencies(self, cmd: str, env: Dict[str, str], - cwd: Union[Path, Any], pkgname_prefix: str) -> None: + cwd: Union[Path, Any], pkgdir_prefix: str, + pkgname_prefix: str) -> None: effective_env = dict(os.environ) effective_env.update(env) @@ -754,15 +755,15 @@ class Adjuster: self.g.debug('unknown dependency line: {0}', line) self.set_license(license_name, license_default) - self.add_dependencies(pkgname_prefix, dep_lines) + self.add_dependencies(pkgdir_prefix, pkgname_prefix, dep_lines) - def add_dependencies(self, pkgname_prefix: str, + def add_dependencies(self, pkgdir_prefix: str, pkgname_prefix: str, dep_lines: List[Tuple[str, str, str, str]]): for dep_line in dep_lines: kind, pkgbase, constraint, dep_dir = dep_line - if dep_dir == '' and pkgname_prefix != '': - dep_dir = self.g.find_package(pkgname_prefix + pkgbase) + if dep_dir == '' and pkgdir_prefix != '': + dep_dir = self.g.find_package(pkgdir_prefix + pkgbase) if dep_dir != '': pkgbase = pkgname_prefix + pkgbase if dep_dir == '': @@ -881,7 +882,7 @@ class Adjuster: # devel/p5-Algorithm-CheckDigits cmd = f'{self.g.perl5} -I{self.g.libdir} -I. Build.PL' - self.read_dependencies(cmd, {}, self.abs_wrksrc, '') + self.read_dependencies(cmd, {}, self.abs_wrksrc, '', '') self.build_vars.append(Var('PERL5_MODULE_TYPE', '=', 'Module::Build')) def adjust_perl_module_Makefile_PL(self): @@ -896,7 +897,7 @@ class Adjuster: subprocess.call(cmd1, shell=True, cwd=self.abs_wrksrc) cmd2 = f'{self.g.perl5} -I{self.g.libdir} -I. Makefile.PL' - self.read_dependencies(cmd2, {}, self.abs_wrksrc, '') + self.read_dependencies(cmd2, {}, self.abs_wrksrc, '', '') def adjust_perl_module_homepage(self): if '${MASTER_SITE_PERL_CPAN:' \ @@ -949,7 +950,7 @@ class Adjuster: 'PYTHONDONTWRITEBYTECODE': 'x', 'PYTHONPATH': self.g.libdir } - self.read_dependencies(cmd, env, self.abs_wrksrc, 'py-') + self.read_dependencies(cmd, env, self.abs_wrksrc, 'py-', '${PYPKGPREFIX}-') self.pkgname_prefix = '${PYPKGPREFIX}-' self.categories.append('python') diff --git a/pkgtools/url2pkg/files/url2pkg_test.py b/pkgtools/url2pkg/files/url2pkg_test.py index 914addce329..f83c5e109a6 100644 --- a/pkgtools/url2pkg/files/url2pkg_test.py +++ b/pkgtools/url2pkg/files/url2pkg_test.py @@ -1,4 +1,4 @@ -# $NetBSD: url2pkg_test.py,v 1.29 2021/05/23 16:27:39 rillig Exp $ +# $NetBSD: url2pkg_test.py,v 1.30 2021/05/25 17:44:08 rillig Exp $ import pytest from url2pkg import * @@ -710,7 +710,7 @@ def test_Adjuster_read_dependencies(): adjuster = Adjuster(g, '', Lines()) adjuster.makefile_lines.add('# url2pkg-marker') - adjuster.read_dependencies(cmd, env, '.', '') + adjuster.read_dependencies(cmd, env, '.', '', '') assert os.getenv('URL2PKG_DEPENDENCIES') is None assert adjuster.depends == ['package>=112.0:../../pkgtools/pkglint'] @@ -746,10 +746,10 @@ def test_Adjuster_read_dependencies__lookup_with_prefix(): cmd = "printf '%s\n' \"$URL2PKG_DEPENDENCIES\"" adjuster = Adjuster(g, '', Lines()) - adjuster.read_dependencies(cmd, env, '.', 'py-') + adjuster.read_dependencies(cmd, env, '.', 'py-', '${PYPKGPREFIX}-') assert adjuster.depends == [ - 'py-pyobjc-framework-Quartz>=0:../../devel/py-pyobjc-framework-Quartz', + '${PYPKGPREFIX}-pyobjc-framework-Quartz>=0:../../devel/py-pyobjc-framework-Quartz', ] -- cgit v1.2.3