Skip to content

Commit

Permalink
Merge pull request #21 from yuvipanda/fix-setup
Browse files Browse the repository at this point in the history
Make sure `pip install` builds js assets
  • Loading branch information
yuvipanda authored Mar 28, 2024
2 parents 1afb6f3 + cbfba97 commit f4f869d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 35 deletions.
19 changes: 0 additions & 19 deletions MANIFEST.in

This file was deleted.

45 changes: 29 additions & 16 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,48 @@
from subprocess import check_call

from setuptools import setup
from setuptools.command.build_py import build_py
from setuptools.command.sdist import sdist

HERE = os.path.dirname(__file__)


class WebPackedSDist(sdist):
def webpacked_command(command):
"""
Run npm webpack to generate appropriate output files before sdist.
This generates all the js & css we need, and that is included via an
entry in MANIFEST.in
Return a command that inherits from command, but adds webpack JS building
"""

description = "build frontend files with webpack"

def run(self):
class WebPackedCommand(command):
"""
Call npm install & npm run webpack before packaging
Run npm webpack to generate appropriate output files before given command.
This generates all the js & css we need, and that is included via an
entry in MANIFEST.in
"""
check_call(
["npm", "install", "--progress=false", "--unsafe-perm"],
cwd=HERE,
)

check_call(["npm", "run", "webpack"], cwd=HERE)
description = "build frontend files with webpack"

def run(self):
"""
Call npm install & npm run webpack before packaging
"""
check_call(
["npm", "install", "--progress=false", "--unsafe-perm"],
cwd=HERE,
)

check_call(["npm", "run", "webpack"], cwd=HERE)

return super().run()

return super().run()
return WebPackedCommand


setup(
cmdclass={"sdist": WebPackedSDist},
cmdclass={
# Handles making sdists and wheels
"sdist": webpacked_command(sdist),
# Handles `pip install` directly
"build_py": webpacked_command(build_py),
},
)

0 comments on commit f4f869d

Please sign in to comment.