-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8948216
commit 8c3d6b3
Showing
7 changed files
with
396 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#!/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 = 'clinguin' | ||
|
||
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.') | ||
args = parser.parse_args() | ||
if args.release: | ||
label = None | ||
channels = ['potassco'] | ||
else: | ||
label = "dev" | ||
channels = ['potassco/label/dev', 'potassco'] | ||
|
||
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') | ||
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{% set name = 'clinguin' %} | ||
{% set dev = not environ.get('BUILD_RELEASE', false) %} | ||
{% set version = environ.get('VERSION_NUMBER') %} | ||
{% set revision = environ.get('GITHUB_SHA', 'wip') %} | ||
{% set build = environ.get('BUILD_NUMBER', "0") %} | ||
|
||
package: | ||
name: {{ name }} | ||
version: {{ version }} | ||
|
||
source: | ||
path: ../.. | ||
|
||
requirements: | ||
host: | ||
- python >=3.8 | ||
- pip | ||
run: | ||
- clingo>=5.6.0 | ||
- clorm>=1.4.1 | ||
- clingo-dl | ||
- httpx==0.20.0 | ||
- fastapi | ||
- pydantic | ||
- networkx | ||
- uvicorn | ||
- httpcore==0.13.3 | ||
- h11==0.12.0 | ||
- clingraph | ||
- Pillow | ||
|
||
build: | ||
number: {{ build }} | ||
noarch: python | ||
script: python -m pip install --no-deps --ignore-installed . | ||
entry_points: ['clinguin = clinguin:main'] | ||
|
||
|
||
about: | ||
home: https://potassco.org/ | ||
license: MIT | ||
license_family: MIT | ||
license_file: LICENSE | ||
summary: A system to build User Interfaces in ASP | ||
doc_url: https://clinguin.readthedocs.io/en/latest/index.html | ||
dev_url: https://github.com/potassco/{{ name }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# do not edit the workflows, they are generated from this file | ||
pip: | ||
pure: True | ||
version: | | ||
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) | ||
build_depends_release: | | ||
python3 -m pip install --user -r .github/requirements.txt | ||
build_depends_dev: | | ||
python3 -m pip install --user --extra-index-url https://test.pypi.org/simple/ -r .github/requirements.txt | ||
conda: | ||
package_name: | ||
'clinguin' | ||
os: | ||
- 'ubuntu-latest' | ||
channels_release: | ||
- 'potassco' | ||
channels_dev: | ||
- 'potassco/label/dev' | ||
- 'potassco' | ||
version: | | ||
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) | ||
meta: | ||
url: https://github.com/potassco/{{ name }}/archive/v{{ version }}.tar.gz | ||
git_url: https://github.com/potassco/{{ name }}.git | ||
requirements: | ||
host: | ||
- python >=3.8 | ||
- pip | ||
run: | ||
- clingo>=5.6.0 | ||
- clorm>=1.4.1 | ||
- clingo-dl | ||
- httpx==0.20.0 | ||
- fastapi | ||
- pydantic | ||
- networkx | ||
- uvicorn | ||
- httpcore==0.13.3 | ||
- h11==0.12.0 | ||
- clingraph | ||
- Pillow | ||
|
||
build: | ||
noarch: python | ||
script: 'python -m pip install --no-deps --ignore-installed .' | ||
entry_points: | ||
- clinguin = clinguin:main | ||
|
||
about: | ||
home: https://potassco.org/ | ||
license: MIT | ||
license_family: MIT | ||
license_file: LICENSE | ||
summary: A system to build User Interfaces in ASP | ||
|
||
doc_url: https://clinguin.readthedocs.io/en/latest/index.html | ||
dev_url: https://github.com/potassco/{{ name }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
''' | ||
Script to build pip source package. | ||
''' | ||
|
||
import argparse | ||
from re import finditer, escape, match, sub, search | ||
from subprocess import check_call, check_output | ||
from os.path import exists | ||
|
||
def adjust_version(url): | ||
''' | ||
Adjust version in setup.py. | ||
''' | ||
if exists('setup.cfg'): | ||
setup_type = 'cfg' | ||
setup_path = 'setup.cfg' | ||
else: | ||
setup_type = 'py' | ||
setup_path = 'setup.py' | ||
|
||
with open(setup_path) as fr: | ||
setup = fr.read() | ||
|
||
if setup_type == 'cfg': | ||
package_name = search(r'name[ ]*=[ ]*(.*)[ ]*', setup).group(1) | ||
package_regex = package_name.replace('-', '[-_]') | ||
else: | ||
package_name = search(r'''name[ ]*=[ ]*['"]([^'"]*)['"]''', setup).group(1) | ||
package_regex = package_name.replace('-', '[-_]') | ||
|
||
pip = check_output(['curl', '-sL', '{}/{}'.format(url, package_name)]).decode() | ||
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 | ||
|
||
post = 0 | ||
for m in finditer(r'{}-{}\.tar\.gz'.format(package_regex, escape(version)), pip): | ||
post = max(post, 1) | ||
|
||
for m in finditer(r'{}-{}\.post([0-9]+)\.tar\.gz'.format(package_regex, escape(version)), pip): | ||
post = max(post, int(m.group(1)) + 1) | ||
|
||
for m in finditer(r'{}-{}\.post([0-9]+).*\.whl'.format(package_regex, escape(version)), pip): | ||
post = max(post, int(m.group(1))) | ||
|
||
with open(setup_path, 'w') as fw: | ||
if setup_type == 'cfg': | ||
if post > 0: | ||
fw.write(sub('version( *)=.*', 'version = {}.post{}'.format(version, post), setup, 1)) | ||
else: | ||
fw.write(sub('version( *)=.*', 'version = {}'.format(version), setup, 1)) | ||
else: | ||
if post > 0: | ||
fw.write(sub('version( *)=.*', 'version = \'{}.post{}\','.format(version, post), setup, 1)) | ||
else: | ||
fw.write(sub('version( *)=.*', 'version = \'{}\','.format(version), setup, 1)) | ||
|
||
def run(): | ||
parser = argparse.ArgumentParser(description='Build source package.') | ||
parser.add_argument('--release', action='store_true', help='Build release package.') | ||
args = parser.parse_args() | ||
if args.release: | ||
url = 'https://pypi.org/simple' | ||
else: | ||
url = 'https://test.pypi.org/simple' | ||
|
||
adjust_version(url) | ||
check_call(['python3', 'setup.py', 'sdist', 'bdist_wheel']) | ||
|
||
if __name__ == "__main__": | ||
run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
clingo>=5.6.0 | ||
clorm>=1.4.1 | ||
clingo-dl | ||
httpx==0.20.0 | ||
fastapi | ||
pydantic | ||
networkx | ||
uvicorn | ||
httpcore==0.13.3 | ||
h11==0.12.0 | ||
clingraph | ||
Pillow |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
name: Deploy conda packages (wip) | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
wip: | ||
description: 'Publish work in progress package.' | ||
required: false | ||
default: 'true' | ||
|
||
jobs: | ||
build: | ||
name: deploy on ${{ matrix.os }} using python-${{ matrix.python-version }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: | ||
- ubuntu-latest | ||
python-version: ['3.8'] | ||
|
||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v2 | ||
with: | ||
submodules: recursive | ||
|
||
- name: setup miniconda | ||
uses: conda-incubator/setup-miniconda@v2 | ||
with: | ||
auto-update-conda: true | ||
python-version: ${{ matrix.python-version }} | ||
activate-environment: build | ||
|
||
- name: Install prerequisites | ||
shell: pwsh | ||
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 (wip) | ||
if: ${{ github.event.inputs.wip == 'true' }} | ||
shell: pwsh | ||
run: | | ||
python .github/conda.py | ||
env: | ||
ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_TOKEN }} | ||
|
||
- name: publish conda package (release) | ||
if: ${{ github.event.inputs.wip == 'false' }} | ||
shell: pwsh | ||
run: | | ||
python .github/conda.py --release | ||
env: | ||
ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_TOKEN }} |
Oops, something went wrong.