From 0cd8a32ada8075dc1ef9225fd0e4b812d2d0f4e6 Mon Sep 17 00:00:00 2001 From: Florian Thomas Date: Thu, 21 Sep 2023 13:25:49 +0200 Subject: [PATCH 1/2] Modify README Add strong advice to run clean after installation to remove the build directory that is created by pip install --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 34c0978..cf5ba2b 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ DESKTOP_PARALLEL_JOBS = 2 PYTHON_SCRIPT_DIR = /some/directory ``` -As last step, run `pip install .` in the directory with setup.py. +**IMPORTANT**: As last step, run `python setup.py clean --all; pip install . ; python setup.py clean --all` in the directory with setup.py. This combined command is the safest way for installation in all situations. For further explanation: in theory `pip install .` is sufficient for a first installation after initially cloning the repo. **But** newer versions of pip create a `build` directory inside the repository and do not clean it up automatically after the installation. During development or when pulling new versions this directory can cause issues if it is not cleaned up after the installation. Therefore it is advised to adapt this installation routine in order to make sure no old build artifacts can mess with the installation process. Note: If you are using the system wide python environment (not recommended) instead of a virtual environment (e.g. with Anaconda) the package data will go to `/usr/local`, which causes access permission issues with Docker. As a workaround use `pip install -e .` which creates symlinks to the repo instead of copying files. From 7edae57bc9bfb36215813dc3514f02d46c37c340 Mon Sep 17 00:00:00 2001 From: Florian Thomas Date: Thu, 21 Sep 2023 14:19:04 +0200 Subject: [PATCH 2/2] Modify setup.py Now first deletes existing old CRESanaModels before installation. This prevents models from old versions (after renaming) to still exist in newer versions. --- setup.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) 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')