aboutsummaryrefslogtreecommitdiff
path: root/pending
diff options
context:
space:
mode:
authorbozo.kopic <bozo@kopic.xyz>2021-11-07 15:52:44 +0100
committerbozo.kopic <bozo@kopic.xyz>2021-12-18 02:38:50 +0100
commit0702d13263bf501c1db074ce1544e60b95161210 (patch)
treeebca76946cead0ffcc742a64c15dd6f5e79958fa /pending
parent56a75fcb8f5a9e4c05ccec8eb4a3345a115da441 (diff)
major rewritev0.3.0
Diffstat (limited to 'pending')
-rw-r--r--pending/.dockerignore6
-rw-r--r--pending/Dockerfile25
-rw-r--r--pending/Procfile1
-rw-r--r--pending/app.json11
-rw-r--r--pending/bin/compile6
-rw-r--r--pending/bin/detect4
-rw-r--r--pending/dodo.py193
-rw-r--r--pending/package.json30
-rw-r--r--pending/requirements.pacman.linux.txt5
-rw-r--r--pending/runtime.txt1
-rw-r--r--pending/webpack.config.js39
11 files changed, 321 insertions, 0 deletions
diff --git a/pending/.dockerignore b/pending/.dockerignore
new file mode 100644
index 0000000..2b6c642
--- /dev/null
+++ b/pending/.dockerignore
@@ -0,0 +1,6 @@
+__pycache__
+/.doit.db
+/build
+/dist
+/node_modules
+/yarn-error.log
diff --git a/pending/Dockerfile b/pending/Dockerfile
new file mode 100644
index 0000000..0e093c5
--- /dev/null
+++ b/pending/Dockerfile
@@ -0,0 +1,25 @@
+FROM python:3.8-buster AS base
+
+
+FROM base AS build
+
+RUN apt-get update \
+ && apt-get install -q -y nodejs yarnpkg \
+ && ln -s /usr/bin/yarnpkg /usr/bin/yarn
+
+COPY . /opcut
+
+RUN cd /opcut \
+ && pip install -r requirements.txt \
+ && doit
+
+
+FROM base AS run
+
+COPY --from=build /opcut/dist /opcut/dist
+
+RUN pip install /opcut/dist/*
+
+EXPOSE 80
+
+CMD ["opcut", "server", "--addr", "http://0.0.0.0:80"]
diff --git a/pending/Procfile b/pending/Procfile
new file mode 100644
index 0000000..175affd
--- /dev/null
+++ b/pending/Procfile
@@ -0,0 +1 @@
+web: python -m opcut.main server --addr http://0.0.0.0:$PORT
diff --git a/pending/app.json b/pending/app.json
new file mode 100644
index 0000000..13044b9
--- /dev/null
+++ b/pending/app.json
@@ -0,0 +1,11 @@
+{
+ "name": "opcut",
+ "website": "http://opcut.heroku.com",
+ "repository": "https://github.com/bozokopic/opcut",
+ "image": "heroku/python",
+ "buildpacks": [
+ {"url": "heroku/python"},
+ {"url": "heroku/nodejs"},
+ {"url": "https://github.com/bozokopic/opcut"}
+ ]
+}
diff --git a/pending/bin/compile b/pending/bin/compile
new file mode 100644
index 0000000..9aa8e6c
--- /dev/null
+++ b/pending/bin/compile
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+cd $1
+doit clean_all
+doit
+pip install ./dist/*.whl
diff --git a/pending/bin/detect b/pending/bin/detect
new file mode 100644
index 0000000..2315487
--- /dev/null
+++ b/pending/bin/detect
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+echo "opcut build"
+exit 0
diff --git a/pending/dodo.py b/pending/dodo.py
new file mode 100644
index 0000000..5951fb7
--- /dev/null
+++ b/pending/dodo.py
@@ -0,0 +1,193 @@
+from pathlib import Path
+import datetime
+import os
+import shutil
+import subprocess
+import sys
+
+import packaging.version
+
+
+DOIT_CONFIG = {'backend': 'sqlite3',
+ 'default_tasks': ['dist'],
+ 'verbosity': 2}
+
+
+pythonpath = os.environ.get('PYTHONPATH')
+src_py_path = str(Path('src_py').resolve())
+
+sys.path += [src_py_path]
+if pythonpath:
+ os.environ['PYTHONPATH'] = f'{src_py_path}{os.pathsep}{pythonpath}'
+else:
+ os.environ['PYTHONPATH'] = src_py_path
+
+
+build_dir = Path('build')
+dist_dir = Path('dist')
+py_build_dir = build_dir / 'py'
+js_build_dir = build_dir / 'js'
+
+docker_img = 'bozokopic/opcut'
+
+
+def task_clean_all():
+ """Clean all"""
+ return {'actions': [f'rm -rf {build_dir}',
+ f'rm -rf {dist_dir}']}
+
+
+def task_check():
+ """Run linters"""
+ def flake8():
+ subprocess.run(['python', '-m', 'flake8', '.'],
+ cwd='src_py',
+ check=True)
+
+ return {'actions': [flake8,
+ 'yarn run --silent check_js',
+ 'yarn run --silent check_sass'],
+ 'task_dep': ['js_deps']}
+
+
+def task_js_deps():
+ """Install js dependencies"""
+ return {'actions': ['yarn install --silent']}
+
+
+def task_js_build():
+ """Build js"""
+ return {'actions': ['yarn run --silent build'],
+ 'task_dep': ['js_deps']}
+
+
+def task_js_watch():
+ """Build js on change"""
+
+ return {'actions': ['yarn run --silent watch'],
+ 'task_dep': ['js_deps']}
+
+
+def task_py_build():
+ """Build py"""
+ def mappings():
+ src_py_dir = Path('src_py')
+ for i in (src_py_dir / 'opcut').rglob('*.py'):
+ yield i, dst_dir / i.relative_to(src_py_dir)
+
+ src_json_dir = Path('schemas_json')
+ for i in src_json_dir.rglob('*.yaml'):
+ yield i, (dst_dir / 'opcut/schemas_json'
+ / i.relative_to(src_json_dir))
+
+ for i in js_build_dir.rglob('*'):
+ if i.is_dir():
+ continue
+ yield i, (dst_dir / 'opcut/ui'
+ / i.relative_to(js_build_dir))
+
+ dst_dir = py_build_dir
+ setup_path = dst_dir / 'setup.py'
+ manifest_path = dst_dir / 'MANIFEST.in'
+ src_paths = list(src_path for src_path, _ in mappings())
+ dst_paths = [setup_path, *(dst_path for _, dst_path in mappings())]
+ return {'actions': [(_copy_files, [mappings]),
+ (_create_manifest, [manifest_path, mappings]),
+ (_create_setup_py, [setup_path])],
+ 'file_dep': src_paths,
+ 'targets': dst_paths,
+ 'task_dep': ['js_build']}
+
+
+def task_dist():
+ """Create distribution"""
+ def dist():
+ dist_dir.mkdir(parents=True, exist_ok=True)
+ subprocess.run(['python', 'setup.py', '-q', 'bdist_wheel',
+ '--dist-dir', str(dist_dir.resolve())],
+ cwd=str(py_build_dir),
+ check=True)
+
+ return {'actions': [dist],
+ 'task_dep': ['py_build']}
+
+
+def task_docker_build():
+ """Create docker image"""
+ def build():
+ version = _get_version()
+ subprocess.run(['docker', 'build', '-t', f'{docker_img}:{version}',
+ '.'],
+ check=True)
+
+ return {'actions': [build]}
+
+
+def task_docker_upload():
+ """Upload docker image"""
+ def upload():
+ version = _get_version()
+ subprocess.run(['docker', 'push', f'{docker_img}:{version}'],
+ check=True)
+
+ return {'actions': [upload]}
+
+
+def _create_setup_py(path):
+ version = _get_version()
+ readme = _get_readme()
+ dependencies = ['aiohttp',
+ 'pycairo',
+ 'hat-util']
+ entry_points = {'console_scripts': ['opcut = opcut.main:main']}
+ options = {'bdist_wheel': {'python_tag': 'cp38',
+ 'py_limited_api': 'cp38',
+ 'plat_name': 'any'}}
+ classifiers = ['Programming Language :: Python :: 3']
+ with open(path, 'w', encoding='utf-8') as f:
+ f.write(f"from setuptools import setup\n\n\n"
+ f"readme = r\"\"\"\n{readme}\n\"\"\"\n\n"
+ f"setup(name='opcut',\n"
+ f" version={repr(version)},\n"
+ f" description='Cutting stock problem optimizer',\n"
+ f" long_description=readme,\n"
+ f" long_description_content_type='text/x-rst',\n"
+ f" url='https://github.com/bozokopic/opcut',\n"
+ f" author='Bozo Kopic',\n"
+ f" author_email='bozo.kopic@gmail.com',\n"
+ f" license='GPLv3',\n"
+ f" packages=['opcut'],\n"
+ f" include_package_data=True,\n"
+ f" install_requires={repr(dependencies)},\n"
+ f" python_requires='>=3.8',\n"
+ f" zip_safe=False,\n"
+ f" classifiers={repr(classifiers)},\n"
+ f" options={repr(options)},\n"
+ f" entry_points={repr(entry_points)})\n")
+
+
+def _copy_files(mappings):
+ for src_path, dst_path in mappings():
+ if not dst_path.parent.exists():
+ dst_path.parent.mkdir(parents=True, exist_ok=True)
+ shutil.copyfile(str(src_path), str(dst_path))
+
+
+def _create_manifest(path, mappings):
+ with open(path, 'w', encoding='utf-8') as f:
+ for _, i in mappings():
+ f.write(f"include {i.relative_to(path.parent)}\n")
+
+
+def _get_version():
+ with open('VERSION', encoding='utf-8') as f:
+ version_str = f.read().strip()
+ if version_str.endswith('dev'):
+ version_str += datetime.datetime.now().strftime("%Y%m%d")
+ version = packaging.version.Version(version_str)
+ return version.public
+
+
+def _get_readme():
+ with open('README.rst', encoding='utf-8') as f:
+ return f.read().strip()
diff --git a/pending/package.json b/pending/package.json
new file mode 100644
index 0000000..dc193f8
--- /dev/null
+++ b/pending/package.json
@@ -0,0 +1,30 @@
+{
+ "private": true,
+ "scripts": {
+ "build": "webpack",
+ "watch": "webpack -w",
+ "check_js": "eslint src_js",
+ "check_sass": "sass-lint src_scss/**/*.scss"
+ },
+ "devDependencies": {
+ "@hat-core/renderer": "0.4.0-dev20200410",
+ "@hat-core/util": "0.4.0-dev20200410",
+ "copy-webpack-plugin": "5.1.1",
+ "css-loader": "3.5.2",
+ "eslint": "6.8.0",
+ "file-loader": "6.0.0",
+ "file-saver": "2.0.2",
+ "hyperscript": "2.0.2",
+ "izitoast": "1.4.0",
+ "node-sass": "4.13.1",
+ "normalize.css": "8.0.1",
+ "papaparse": "5.2.0",
+ "resolve-url-loader": "3.1.1",
+ "sass-lint": "1.13.1",
+ "sass-loader": "8.0.2",
+ "style-loader": "1.1.3",
+ "uri-js": "4.2.2",
+ "webpack": "4.42.1",
+ "webpack-cli": "3.3.11"
+ }
+}
diff --git a/pending/requirements.pacman.linux.txt b/pending/requirements.pacman.linux.txt
new file mode 100644
index 0000000..6b5d366
--- /dev/null
+++ b/pending/requirements.pacman.linux.txt
@@ -0,0 +1,5 @@
+git
+nodejs
+yarn
+python
+python-pip
diff --git a/pending/runtime.txt b/pending/runtime.txt
new file mode 100644
index 0000000..724c203
--- /dev/null
+++ b/pending/runtime.txt
@@ -0,0 +1 @@
+python-3.8.2
diff --git a/pending/webpack.config.js b/pending/webpack.config.js
new file mode 100644
index 0000000..57d31c1
--- /dev/null
+++ b/pending/webpack.config.js
@@ -0,0 +1,39 @@
+const path = require('path');
+const CopyWebpackPlugin = require('copy-webpack-plugin');
+
+
+module.exports = {
+ mode: 'none',
+ entry: '.' + path.sep + path.join('src_js', 'opcut', 'main'),
+ output: {
+ filename: 'main.js',
+ path: path.join(__dirname, 'build', 'js')
+ },
+ module: {
+ rules: [
+ {
+ test: /\.scss$/,
+ use: ["style-loader", "css-loader", "resolve-url-loader", "sass-loader?sourceMap"]
+ },
+ {
+ test: /\.woff2$/,
+ use: "file-loader?name=fonts/[name].[ext]"
+ }
+ ]
+ },
+ resolve: {
+ modules: [
+ path.join(__dirname, 'src_js'),
+ path.join(__dirname, 'src_scss'),
+ path.join(__dirname, 'node_modules')
+ ]
+ },
+ watchOptions: {
+ ignored: /node_modules/
+ },
+ plugins: [
+ new CopyWebpackPlugin([{from: 'src_web'}])
+ ],
+ devtool: 'source-map',
+ stats: 'errors-only'
+};