Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conda build #14

Merged
merged 4 commits into from
Mar 25, 2022
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
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ Or even easier, install directly from PyPI:
```bash
pip install bifixer
```

Also, you can install the conda package:

```bash
conda install -c bitextor bifixer
```

After installing, two executables (`bifixer` and `monofixer`) will be available to be run.

### Loomchild segmenter ###
Expand Down
6 changes: 6 additions & 0 deletions conda_build/bifixer/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

export PIP_NO_INDEX="False" # We are downloading requisites from PyPi
export PIP_NO_DEPENDENCIES="False" # We need the dependencies from our defined dependencies
export PIP_IGNORE_INSTALLED="False" # We need to take into account the dependencies

$PYTHON -m pip install .[loomchild]
35 changes: 35 additions & 0 deletions conda_build/bifixer/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

{% set rdir = "../.." %}
{% set data = load_setup_py_data(setup_file=''+rdir+'/setup.py', from_recipe_dir=True) %}

package:
name: bifixer
version: {{ data.get('version') }}

source:
path: {{ rdir }}

build:
string: {{ environ.get('GIT_DESCRIBE_HASH') }}
preserve_egg_dir: True

requirements:
build:
- pip
- setuptools
- python>=3.7
run:
- python>=3.7

test:
source_files:
- tests/*
requires:
- pytest
commands:
- pushd tests; pytest; popd

about:
home: https://github.com/bitextor/bifixer
license: GPL3
summary: Tool to fix bitexts and tag near-duplicates for removal
78 changes: 78 additions & 0 deletions conda_build/make_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#!/usr/bin/env bash

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

usage()
{
echo "$(basename $0) [-h] [-e <CONDA_ENV_NAME>] [-r] -n <package_name>"
echo ""
echo "OPTIONS:"
echo " -e <CONDA_ENV_NAME> Name of the conda environment which will be used to build"
echo " Bifixer. If not specified, the default value is"
echo " the provided package name with the suffix '-build'."
echo " -r It removes the conda environment before start if exists."
echo " -h It displays this help message."
echo " -n Conda package name in order to retrieve the pkg path"
}

CONDA_ENV_NAME=""
CONDA_PACKAGE_NAME=""
REMOVE_ENV_IF_EXISTS=""

while getopts "e:n:rh" options
do
case "${options}" in
e) CONDA_ENV_NAME=$OPTARG;;
r) REMOVE_ENV_IF_EXISTS="y";;
h) usage
exit 0;;
n) CONDA_PACKAGE_NAME=$OPTARG;;
\?) usage 1>&2
exit 1;;
esac
done

if [[ "$CONDA_PACKAGE_NAME" == "" ]]; then
>&2 echo "Error: package name is mandatory"
>&2 echo ""
usage 1>&2
exit 1
fi

if [[ "$CONDA_ENV_NAME" == "" ]]; then
CONDA_ENV_NAME="${CONDA_PACKAGE_NAME}-build"
fi

CONDA_PACKAGE_PATH="${SCRIPT_DIR}/${CONDA_PACKAGE_NAME}"

if [[ ! -f "${CONDA_PACKAGE_PATH}/meta.yaml" ]]; then
>&2 echo "File 'meta.yaml' not found: ${CONDA_PACKAGE_PATH}/meta.yaml"
exit 1
fi

source $(conda info --base)/etc/profile.d/conda.sh

if [[ "$REMOVE_ENV_IF_EXISTS" == "y" ]]; then
conda remove -y -n $CONDA_ENV_NAME --all
fi

if [[ "$(conda env list | grep ^$CONDA_ENV_NAME[\ +])" != "" ]]; then
>&2 echo "Error: conda environment '$CONDA_ENV_NAME' already exists"
>&2 echo ""
usage 1>&2
exit 1
fi

conda create -y -n $CONDA_ENV_NAME -c conda-forge conda-build conda-verify
conda activate $CONDA_ENV_NAME

echo "git describe --tags:"
git describe --tags || true

echo "git describe --always:"
git describe --always

CONDA_CHANNELS="-c conda-forge"

# Make build
conda-build --no-anaconda-upload --no-test $CONDA_CHANNELS $CONDA_PACKAGE_PATH