diff --git a/setup.py b/setup.py index f7ae971..a8d4cbd 100644 --- a/setup.py +++ b/setup.py @@ -5,13 +5,14 @@ """ -from distutils.cmd import Command + from setuptools import setup import setuptools from setuptools.command.build_py import build_py import versioneer import subprocess -import glob +from pathlib import Path +import shutil from hercules import _versionhelper @@ -23,9 +24,17 @@ def run(self) -> None: #pickle CRESana models try: import cresana - path = 'hercules/hexbug/Phase4/CRESana_models' - for file in glob.glob(path+'/*.py'): - subprocess.run(['python', file]) + path = Path('hercules/hexbug/Phase4/CRESana_models') + paths_to_delete = [p for p in path.glob('*') if not p.suffix=='.py'] + + for p in paths_to_delete: + if p.is_file(): + p.unlink() + else: + shutil.rmtree(p) + + for file in path.glob('*.py'): + subprocess.run(['python', str(file)]) except: print('Not installing CRESana models')