Skip to content

Commit

Permalink
Fixes to setup.py for pip install (holoviz#1782)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
jlstevens authored and ea42gh committed Aug 12, 2017
1 parent e7fd0da commit de9ba5b
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
2 changes: 1 addition & 1 deletion holoviews/util/__init__.py
Expand Up @@ -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.
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion holoviews/util/command.py
Expand Up @@ -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
Expand Down
31 changes: 27 additions & 4 deletions 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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)

0 comments on commit de9ba5b

Please sign in to comment.