diff --git a/setup.py b/setup.py index 9cbb651c4d..4e82a9dab9 100644 --- a/setup.py +++ b/setup.py @@ -1,13 +1,11 @@ #!/usr/bin/env python import sys -import os from setuptools.command.sdist import sdist from wagtail.wagtailcore import __version__ -from wagtail.utils.setup import assets, add_subcommand - +from wagtail.utils.setup import assets, add_subcommand, check_bdist_egg try: from setuptools import setup, find_packages @@ -83,6 +81,7 @@ setup( zip_safe=False, cmdclass={ 'sdist': add_subcommand(sdist, [('assets', None)]), + 'bdist_egg': check_bdist_egg, 'assets': assets, }, ) diff --git a/wagtail/utils/setup.py b/wagtail/utils/setup.py index 6503eb3b1b..33639449c4 100644 --- a/wagtail/utils/setup.py +++ b/wagtail/utils/setup.py @@ -1,8 +1,12 @@ from __future__ import absolute_import, print_function, unicode_literals + +import os import subprocess from distutils.core import Command +from setuptools.command.bdist_egg import bdist_egg + class assets(Command): @@ -22,10 +26,26 @@ class assets(Command): raise SystemExit(1) +class check_bdist_egg(bdist_egg): + + # If this file does not exist, warn the user to compile the assets + sentinel_file = 'wagtail/wagtailadmin/static/wagtailadmin/css/core.css' + + def run(self): + bdist_egg.run(self) + if not os.path.isfile(self.sentinel_file): + print("\n".join([ + "************************************************************", + "The front end assets for Wagtail are missing.", + "To generate the assets, please refer to the documentation in", + "docs/contributing/css_guidelines.rst", + "************************************************************", + ])) + + def add_subcommand(command, extra_sub_commands): # Sadly, as commands are old-style classes, `type()` can not be used to - # construct these. Additionally, old-style classes do not have a `name` - # attribute, so naming them nicely is also impossible. + # construct these. class CompileAnd(command): sub_commands = command.sub_commands + extra_sub_commands CompileAnd.__name__ = command.__name__