From 845b62367f6d173e8a209ac54b7225df7cbe79f5 Mon Sep 17 00:00:00 2001 From: Nikola Date: Wed, 3 May 2023 12:02:21 +0200 Subject: [PATCH] removed installation from docker added gdal as setup.py programatically inferred dependency small fixes --- Dockerfile | 4 ++-- entrypoint.sh | 4 ++-- eoxserver/instance_template/manage.py | 2 +- eoxserver/scripts/eoxserver-instance.py | 3 +-- requirements.txt | 1 - setup.cfg | 2 -- setup.py | 21 +++++++++++++++++++++ 7 files changed, 27 insertions(+), 10 deletions(-) mode change 100644 => 100755 entrypoint.sh mode change 100644 => 100755 eoxserver/scripts/eoxserver-instance.py create mode 100644 setup.py diff --git a/Dockerfile b/Dockerfile index 519e8d737..a132323bd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,6 +2,8 @@ FROM ubuntu:22.04 ENV INSTANCE_NAME=instance ENV TZ=UTC +ENV PYTHONPATH='/opt/eoxserver' +ENV PYTHONUNBUFFERED="1" # possible values are "postgis" and "spatialite" ENV DB=spatialite @@ -50,8 +52,6 @@ RUN python3 -m pip install -U pip \ # install EOxServer COPY . . -RUN python3 -m pip install --no-cache-dir . \ - && chmod +x entrypoint.sh EXPOSE 8000 diff --git a/entrypoint.sh b/entrypoint.sh old mode 100644 new mode 100755 index adf80bb2f..b0af24737 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -27,8 +27,8 @@ if [ ! -d "${INSTANCE_DIR}" ]; then source $f done fi - - eoxserver-instance.py "${INSTANCE_NAME}" "${INSTANCE_DIR}" + + ./eoxserver/scripts/eoxserver-instance.py "${INSTANCE_NAME}" "${INSTANCE_DIR}" cd "${INSTANCE_DIR}" # create the database schema diff --git a/eoxserver/instance_template/manage.py b/eoxserver/instance_template/manage.py index 6fcfc0d4d..41309844e 100644 --- a/eoxserver/instance_template/manage.py +++ b/eoxserver/instance_template/manage.py @@ -19,4 +19,4 @@ "forget to activate a virtual environment?" ) raise - execute_from_command_line(sys.argv) \ No newline at end of file + execute_from_command_line(sys.argv) diff --git a/eoxserver/scripts/eoxserver-instance.py b/eoxserver/scripts/eoxserver-instance.py old mode 100644 new mode 100755 index 9e69f599d..8545a3d74 --- a/eoxserver/scripts/eoxserver-instance.py +++ b/eoxserver/scripts/eoxserver-instance.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 #------------------------------------------------------------------------------- # # Project: EOxServer @@ -42,7 +42,6 @@ import eoxserver from eoxserver.core.instance import create_instance - def main(): parser = OptionParser( usage=textwrap.dedent("""\ diff --git a/requirements.txt b/requirements.txt index 3a994e8a0..60388da28 100644 --- a/requirements.txt +++ b/requirements.txt @@ -15,4 +15,3 @@ python-swiftclient<5.0.0 jsonfield gunicorn mapscript -gdal \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index b5d78afe6..e6ec3c33f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -46,8 +46,6 @@ scripts = tools/eoxserver-validate_xml.py tools/eoxserver-preprocess.py -install_requires = file: requirements.txt - [options.extras_require] dev = scipy diff --git a/setup.py b/setup.py new file mode 100644 index 000000000..1840b0ce2 --- /dev/null +++ b/setup.py @@ -0,0 +1,21 @@ +from setuptools import setup +import subprocess +import pkg_resources + + +with open('requirements.txt', 'r') as reqs: + install_requires = [ + str(requirement) + for requirement + in pkg_resources.parse_requirements(reqs) + ] + +try: + gdal_version = subprocess.check_output(['gdal-config','--version']).decode('utf-8').strip() +except FileNotFoundError: + gdal_version = subprocess.check_output(['gdalinfo','--version']).decode('utf-8').split(' ')[1].strip(',') + +install_requires.append(f'gdal=={gdal_version}') + +if __name__ == "__main__": + setup(install_requires=install_requires)