From 13cd9fd87fb5a1e34ad007499eef361352273bca Mon Sep 17 00:00:00 2001 From: Karan Sheth Date: Tue, 18 Jun 2019 01:11:11 +0530 Subject: [PATCH] Change python naming convention --- upt_macports/templates/python.Portfile | 3 +++ upt_macports/tests/test_python_package.py | 2 +- upt_macports/upt_macports.py | 6 ++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/upt_macports/templates/python.Portfile b/upt_macports/templates/python.Portfile index b07dcaf..27fbfcd 100644 --- a/upt_macports/templates/python.Portfile +++ b/upt_macports/templates/python.Portfile @@ -5,6 +5,9 @@ PortGroup python 1.0 {% endblock %} {% block nameversion %} name {{ pkg._pkgname() }} +{% if pkg._python_root_name() %} +python.rootname {{ pkg._python_root_name() }} +{% endif %} version {{ pkg.upt_pkg.version }} revision 0 {% endblock %} diff --git a/upt_macports/tests/test_python_package.py b/upt_macports/tests/test_python_package.py index fe15fa5..3639af9 100644 --- a/upt_macports/tests/test_python_package.py +++ b/upt_macports/tests/test_python_package.py @@ -11,7 +11,7 @@ def setUp(self): self.package.upt_pkg = upt.Package('test-pkg', '13.37') def test_pkgname(self): - expected = ['py-foo', 'py-py-foo', 'py-pyfoo', 'py-pyFoo'] + expected = ['py-foo', 'py-py-foo', 'py-pyfoo', 'py-pyfoo'] names = ['foo', 'py-foo', 'pyfoo', 'pyFoo'] for (name, expected_name) in zip(names, expected): self.package.upt_pkg = upt.Package(name, '13.37') diff --git a/upt_macports/upt_macports.py b/upt_macports/upt_macports.py index b5bc500..55cf2db 100644 --- a/upt_macports/upt_macports.py +++ b/upt_macports/upt_macports.py @@ -97,8 +97,14 @@ def _pkgname(self): @staticmethod def _normalized_macports_name(name): + name = name.lower() return f'py-{name}' + def _python_root_name(self): + pypi_name = self.upt_pkg.get_archive().filename.split('-'+self.upt_pkg.version)[0] # noqa + if pypi_name != self.upt_pkg.name.lower(): + return pypi_name + class MacPortsNpmPackage(MacPortsPackage): template = 'npm.Portfile'