From de9ba5bf06b582ebad641aeee0a74d9475d77f68 Mon Sep 17 00:00:00 2001 From: Jean-Luc Stevens Date: Fri, 4 Aug 2017 00:07:36 +0100 Subject: [PATCH] Fixes to setup.py for pip install (#1782) * Moved examples function to setup.py to avoid dependencies install * Restored copy of examples function in util * Added comment about duplication of the examples function * Fixed message about holoviews command dependencies --- holoviews/util/__init__.py | 2 +- holoviews/util/command.py | 2 +- setup.py | 31 +++++++++++++++++++++++++++---- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/holoviews/util/__init__.py b/holoviews/util/__init__.py index 05a9aef969..e84f7c0adf 100644 --- a/holoviews/util/__init__.py +++ b/holoviews/util/__init__.py @@ -15,6 +15,7 @@ Store.output_settings = OutputSettings + def examples(path='holoviews-examples', verbose=False, force=False, root=__file__): """ Copies the notebooks to the supplied path. @@ -36,7 +37,6 @@ def examples(path='holoviews-examples', verbose=False, force=False, root=__file_ print('Cannot find %s' % tree_root) - class opts(param.ParameterizedFunction): """ Utility function to set options either at the global level or on a diff --git a/holoviews/util/command.py b/holoviews/util/command.py index 123165467b..77acb749f4 100755 --- a/holoviews/util/command.py +++ b/holoviews/util/command.py @@ -15,7 +15,7 @@ try: import nbformat, nbconvert except: - print('Both nbformat and nbconvert need to be installed to use the holoviews command') + print('nbformat, nbconvert and ipython need to be installed to use the holoviews command') sys.exit() try: from ..ipython.preprocessors import OptsMagicProcessor, OutputMagicProcessor diff --git a/setup.py b/setup.py index dd90fa6dae..9b5549242b 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ #!/usr/bin/env python import sys, os, glob -from shutil import rmtree +import shutil from collections import defaultdict try: from setuptools import setup @@ -110,12 +110,35 @@ def walker(top, names): extensions[package].append(ext_str) +# Note: This function should be identical to util.examples +# (unfortunate and unavoidable duplication) +def examples(path='holoviews-examples', verbose=False, force=False, root=__file__): + """ + Copies the notebooks to the supplied path. + """ + filepath = os.path.abspath(os.path.dirname(root)) + example_dir = os.path.join(filepath, './examples') + if not os.path.exists(example_dir): + example_dir = os.path.join(filepath, '../examples') + if os.path.exists(path): + if not force: + print('%s directory already exists, either delete it or set the force flag' % path) + return + shutil.rmtree(path) + ignore = shutil.ignore_patterns('.ipynb_checkpoints','*.pyc','*~') + tree_root = os.path.abspath(example_dir) + if os.path.isdir(tree_root): + shutil.copytree(tree_root, path, ignore=ignore, symlinks=True) + else: + print('Cannot find %s' % tree_root) + + + def package_assets(example_path): """ Generates pseudo-packages for the examples directory. """ - import holoviews - holoviews.util.examples(example_path, force=True, root=__file__) + examples(example_path, force=True, root=__file__) for root, dirs, files in os.walk(example_path): walker(root, dirs+files) setup_args['packages'] += packages @@ -153,4 +176,4 @@ def package_assets(example_path): setup(**setup_args) if os.path.isdir(example_path): - rmtree(example_path) + shutil.rmtree(example_path)