Skip to content

Commit 0247120

Browse files
Make sure to always build the assets when building a python package (django-oscar#4306)
1 parent c429949 commit 0247120

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

setup.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,27 @@
88
"""
99
import os
1010
import re
11+
import subprocess
1112
import sys
1213

14+
# pylint: disable=deprecated-module
15+
from distutils.command import build as build_module
16+
1317
from setuptools import setup, find_packages
1418

1519
PROJECT_DIR = os.path.dirname(__file__)
1620

1721
sys.path.append(os.path.join(PROJECT_DIR, "src"))
1822
from oscar import get_version # noqa isort:skip
1923

24+
25+
class BuildNPM(build_module.build):
26+
def run(self):
27+
subprocess.check_call(["npm", "install"])
28+
subprocess.check_call(["npm", "run", "build"])
29+
super().run()
30+
31+
2032
install_requires = [
2133
"setuptools>=51.3.3",
2234
"django>=3.2,<4.3",
@@ -88,8 +100,8 @@
88100
license="BSD",
89101
platforms=["linux"],
90102
include_package_data=True,
91-
package_dir={'': 'src'},
92-
packages=find_packages('src'),
103+
package_dir={"": "src"},
104+
packages=find_packages("src"),
93105
python_requires=">=3.8",
94106
install_requires=install_requires,
95107
extras_require={
@@ -98,6 +110,7 @@
98110
"sorl-thumbnail": [sorl_thumbnail_version],
99111
"easy-thumbnails": [easy_thumbnails_version],
100112
},
113+
cmdclass={"build": BuildNPM},
101114
classifiers=[
102115
"Development Status :: 5 - Production/Stable",
103116
"Environment :: Web Environment",

0 commit comments

Comments
 (0)