Skip to content

Commit

Permalink
Support building conda packages
Browse files Browse the repository at this point in the history
  • Loading branch information
csukuangfj committed Oct 4, 2022
1 parent 7831101 commit a64432d
Show file tree
Hide file tree
Showing 5 changed files with 278 additions and 0 deletions.
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
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: "1.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.

0 comments on commit a64432d

Please sign in to comment.