diff --git a/.gitignore b/.gitignore index 79b7162..afc60ed 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,7 @@ *.note *.xcf /nohup.out -/*-old +*-old /*.yml /pylintrc .venv/* diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 0d119f0..167691c 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -11,10 +11,10 @@ Clone the repository and enter it. To avoid cluttering your system, consider using a [virtual environment](https://docs.python.org/3/tutorial/venv.html). -Your system needs several packages installed. On Alpine, this can be done with +Your system needs several packages installed. For supported distributions, this can be done with e.g. ```console - sh ./dev/install_dependencies_alpine.sh + sh ./install/install_dependencies_alpine.sh ``` For other distros, try to find the equivalents of the packages listed or simply check your error output. diff --git a/README.md b/README.md index f299ee4..1a0562e 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ Your CPU should have a single core passmark score of at the very least 1500. Whe ### PyPI -You can download the included script `install_alpine.sh` and run it with +You can download one of the included scripts in the `install` folder and run it with e.g. ```console sh install_alpine.sh @@ -73,7 +73,7 @@ You can also simply call the install command pip install malojaserver ``` -directly (e.g. if you're not on Alpine) - make sure you have all the system packages installed. +directly - make sure you have all the system packages installed. ### From Source @@ -84,10 +84,10 @@ Clone this repository and enter the directory with cd maloja ``` -Then install all the requirements and build the package: +Then install all the requirements and build the package, e.g.: ```console - sh ./install/install_dependencies.sh + sh ./install/install_dependencies_alpine.sh pip install -r requirements.txt pip install . ``` diff --git a/dev/install_dependencies_alpine.sh b/dev/install_dependencies_alpine.sh deleted file mode 100644 index 0d6f320..0000000 --- a/dev/install_dependencies_alpine.sh +++ /dev/null @@ -1,4 +0,0 @@ -apk add \ - gcc g++ python3-dev libxml2-dev libxslt-dev libffi-dev libc-dev py3-pip linux-headers \ - python3 tzdata \ - vips diff --git a/dev/templates/dev/install_dependencies_alpine.sh.jinja b/dev/templates/dev/install_dependencies_alpine.sh.jinja deleted file mode 100644 index 8824fbb..0000000 --- a/dev/templates/dev/install_dependencies_alpine.sh.jinja +++ /dev/null @@ -1,4 +0,0 @@ -apk add \ - {{ tool.osreqs.alpine.build | join(' ') }} \ - {{ tool.osreqs.alpine.run | join(' ') }} \ - {{ tool.osreqs.alpine.opt | join(' ') }} diff --git a/dev/templates/install/install_alpine.sh.jinja b/dev/templates/install/install_alpine.sh.jinja new file mode 100644 index 0000000..021ebc0 --- /dev/null +++ b/dev/templates/install/install_alpine.sh.jinja @@ -0,0 +1,4 @@ +{% include 'install/install_dependencies_alpine.sh.jinja' %} +apk add py3-pip +pip install wheel +pip install malojaserver diff --git a/dev/templates/install/install_debian.sh.jinja b/dev/templates/install/install_debian.sh.jinja new file mode 100644 index 0000000..bd3f903 --- /dev/null +++ b/dev/templates/install/install_debian.sh.jinja @@ -0,0 +1,4 @@ +{% include 'install/install_dependencies_debian.sh.jinja' %} +apt install python3-pip +pip install wheel +pip install malojaserver diff --git a/dev/templates/install/install_dependencies_alpine.sh.jinja b/dev/templates/install/install_dependencies_alpine.sh.jinja new file mode 100644 index 0000000..862d63c --- /dev/null +++ b/dev/templates/install/install_dependencies_alpine.sh.jinja @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +apk update +apk add \ + {{ (tool.osreqs.alpine.build + tool.osreqs.alpine.run + tool.osreqs.alpine.opt) | join(' \\\n\t') }} diff --git a/dev/templates/install/install_dependencies_debian.sh.jinja b/dev/templates/install/install_dependencies_debian.sh.jinja new file mode 100644 index 0000000..b840935 --- /dev/null +++ b/dev/templates/install/install_dependencies_debian.sh.jinja @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +apt update +apt install \ + {{ (tool.osreqs.debian.build + tool.osreqs.debian.run + tool.osreqs.debian.opt) | join(' \\\n\t') }} diff --git a/dev/templates/install_alpine.sh.jinja b/dev/templates/install_alpine.sh.jinja deleted file mode 100644 index ce07a61..0000000 --- a/dev/templates/install_alpine.sh.jinja +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash -apk add \ - {{ tool.osreqs.alpine.build | join(' \\\n\t') }} \ - {{ tool.osreqs.alpine.run | join(' \\\n\t') }} \ - {{ tool.osreqs.alpine.opt | join(' \\\n\t') }} -pip3 install wheel -pip3 install malojaserver diff --git a/dev/update_dist_files.py b/dev/update_dist_files.py index adf941e..0bd6c8e 100644 --- a/dev/update_dist_files.py +++ b/dev/update_dist_files.py @@ -2,6 +2,12 @@ import toml import os import jinja2 +env = jinja2.Environment( + loader=jinja2.FileSystemLoader('dev/templates'), + autoescape=jinja2.select_autoescape(['html', 'xml']), + keep_trailing_newline=True +) + with open("pyproject.toml") as filed: data = toml.load(filed) @@ -9,20 +15,19 @@ templatedir = "./dev/templates" for root,dirs,files in os.walk(templatedir): - relpath = os.path.relpath(root,start=templatedir) + reldirpath = os.path.relpath(root,start=templatedir) for f in files: + relfilepath = os.path.join(reldirpath,f) + if not f.endswith('.jinja'): continue srcfile = os.path.join(root,f) - trgfile = os.path.join(relpath,f.replace(".jinja","")) + trgfile = os.path.join(reldirpath,f.replace(".jinja","")) - with open(srcfile) as templatefiled: - template = jinja2.Template(templatefiled.read()) - + template = env.get_template(relfilepath) result = template.render(**data) with open(trgfile,"w") as filed: filed.write(result) - filed.write('\n') diff --git a/install/install_alpine.sh b/install/install_alpine.sh new file mode 100644 index 0000000..88b23c2 --- /dev/null +++ b/install/install_alpine.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env sh +apk update +apk add \ + gcc \ + g++ \ + python3-dev \ + libxml2-dev \ + libxslt-dev \ + libffi-dev \ + libc-dev \ + py3-pip \ + linux-headers \ + python3 \ + tzdata \ + vips + +apk add py3-pip +pip install wheel +pip install malojaserver diff --git a/install/install_debian.sh b/install/install_debian.sh new file mode 100644 index 0000000..3886e39 --- /dev/null +++ b/install/install_debian.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env sh +apt update +apt install \ + python3-pip \ + python3 + +apt install python3-pip +pip install wheel +pip install malojaserver diff --git a/install_alpine.sh b/install/install_dependencies_alpine.sh similarity index 69% rename from install_alpine.sh rename to install/install_dependencies_alpine.sh index 5c890e6..5a14d85 100644 --- a/install_alpine.sh +++ b/install/install_dependencies_alpine.sh @@ -1,4 +1,5 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh +apk update apk add \ gcc \ g++ \ @@ -12,5 +13,3 @@ apk add \ python3 \ tzdata \ vips -pip3 install wheel -pip3 install malojaserver diff --git a/install/install_dependencies_debian.sh b/install/install_dependencies_debian.sh new file mode 100644 index 0000000..776bb6c --- /dev/null +++ b/install/install_dependencies_debian.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env sh +apt update +apt install \ + python3-pip \ + python3 diff --git a/install_ubuntu.sh b/install_ubuntu.sh deleted file mode 100644 index ff0bd66..0000000 --- a/install_ubuntu.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash -apt update -apt install python3 python3-pip -pip3 install malojaserver diff --git a/pyproject.toml b/pyproject.toml index ef519db..8754aa4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -68,3 +68,12 @@ run = [ opt = [ "vips" ] + +[tool.osreqs.debian] +build = [ + "python3-pip" +] +run = [ + "python3" +] +opt = []