diff --git a/upt_macports/templates/base.Portfile b/upt_macports/templates/base.Portfile index 685b4fb..0ba470c 100644 --- a/upt_macports/templates/base.Portfile +++ b/upt_macports/templates/base.Portfile @@ -1,3 +1,11 @@ +{%- macro depends(kind, deps) -%}{% if deps %} + depends_{{ kind }}-append \ + {% for dep in deps %} + port:{{ dep|reqformat }}{% if not loop.last %} \ + {% endif %} + {% endfor %} +{% endif %} +{% endmacro -%} # -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4 PortSystem 1.0 diff --git a/upt_macports/templates/python.Portfile b/upt_macports/templates/python.Portfile index 27fbfcd..a08c948 100644 --- a/upt_macports/templates/python.Portfile +++ b/upt_macports/templates/python.Portfile @@ -28,24 +28,14 @@ if {${name} ne ${subport}} { ## file that setuptools is indeed used and that the dependency-type is correct. depends_build-append \ port:py${python.version}-setuptools - {%- if pkg.upt_pkg.requirements.run|length > 0 %} - - - depends_lib-append \ - {% for i in pkg.upt_pkg.requirements.run|sort(attribute='name') %} - port:py${python.version}-{{i.name}}{% if not loop.last %} \ - {% endif %} - {% endfor %} - {% endif %} - {%- if pkg.upt_pkg.requirements.test|length > 0 %} +{% if pkg.upt_pkg.requirements.run %} +{{ depends('lib', pkg.upt_pkg.requirements.run) -}} +{% endif %} - depends_test-append \ - {% for i in pkg.upt_pkg.requirements.test|sort(attribute='name') %} - port:py${python.version}-{{i.name}}{% if not loop.last %} \ - {% endif %} - {% endfor %} - {% endif %} +{% if pkg.upt_pkg.requirements.test %} +{{ depends('test', pkg.upt_pkg.requirements.test) -}} +{% endif %} livecheck.type none diff --git a/upt_macports/upt_macports.py b/upt_macports/upt_macports.py index 55cf2db..6f7b709 100644 --- a/upt_macports/upt_macports.py +++ b/upt_macports/upt_macports.py @@ -22,6 +22,7 @@ def _render_makefile_template(self): lstrip_blocks=True, keep_trailing_newline=True, ) + env.filters['reqformat'] = self.jinja2_reqformat template = env.get_template(self.template) return template.render(pkg=self) @@ -105,6 +106,10 @@ def _python_root_name(self): if pypi_name != self.upt_pkg.name.lower(): return pypi_name + def jinja2_reqformat(self, req): + return 'py${python.version}-'+req.name + + class MacPortsNpmPackage(MacPortsPackage): template = 'npm.Portfile'