Skip to content

Commit 0667afd

Browse files
Provide setup keyword require_node_modules
1 parent 020801e commit 0667afd

File tree

3 files changed

+57
-1
lines changed

3 files changed

+57
-1
lines changed

nodely/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
# __version__ module is created by setuptools_scm during setup
3232
from .__version__ import version as __version__
3333

34-
__all__ = ['install', 'uninstall', 'which', 'Popen', 'call']
34+
__all__ = ('install', 'uninstall', 'which', 'Popen', 'call')
3535

3636

3737
#: The absolute path to the local node_modules/ sub-directory used for

nodely/setup_keywords.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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)

setup.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
packages=[
2727
'nodely',
2828
],
29+
entry_points={'distutils.setup_keywords': [
30+
'require_node_modules = nodely.setup_keywords:require_node_modules',
31+
]},
2932

3033
classifiers=[
3134
'Development Status :: 4 - Beta',

0 commit comments

Comments
 (0)