Skip to content

Commit

Permalink
[WIP]: Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Korusuke committed Jun 27, 2019
1 parent 13cd9fd commit 44a367d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
8 changes: 8 additions & 0 deletions upt_macports/templates/base.Portfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
22 changes: 6 additions & 16 deletions upt_macports/templates/python.Portfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions upt_macports/upt_macports.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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'
Expand Down

0 comments on commit 44a367d

Please sign in to comment.