Skip to content

Commit

Permalink
Change python naming convention
Browse files Browse the repository at this point in the history
  • Loading branch information
Korusuke authored and reneeotten committed Jun 22, 2019
1 parent 8c08181 commit 13cd9fd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions upt_macports/templates/python.Portfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand Down
2 changes: 1 addition & 1 deletion upt_macports/tests/test_python_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
6 changes: 6 additions & 0 deletions upt_macports/upt_macports.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 13cd9fd

Please sign in to comment.