Skip to content

Commit

Permalink
Build JavaScript files during python package build (isso-comments#697)
Browse files Browse the repository at this point in the history
Make package builds via setuptools automatically trigger building of
merged & minified JS assets.

This fixes installing isso from source when using "pip install" as long
as both the python and node requirements are met. It also ensures that
setup.py commands like "build" or "bdist_wheel" create archives that
contain generated JS code.
  • Loading branch information
stefangehn committed Jan 4, 2022
1 parent e6dbd21 commit bbad14e
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
#!/usr/bin/env python3
# -*- encoding: utf-8 -*-

import os
import setuptools.command.build_py
import subprocess

from setuptools import setup, find_packages

requires = ['itsdangerous', 'Jinja2', 'misaka>=2.0,<3.0', 'html5lib',
'werkzeug>=1.0', 'bleach', 'Flask-Caching>=1.9', 'Flask']


class NpmBuildCommand(setuptools.command.build_py.build_py):
"""Prefix Python build with node-based asset build"""

def run(self):
if 'TOX_ENV' not in os.environ:
subprocess.check_call(['make', 'init', 'js'])
setuptools.command.build_py.build_py.run(self)


setup(
name='isso',
version='0.12.5',
Expand Down Expand Up @@ -34,5 +48,8 @@
entry_points={
'console_scripts':
['isso = isso:main'],
}
},
cmdclass={
'build_py': NpmBuildCommand,
},
)

0 comments on commit bbad14e

Please sign in to comment.