Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure pip install builds js assets #21

Merged
merged 2 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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),
},
)
Loading