diff --git a/conda.recipe/build.sh b/conda.recipe/build.sh index ec09395e3..00f3111c7 100644 --- a/conda.recipe/build.sh +++ b/conda.recipe/build.sh @@ -9,6 +9,7 @@ SRC_DIR=$RECIPE_DIR/.. pushd $SRC_DIR $PYTHON setup.py --quiet install --single-version-externally-managed --record=record.txt +cp -r $SRC_DIR/examples $PREFIX/share/datashader-examples popd diff --git a/datashader/__init__.py b/datashader/__init__.py index c90349e1b..cfab71313 100644 --- a/datashader/__init__.py +++ b/datashader/__init__.py @@ -28,23 +28,20 @@ def test(): pytest.main(os.path.dirname(__file__)) -def examples(path='.', verbose=False): +def examples(path='datashader-examples', verbose=False): """ Copies the examples to the supplied path. """ import os, glob - from shutil import copyfile - - path = os.path.abspath(path) - if not os.path.exists(path): - os.makedirs(path) - if verbose: print('Created directory %s' % path) - - notebook_glob = os.path.join(__path__[0], '..', 'examples', '*') - notebooks = glob.glob(notebook_glob) - - for notebook in notebooks: - nb_path = os.path.join(path, os.path.basename(notebook)) - copyfile(notebook, nb_path) - if verbose: print("%s copied to %s" % (os.path.basename(notebook), path)) + from shutil import copytree, ignore_patterns + + candidates = [os.path.join(__path__[0], '../examples'), + os.path.join(__path__[0], '../../../../share/datashader-examples')] + + for source in candidates: + if os.path.exists(source): + copytree(source, path, ignore=ignore_patterns('data','.ipynb_checkpoints','*.pyc','*~')) + if verbose: + print("%s copied to %s" % (source, path)) + break diff --git a/examples/README.md b/examples/README.md index cccfcdba3..f362f0b7a 100644 --- a/examples/README.md +++ b/examples/README.md @@ -7,9 +7,9 @@ To get a copy of the examples in your own directory so that you can run and edit them, you can run these commands in your terminal: ```bash -1. mkdir ~/datashader-examples -2. cd ~/datashader-examples -3. python -c 'from datashader import examples ; examples()' +1. cd ~ +2. python -c 'from datashader import examples ; examples("datashader-examples")' +3. cd datashader-examples 4. python download_sample_data.py ```