mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-15 14:03:02 +00:00
prepare for sdist
- trigger js/css before sdist (always) - trigger js/css before build_py (part of wheel, install) iff installing from repo should avoid running js, css from sdist
This commit is contained in:
29
setup.py
29
setup.py
@@ -39,10 +39,17 @@ here = os.path.abspath(os.path.dirname(__file__))
|
|||||||
share_jupyter = pjoin(here, 'share', 'jupyter', 'hub')
|
share_jupyter = pjoin(here, 'share', 'jupyter', 'hub')
|
||||||
static = pjoin(share_jupyter, 'static')
|
static = pjoin(share_jupyter, 'static')
|
||||||
|
|
||||||
|
is_repo = os.path.exists(pjoin(here, '.git'))
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
# Build basic package data, etc.
|
# Build basic package data, etc.
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# setuptools for wheel, develop
|
||||||
|
for cmd in ['bdist_wheel', 'develop']:
|
||||||
|
if cmd in sys.argv:
|
||||||
|
import setuptools
|
||||||
|
|
||||||
def get_data_files():
|
def get_data_files():
|
||||||
"""Get data files in share/jupyter"""
|
"""Get data files in share/jupyter"""
|
||||||
|
|
||||||
@@ -99,7 +106,8 @@ setup_args = dict(
|
|||||||
|
|
||||||
# imports here, so they are after setuptools import if there was one
|
# imports here, so they are after setuptools import if there was one
|
||||||
from distutils.cmd import Command
|
from distutils.cmd import Command
|
||||||
from distutils.command.install import install
|
from distutils.command.build_py import build_py
|
||||||
|
from distutils.command.sdist import sdist
|
||||||
|
|
||||||
class BaseCommand(Command):
|
class BaseCommand(Command):
|
||||||
"""Dumb empty command because Command needs subclasses to override too much"""
|
"""Dumb empty command because Command needs subclasses to override too much"""
|
||||||
@@ -163,13 +171,26 @@ class CSS(BaseCommand):
|
|||||||
# update data-files in case this created new files
|
# update data-files in case this created new files
|
||||||
self.distribution.data_files = get_data_files()
|
self.distribution.data_files = get_data_files()
|
||||||
|
|
||||||
# ensure bower is run as part of install
|
def js_css_first(cls, strict=True):
|
||||||
install.sub_commands.insert(0, ('js', None))
|
class Command(cls):
|
||||||
install.sub_commands.insert(1, ('css', None))
|
def run(self):
|
||||||
|
try:
|
||||||
|
self.run_command('js')
|
||||||
|
self.run_command('css')
|
||||||
|
except Exception:
|
||||||
|
if strict:
|
||||||
|
raise
|
||||||
|
else:
|
||||||
|
pass
|
||||||
|
return super().run()
|
||||||
|
return Command
|
||||||
|
|
||||||
|
|
||||||
setup_args['cmdclass'] = {
|
setup_args['cmdclass'] = {
|
||||||
'js': Bower,
|
'js': Bower,
|
||||||
'css': CSS,
|
'css': CSS,
|
||||||
|
'build_py': js_css_first(build_py, strict=is_repo),
|
||||||
|
'sdist': js_css_first(sdist, strict=True),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user