Skip to content

Commit

Permalink
Modify setup.py
Browse files Browse the repository at this point in the history
Now first deletes existing old CRESanaModels before installation. This
prevents models from old versions (after renaming) to still exist in
newer versions.
  • Loading branch information
MCFlowMace committed Sep 21, 2023
1 parent 0cd8a32 commit 7edae57
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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')
Expand Down

0 comments on commit 7edae57

Please sign in to comment.