Skip to content

Commit

Permalink
Merge 071fd00 into 324f12e
Browse files Browse the repository at this point in the history
  • Loading branch information
jlstevens committed Jun 28, 2017
2 parents 324f12e + 071fd00 commit ae4e385
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ install:
conda install python=3.4.3;
fi
- rm -r $SITE_PACKAGES/numpy*
- python setup.py install
- python setup.py develop
- pip install git+git://github.com/ioam/param.git
- pip install path.py
- pip install coveralls awscli deepdiff
Expand Down
21 changes: 20 additions & 1 deletion holoviews/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

from __future__ import print_function, absolute_import
import os, sys, pydoc
import os, sys, pydoc, shutil

import numpy as np # noqa (API import)

Expand Down Expand Up @@ -85,3 +86,21 @@ def help(obj, visualization=True, ansi=True, backend=None,
print((msg if visualization is False else '') + info)
else:
pydoc.help(obj)


def examples(path='holoviews-examples', verbose=False, force=False):
"""
Copies the notebooks to the supplied path.
"""
filepath = os.path.abspath(os.path.dirname(__file__))
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','*~')
shutil.copytree(os.path.abspath(example_dir), path, ignore=ignore,
symlinks=True)
46 changes: 43 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env python

import sys, os
import sys, os, glob
from shutil import rmtree
from collections import defaultdict
try:
from setuptools import setup
except ImportError:
Expand Down Expand Up @@ -88,13 +90,49 @@ def check_pseudo_package(path):
raise Exception("Please make sure pseudo-package %s is populated." % path)


excludes = ['DS_Store', '.log', 'ipynb_checkpoints']
packages = []
extensions = defaultdict(list)

def walker(arg, top, names):
"""
Walks a directory and records all packages and file extensions.
"""
global packages, extensions
if any(exc in top for exc in excludes):
return
package = top[top.rfind('holoviews'):].replace(os.path.sep, '.')
packages.append(package)
for name in names:
ext = '.'.join(name.split('.')[1:])
ext_str = '*.%s' % ext
if ext and ext not in excludes and ext_str not in extensions[package]:
extensions[package].append(ext_str)


def package_assets(example_path):
"""
Generates pseudo-packages for the examples directory.
"""
import holoviews
holoviews.examples(example_path, force=True)
os.path.walk(example_path, walker, None)
setup_args['packages'] += packages
for p, exts in extensions.items():
if exts:
setup_args['package_data'][p] = exts


if __name__=="__main__":
example_path = os.path.join(os.path.dirname(os.path.abspath(__file__)),
'holoviews/examples')
if not 'develop' in sys.argv:
package_assets(example_path)

if ('upload' in sys.argv) or ('sdist' in sys.argv):
import holoviews
holoviews.__version__.verify(setup_args['version'])


if 'install' in sys.argv:
header = "HOLOVIEWS INSTALLATION INFORMATION"
bars = "="*len(header)
Expand All @@ -111,5 +149,7 @@ def check_pseudo_package(path):
print("For more information please visit http://holoviews.org/install.html\n")
print(bars+'\n')


setup(**setup_args)

if os.path.isdir(example_path):
rmtree(example_path)

0 comments on commit ae4e385

Please sign in to comment.