diff --git a/setup.py b/setup.py index da6830d27..651481dee 100644 --- a/setup.py +++ b/setup.py @@ -7,9 +7,10 @@ if __name__ == '__main__': - example_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), - 'xrspatial', 'examples') - if 'develop' not in sys.argv: + _package_dir = os.path.dirname(os.path.abspath(__file__)) + example_path = os.path.join(_package_dir, 'xrspatial', 'examples') + _is_develop = len(sys.argv) > 1 and sys.argv[1] == 'develop' + if not _is_develop: pyct.build.examples(example_path, __file__, force=True) use_scm = { @@ -19,4 +20,7 @@ setup(use_scm_version=use_scm) if os.path.isdir(example_path): - shutil.rmtree(example_path) + _real_example_path = os.path.realpath(example_path) + _real_package_dir = os.path.realpath(_package_dir) + if _real_example_path.startswith(_real_package_dir + os.sep): + shutil.rmtree(example_path)