From 836b6275b6819e066471bd68871db2965e44df93 Mon Sep 17 00:00:00 2001 From: Oliver Date: Thu, 6 Jan 2022 13:31:04 +1100 Subject: [PATCH] Removes custom plugins directory - rely on plugins.txt instead --- InvenTree/InvenTree/settings.py | 17 ----------------- docker/Dockerfile | 6 +++++- tasks.py | 25 ++++++++++++------------- 3 files changed, 17 insertions(+), 31 deletions(-) diff --git a/InvenTree/InvenTree/settings.py b/InvenTree/InvenTree/settings.py index 8fc0562059..d738a640b9 100644 --- a/InvenTree/InvenTree/settings.py +++ b/InvenTree/InvenTree/settings.py @@ -934,23 +934,6 @@ if DEBUG or TESTING: # load samples in debug mode PLUGIN_DIRS.append('plugin.samples') -# Check if an external plugin directory has been specified as an environment variable -# Note: This should be specified as INVENTREE_PLUGIN_DIR -plugin_dir = os.getenv('INVENTREE_PLUGIN_DIR') - -if plugin_dir: - if not os.path.exists(plugin_dir): - logger.info(f"Plugin directory '{plugin_dir}' does not exist") - - try: - os.makedirs(plugin_dir, exist_ok=True) - logger.info(f"Created plugin directory '{plugin_dir}'") - except: - logger.warning(f"Could not create plugins directory '{plugin_dir}'") - - if os.path.exists(plugin_dir): - PLUGIN_DIRS.append(plugin_dir) - # Plugin test settings PLUGIN_TESTING = get_setting('PLUGIN_TESTING', TESTING) # are plugins beeing tested? PLUGIN_TESTING_SETUP = get_setting('PLUGIN_TESTING_SETUP', False) # load plugins from setup hooks in testing? diff --git a/docker/Dockerfile b/docker/Dockerfile index 8fd932ff6f..55a89210fe 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -34,7 +34,7 @@ ENV INVENTREE_PLUGIN_DIR="${INVENTREE_DATA_DIR}/plugins" ENV INVENTREE_CONFIG_FILE="${INVENTREE_DATA_DIR}/config.yaml" ENV INVENTREE_SECRET_KEY_FILE="${INVENTREE_DATA_DIR}/secret_key.txt" -ENV INVENTREE_PLUGIN_FILE="${INVENTREE_DATA_DIR}}/plugins.txt" +ENV INVENTREE_PLUGIN_FILE="${INVENTREE_DATA_DIR}/plugins.txt" # Worker configuration (can be altered by user) ENV INVENTREE_GUNICORN_WORKERS="4" @@ -131,8 +131,12 @@ ENV INVENTREE_PY_ENV="${INVENTREE_DEV_DIR}/env" # Override default path settings ENV INVENTREE_STATIC_ROOT="${INVENTREE_DEV_DIR}/static" ENV INVENTREE_MEDIA_ROOT="${INVENTREE_DEV_DIR}/media" +ENV INVENTREE_PLUGIN_DIR="${INVENTREE_DEV_DIR}/plugins" + ENV INVENTREE_CONFIG_FILE="${INVENTREE_DEV_DIR}/config.yaml" ENV INVENTREE_SECRET_KEY_FILE="${INVENTREE_DEV_DIR}/secret_key.txt" +ENV INVENTREE_PLUGIN_FILE="${INVENTREE_DEV_DIR}/plugins.txt" + WORKDIR ${INVENTREE_HOME} diff --git a/tasks.py b/tasks.py index 9eaaa261d9..89a579ac9e 100644 --- a/tasks.py +++ b/tasks.py @@ -71,19 +71,6 @@ def manage(c, cmd, pty=False): cmd=cmd ), pty=pty) - -@task -def install(c): - """ - Installs required python packages - """ - - print("Installing required python packages from 'requirements.txt'") - - # Install required Python packages with PIP - c.run('pip3 install -U -r requirements.txt') - - @task def plugins(c): """ @@ -99,12 +86,24 @@ def plugins(c): if not os.path.exists(PLUGIN_FILE): # Create an empty plugin print(f"Plugins file '{PLUGIN_FILE}' does not exist") + return print(f"Installing plugin packages from '{PLUGIN_FILE}'") # Install the plugins c.run(f"pip3 install -U -r '{PLUGIN_FILE}'") +@task(post=[plugins]) +def install(c): + """ + Installs required python packages + """ + + print("Installing required python packages from 'requirements.txt'") + + # Install required Python packages with PIP + c.run('pip3 install -U -r requirements.txt') + @task def shell(c): """