Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions .github/workflows/build_conda_macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: build_conda_macos

on:
push:
tags:
- '*'
branches:
- conda

concurrency:
group: build_conda_macos-${{ github.ref }}
cancel-in-progress: true

jobs:
build_conda_macos:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-10.15]
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]

steps:
# refer to https://github.com/actions/checkout
- uses: actions/checkout@v2
with:
fetch-depth: 0

- uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
activate-environment: kaldialign

- name: Display Python version
shell: bash -l {0}
run: |
python3 -c "import sys; print(sys.version)"
which python3

- name: Install conda dependencies
shell: bash -l {0}
run: |
conda install -y -q anaconda-client
conda install -y -q conda-build

- name: Display conda info
shell: bash -l {0}
run: |
which conda
conda env list
conda info

- name: Build kaldialign
shell: bash -l {0}
env:
KALDIALIGN_CONDA_TOKEN: ${{ secrets.KALDIALIGN_CONDA_TOKEN }}
run: |
./scripts/build_conda.sh

- name: Display generated files
run: |
ls -lh /usr/local/miniconda/envs/kaldialign/conda-bld/osx-64

- name: Upload generated files
uses: actions/upload-artifact@v2
with:
name: cpu-python-${{ matrix.python-version }}-${{ matrix.os }}
path: /usr/local/miniconda/envs/kaldialign/conda-bld/osx-64/*.tar.bz2
71 changes: 71 additions & 0 deletions .github/workflows/build_conda_ubuntu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: build_conda_ubuntu

on:
push:
tags:
- '*'
branches:
- conda

concurrency:
group: build_conda_ubuntu-${{ github.ref }}
cancel-in-progress: true

jobs:
build_conda_ubuntu:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-18.04]
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]

steps:
# refer to https://github.com/actions/checkout
- uses: actions/checkout@v2
with:
fetch-depth: 0

- uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
activate-environment: kaldialign

- name: Display Python version
shell: bash -l {0}
run: |
python3 -c "import sys; print(sys.version)"
which python3

- name: Install conda dependencies
shell: bash -l {0}
run: |
conda install -y -q anaconda-client
conda install -y -q conda-build
conda install -y -q numpy

- name: Display conda info
shell: bash -l {0}
run: |
which conda
conda env list
conda info
nproc

- name: Build kaldialign
shell: bash -l {0}
env:
KALDIALIGN_CONDA_TOKEN: ${{ secrets.KALDIALIGN_CONDA_TOKEN }}
run: |
./scripts/build_conda.sh

- name: Display generated files
run: |
ls -lh /usr/share/miniconda/envs/kaldialign/conda-bld/linux-64

- name: Upload generated files
uses: actions/upload-artifact@v2
with:
name: python-${{ matrix.python-version }}-${{ matrix.os }}
path: /usr/share/miniconda/envs/kaldialign/conda-bld/linux-64/*.tar.bz2
73 changes: 73 additions & 0 deletions .github/workflows/build_conda_windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: build_conda_windows

on:
push:
tags:
- '*'
branches:
- conda

concurrency:
group: build_conda_windows-${{ github.ref }}
cancel-in-progress: true

jobs:
build_conda_windows:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-2019]
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]

steps:
# refer to https://github.com/actions/checkout
- uses: actions/checkout@v2
with:
fetch-depth: 0

- uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
activate-environment: kaldialign

- name: Display Python version
shell: bash -l {0}
run: |
python -c "import sys; print(sys.version)"
which python

- name: Install conda dependencies
shell: bash -l {0}
run: |
conda install -y -q anaconda-client
conda install -y -q conda-build

- name: Display conda info
shell: bash -l {0}
run: |
which conda
conda env list
conda info
which python

- name: Build kaldialign
shell: bash -l {0}
env:
KALDIALIGN_CONDA_TOKEN: ${{ secrets.KALDIALIGN_CONDA_TOKEN }}
run: |
./scripts/build_conda.sh

- name: Display generated files
shell: bash -l {0}
run: |
ls -lh /c/Miniconda/envs/kaldialign/conda-bld
ls -lh /c/Miniconda/envs/kaldialign/conda-bld/*/*
ls -lh /c/Miniconda/envs/kaldialign/conda-bld/win-64/*

- name: Upload generated files
uses: actions/upload-artifact@v2
with:
name: python-${{ matrix.python-version }}-windows-2019
path: c:/Miniconda/envs/kaldialign/conda-bld/win-64/*.tar.bz2
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ cmake_minimum_required(VERSION 3.8 FATAL_ERROR)

project(kaldialign CXX)

# Please remember to also change line 3 of ./scripts/conda/kaldialign/meta.yaml
set(KALDIALIGN_VERSION "0.4")

if(NOT CMAKE_BUILD_TYPE)
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ A small package that exposes edit distance computation functions from [Kaldi](ht

## Installation

```bash
conda install -c kaldialign kaldialign
```

or

```bash
pip install --verbose kaldialign
```
Expand Down Expand Up @@ -33,7 +39,7 @@ EPS = '*'
a = ['a', 'b', 'c']
b = ['a', 's', 'x', 'c']
ali = align(a, b, EPS)
assert ali == [('a', 'a'), (b, 's'), (EPS, 'x'), ('c', 'c')]
assert ali == [('a', 'a'), ('b', 's'), (EPS, 'x'), ('c', 'c')]
```

- `edit_distance(seq1, seq2)` - used to obtain the total edit distance, as well as the number of insertions, deletions and substitutions.
Expand Down
32 changes: 32 additions & 0 deletions scripts/build_conda.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash
#
# The following environment variables are supposed to be set by users
#
# - KALDIALIGN_CONDA_TOKEN
# If not set, auto upload to anaconda.org is disabled.
#
# Its value is from https://anaconda.org/kaldialign/settings/access
# (You need to login as user kaldialign to see its value)
#
set -e
export CONDA_BUILD=1

cur_dir=$(cd $(dirname $BASH_SOURCE) && pwd)
kaldialign_dir=$(cd $cur_dir/.. && pwd)

cd $kaldialign_dir

export KALDIALIGN_ROOT_DIR=$kaldialign_dir
echo "KALDIALIGN_DIR: $KALDIALIGN_ROOT_DIR"

KALDIALIGN_PYTHON_VERSION=$(python -c "import sys; print('.'.join(sys.version.split('.')[:2]))")

# Example value: 3.8
export KALDIALIGN_PYTHON_VERSION

if [ -z $KALDIALIGN_CONDA_TOKEN ]; then
echo "Auto upload to anaconda.org is disabled since KALDIALIGN_CONDA_TOKEN is not set"
conda build --no-test --no-anaconda-upload ./scripts/conda/kaldialign
else
conda build --no-test --token $KALDIALIGN_CONDA_TOKEN ./scripts/conda/kaldialign
fi
33 changes: 33 additions & 0 deletions scripts/conda/kaldialign/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package:
name: kaldialign
version: "0.4"

source:
path: "{{ environ.get('KALDIALIGN_ROOT_DIR') }}"

build:
number: 0
string: py{{ environ.get('KALDIALIGN_PYTHON_VERSION') }}
script: {{ PYTHON }} setup.py install --single-version-externally-managed --record=record.txt

requirements:
build:
- {{ compiler('c') }} # [win]
- {{ compiler('cxx') }} # [win]

host:
- anaconda-client
- conda-build
- cmake
- python
run:
- python

about:
home: https://github.com/pzelasko/kaldialign
license: Apache V2
license_file: LICENSE
summary: Python wrappers for Kaldi Levenshtein's distance and alignment code.
description: |
A small package that exposes edit distance computation functions from Kaldi.
It uses the original Kaldi code and wraps it using pybind11.