|
| 1 | +# nodely >>> putMORE Node.js into Python |
| 2 | +# |
| 3 | +# Copyright (C) 2017 Stefan Zimmermann <[email protected]> |
| 4 | +# |
| 5 | +# nodely is free software: you can redistribute it and/or modify |
| 6 | +# it under the terms of the GNU Lesser General Public License as published by |
| 7 | +# the Free Software Foundation, either version 3 of the License, or |
| 8 | +# (at your option) any later version. |
| 9 | +# |
| 10 | +# nodely is distributed in the hope that it will be useful, |
| 11 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | +# GNU Lesser General Public License for more details. |
| 14 | +# |
| 15 | +# You should have received a copy of the GNU Lesser General Public License |
| 16 | +# along with nodely. If not, see <http://www.gnu.org/licenses/>. |
| 17 | + |
| 18 | +""" |
| 19 | +nodely entry points for ``distutils.setup_keywords``. |
| 20 | +
|
| 21 | +Adding ``require_node_modules`` to ``setup()``:: |
| 22 | +
|
| 23 | + from setuptools import setup |
| 24 | +
|
| 25 | + setup( |
| 26 | + ... |
| 27 | + setup_requires=['nodely', ...], |
| 28 | + require_node_modules=['coffee-script', ...], |
| 29 | + ... |
| 30 | + ) |
| 31 | +""" |
| 32 | + |
| 33 | +from moretools import isstring |
| 34 | + |
| 35 | +import nodely |
| 36 | + |
| 37 | +__all__ = ('require_node_modules', ) |
| 38 | + |
| 39 | + |
| 40 | +def require_node_modules(dist, keyword='require_node_modules', |
| 41 | + jsmodules=None): |
| 42 | + """ |
| 43 | + Install required `jsmodules` during a Python package ``setup()``. |
| 44 | + """ |
| 45 | + assert keyword == 'require_node_modules' |
| 46 | + if jsmodules is None: |
| 47 | + return |
| 48 | + |
| 49 | + if isstring(jsmodules): |
| 50 | + jsmodules = filter( |
| 51 | + None, (mod.strip() for mod in jsmodules.split('\n'))) |
| 52 | + for jsmod in jsmodules: |
| 53 | + nodely.install(jsmod) |
0 commit comments