diff --git a/.github/conda.py b/.github/conda.py new file mode 100644 index 00000000..54346c09 --- /dev/null +++ b/.github/conda.py @@ -0,0 +1,83 @@ +#!/usr/bin/env python +''' +Simple script to call conda build with the current revision and version. +''' + +import argparse +import subprocess +import json +from re import match +import os + +NAME = 'viasp' + +def get_build_number(channels, version): + ''' + Get the next build number. + ''' + try: + pkgs = json.loads(subprocess.check_output(['conda', 'search', '--json', '-c', channels[0], NAME])) + except subprocess.CalledProcessError: + pkgs = {NAME: []} + + + build_number = -1 + for pkg in pkgs.get(NAME, []): + if pkg['channel'].find(channels[0]) >= 0 and pkg["version"] == version: + build_number = max(build_number, pkg['build_number']) + + return build_number + 1 + +def run(): + ''' + Compile and upload conda packages. + ''' + + parser = argparse.ArgumentParser(description='Build conda packages.') + parser.add_argument('--release', action='store_true', help='Build release packages.') + parser.add_argument('--package', type=str, help='Package to build. (frontend, backend, or viasp)', default='frontend') + args = parser.parse_args() + if args.release: + label = None + channels = ['potassco'] + else: + label = "dev" + channels = ['potassco/label/dev', 'potassco'] + + path = 'viasp-dash' + if args.package == 'backend': + path = 'viasp-backend' + channels.extend(['conda-forge']) + elif args.package == 'viasp': + path = 'viasp' + channels.extend(['conda-forge', 'stephanzwicknagl/label/dev']) # change this to wherever the viasp-dash and viasp-backend are hosted + + version = None + with open('setup.cfg') as fh: + for line in fh: + m = match(r'''[ ]*version[ ]*=[ ]*([0-9]+\.[0-9]+\.[0-9]+)(\.post[0-9]+)?''', line) + if m is not None: + version = m.group(1) + assert version is not None + build_number = get_build_number(channels, version) + + build_env = os.environ.copy() + build_env.pop("BUILD_RELEASE", "1" if args.release else None) + build_env["VERSION_NUMBER"] = version + build_env["BUILD_NUMBER"] = str(build_number) + if 'GITHUB_SHA' in os.environ: + build_env["BUILD_REVISION"] = os.environ['GITHUB_SHA'] + + recipe_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'conda', path) + options = ['conda', 'build'] + if label is not None: + options.extend(['--label', label]) + + for c in channels: + options.extend(['-c', c]) + options.append(recipe_path) + + subprocess.check_call(options, env=build_env) + +if __name__ == '__main__': + run() \ No newline at end of file diff --git a/.github/conda/viasp-backend/meta.yaml b/.github/conda/viasp-backend/meta.yaml new file mode 100644 index 00000000..fb36117d --- /dev/null +++ b/.github/conda/viasp-backend/meta.yaml @@ -0,0 +1,48 @@ +{% set name = "viasp-backend" %} +{% set version = environ.get('VERSION_NUMBER') %} +{% set dev = not environ.get('BUILD_RELEASE', false) %} +{% set revision = environ.get('GITHUB_SHA', 'wip') %} +{% set build = environ.get('BUILD_NUMBER', "0") %} + +package: + name: {{ name|lower }} + version: {{ version }} + +source: + path: ../../../backend + +build: + noarch: python + script: python -m pip install --no-deps --ignore-installed . + number: {{ build }} + entry_points: + ['viasp_server = viasp.__main__:backend', + 'viasp = viasp.__main__:start'] + +requirements: + host: + - python >=3.7 + - setuptools >=42 + - wheel + - pip + run: + - python >=3.7 + - networkx >=2.4 + - flask ==2.2.0 + - werkzeug ==2.2.2 + - clingo >=5.6.0 + - flask-cors >=3.0 + - requests >=2.26.0 + - igraph >=0.8 + - numpy + - clingraph + +about: + home: https://github.com/potassco/viasp + summary: The backend for the viasp package. + license: MIT + license_file: LICENCE.md + +extra: + recipe-maintainers: + - stephanzwicknagl diff --git a/.github/conda/viasp-dash/meta.yaml b/.github/conda/viasp-dash/meta.yaml new file mode 100644 index 00000000..c15c680b --- /dev/null +++ b/.github/conda/viasp-dash/meta.yaml @@ -0,0 +1,39 @@ +{% set name = "viasp-dash" %} +{% set version = "2.0.2" %} + +package: + name: {{ name|lower }} + version: {{ version }} + +source: + path: ../../../frontend + +build: + noarch: python + script: {{ PYTHON }} -m pip install . -vv --no-deps --no-build-isolation + number: 0 + +requirements: + host: + - python + - pip + run: + - python + - dash >=2 + +test: + imports: + - viasp_dash + commands: + - pip check + requires: + - pip + +about: + summary: The dash frontend for the viasp package. + license: MIT + license_file: LICENCE.md + +extra: + recipe-maintainers: + - stephanzwicknagl diff --git a/.github/conda/viasp/meta.yaml b/.github/conda/viasp/meta.yaml new file mode 100644 index 00000000..f8766760 --- /dev/null +++ b/.github/conda/viasp/meta.yaml @@ -0,0 +1,44 @@ +{% set name = "viasp" %} +{% set version = "2.0.2" %} + +package: + name: {{ name|lower }} + version: {{ version }} + +source: + path: ../../.. + +build: + noarch: python + script: {{ PYTHON }} -m pip install . -vv --no-deps --no-build-isolation + number: {{ build }} + +requirements: + host: + - python >=3.7 + - setuptools >=42 + - wheel + - pip + run: + - python >=3.7 + - viasp-backend + - viasp-dash + - jupyter-server-proxy + - clingraph + - python-graphviz + +test: + imports: + - viasp + - viasp_server + +about: + + home: https://github.com/potassco/viasp + summary: a visualization tool for clingo. + license: MIT + license_file: LICENCE.md + +extra: + recipe-maintainers: + - stephanzwicknagl diff --git a/.github/workflows/publish_conda.yml b/.github/workflows/publish_conda.yml new file mode 100644 index 00000000..b017a2eb --- /dev/null +++ b/.github/workflows/publish_conda.yml @@ -0,0 +1,112 @@ +name: Deploy conda packages + +on: + workflow_dispatch: + inputs: + frontend: + type: boolean + required: true + description: Publish frontend of main HEAD + backend: + type: boolean + required: true + description: Publish backend of main HEAD + +jobs: + backend: + name: Publish backend + runs-on: ubuntu-latest + + steps: + - name: Checkout repo + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: setup miniconda + uses: conda-incubator/setup-miniconda@v3 + with: + auto-update-conda: true + python-version: 3.11 + activate-environment: build + + - name: Install prerequisites + run: | + conda config --set anaconda_upload yes + conda install conda-build anaconda-client + - name: print info + shell: pwsh + run: | + conda info + conda list + - name: publish conda package backend + shell: pwsh + run: | + python .github/conda.py --package backend + env: + ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_TOKEN }} + + frontend: + name: Publish frontend + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: setup miniconda + uses: conda-incubator/setup-miniconda@v3 + with: + auto-update-conda: true + python-version: 3.11 + activate-environment: build + + - name: Install prerequisites + run: | + conda config --set anaconda_upload yes + conda install conda-build anaconda-client + - name: print info + shell: pwsh + run: | + conda info + conda list + - name: publish conda package frontend + shell: pwsh + run: | + python .github/conda.py --package frontend + env: + ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_TOKEN }} + + wrapper: + needs: [ frontend, backend ] + name: Publish container + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: setup miniconda + uses: conda-incubator/setup-miniconda@v3 + with: + auto-update-conda: true + python-version: 3.11 + activate-environment: build + + - name: Install prerequisites + run: | + conda config --set anaconda_upload yes + conda install conda-build anaconda-client + - name: print info + shell: pwsh + run: | + conda info + conda list + - name: publish conda package wrapper + shell: pwsh + run: | + python .github/conda.py --package viasp + env: + ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish_pypi.yml similarity index 100% rename from .github/workflows/publish.yml rename to .github/workflows/publish_pypi.yml diff --git a/backend/LICENCE.md b/backend/LICENCE.md new file mode 100644 index 00000000..c55685c3 --- /dev/null +++ b/backend/LICENCE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 Luis Glaser, Stephan Zwicknagl + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/backend/setup.cfg b/backend/setup.cfg index d7dac2ff..d81c621b 100644 --- a/backend/setup.cfg +++ b/backend/setup.cfg @@ -23,7 +23,6 @@ install_requires = Werkzeug==2.2.2 clingo>=5.6.0 flask-cors>=3.0 - clingox>=1.0.0 requests>=2.26.0 igraph>=0.8 numpy diff --git a/frontend/LICENCE.md b/frontend/LICENCE.md new file mode 100644 index 00000000..c55685c3 --- /dev/null +++ b/frontend/LICENCE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 Luis Glaser, Stephan Zwicknagl + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/requirements.txt b/requirements.txt index f84c1117..15ad2935 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,7 +3,6 @@ flask>=2.0,<=2.2.5 Werkzeug==2.2.2 networkx>=2.6 pytest>=6.2.4 -clingox>=1.0.0 requests dash flask-cors