From 37e8c614e5cea111e457af0187b38d3fa942010e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristian=20Garc=C3=ADa=20Romero?= Date: Wed, 23 Feb 2022 13:43:58 +0100 Subject: [PATCH 01/10] Conda build recipe --- conda_build/build.bat | 20 ++++++++++++++++++++ conda_build/build.sh | 18 ++++++++++++++++++ conda_build/meta.yaml | 39 +++++++++++++++++++++++++++++++++++++++ setup.py | 2 ++ 4 files changed, 79 insertions(+) create mode 100644 conda_build/build.bat create mode 100644 conda_build/build.sh create mode 100644 conda_build/meta.yaml diff --git a/conda_build/build.bat b/conda_build/build.bat new file mode 100644 index 000000000..518ee5fe1 --- /dev/null +++ b/conda_build/build.bat @@ -0,0 +1,20 @@ + +@echo off + +set DIR="%RECIPE_DIR%/%RDIR%" + +echo "DIR: %DIR%" +echo "KENLM_MAX_ORDER: %KENLM_MAX_ORDER%" + +mkdir %DIR%/build_conda + +echo " - Building..." +cd %DIR%/build_conda +cmake .. -DKENLM_MAX_ORDER=%KENLM_MAX_ORDER% -DCMAKE_INSTALL_PREFIX:PATH=%PREFIX% +echo " - Installing..." +make -j all install +cd %DIR% +rmdir /S /Q %DIR%/build_conda + +echo " - Installing python module..." +"%PYTHON%" -m pip install "%DIR%" --install-option="--max_order %KENLM_MAX_ORDER%" diff --git a/conda_build/build.sh b/conda_build/build.sh new file mode 100644 index 000000000..e75b88a38 --- /dev/null +++ b/conda_build/build.sh @@ -0,0 +1,18 @@ + +DIR="${RECIPE_DIR}/${RDIR}" + +echo "DIR: $DIR" +echo "KENLM_MAX_ORDER: $KENLM_MAX_ORDER" + +mkdir -p $DIR/build_conda + +echo -e " - \e[4mBuilding...\e[0m" +cd $DIR/build_conda +cmake .. -DKENLM_MAX_ORDER=$KENLM_MAX_ORDER -DCMAKE_INSTALL_PREFIX:PATH=$PREFIX +echo -e " - \e[4mInstalling...\e[0m" +make -j all install +cd $DIR +rm -rf $DIR/build_conda + +echo -e " - \e[4mInstalling python module...\e[0m" +$PYTHON -m pip install $DIR --install-option="--max_order $KENLM_MAX_ORDER" diff --git a/conda_build/meta.yaml b/conda_build/meta.yaml new file mode 100644 index 000000000..75da04a77 --- /dev/null +++ b/conda_build/meta.yaml @@ -0,0 +1,39 @@ + +{% set rdir = ".." %} +{% set data = load_setup_py_data(setup_file=''+rdir+'/setup.py', from_recipe_dir=True) %} + +package: + name: kenlm + version: {{ data.get('version') }} + +source: + path: {{ rdir }} + +build: + string: {{ environ.get('GIT_DESCRIBE_HASH') }} + script_env: + - RDIR={{ rdir }} + - KENLM_MAX_ORDER=7 + - PIP_NO_INDEX=False # Allow requisites from PyPi + - PIP_NO_DEPENDENCIES=False # Install dependencies from our defined dependencies + - PIP_IGNORE_INSTALLED=False # Take into account the current installed dependencies + +requirements: + build: + - python + - pip + - setuptools + - make + - cmake + - gcc_linux-64 + - gxx_linux-64 + - libboost + + run: + - python + - libboost + +about: + home: https://github.com/kpu/kenlm + license: LGPL + summary: Faster and Smaller Language Model Queries diff --git a/setup.py b/setup.py index 9e0f0d155..26b9e418a 100644 --- a/setup.py +++ b/setup.py @@ -4,6 +4,7 @@ import os import sys import re +from datetime import date #Does gcc compile with this header and library? def compile_test(header, library): @@ -57,6 +58,7 @@ def compile_test(header, library): setup( name='kenlm', + version=date.today().strftime('%Y%m%d'), ext_modules=ext_modules, include_package_data=True, ) From f0c74ea91b72a919615e2466b5351e214675b301 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristian=20Garc=C3=ADa=20Romero?= Date: Wed, 23 Feb 2022 17:21:11 +0100 Subject: [PATCH 02/10] Fix and update conda build scripts --- conda_build/{build.bat => bld.bat} | 7 ++++--- conda_build/build.sh | 7 ++++--- conda_build/meta.yaml | 8 ++++---- 3 files changed, 12 insertions(+), 10 deletions(-) rename conda_build/{build.bat => bld.bat} (78%) diff --git a/conda_build/build.bat b/conda_build/bld.bat similarity index 78% rename from conda_build/build.bat rename to conda_build/bld.bat index 518ee5fe1..8d80b72ea 100644 --- a/conda_build/build.bat +++ b/conda_build/bld.bat @@ -6,15 +6,16 @@ set DIR="%RECIPE_DIR%/%RDIR%" echo "DIR: %DIR%" echo "KENLM_MAX_ORDER: %KENLM_MAX_ORDER%" -mkdir %DIR%/build_conda +if exist %DIR%/build ( rmdir /S /Q %DIR%/build ) +mkdir %DIR%/build echo " - Building..." -cd %DIR%/build_conda +cd %DIR%/build cmake .. -DKENLM_MAX_ORDER=%KENLM_MAX_ORDER% -DCMAKE_INSTALL_PREFIX:PATH=%PREFIX% echo " - Installing..." make -j all install cd %DIR% -rmdir /S /Q %DIR%/build_conda +rmdir /S /Q %DIR%/build echo " - Installing python module..." "%PYTHON%" -m pip install "%DIR%" --install-option="--max_order %KENLM_MAX_ORDER%" diff --git a/conda_build/build.sh b/conda_build/build.sh index e75b88a38..706f73985 100644 --- a/conda_build/build.sh +++ b/conda_build/build.sh @@ -4,15 +4,16 @@ DIR="${RECIPE_DIR}/${RDIR}" echo "DIR: $DIR" echo "KENLM_MAX_ORDER: $KENLM_MAX_ORDER" -mkdir -p $DIR/build_conda +[[ -d $DIR/build ]] && rm -rf $DIR/build +mkdir -p $DIR/build echo -e " - \e[4mBuilding...\e[0m" -cd $DIR/build_conda +cd $DIR/build cmake .. -DKENLM_MAX_ORDER=$KENLM_MAX_ORDER -DCMAKE_INSTALL_PREFIX:PATH=$PREFIX echo -e " - \e[4mInstalling...\e[0m" make -j all install cd $DIR -rm -rf $DIR/build_conda +rm -rf $DIR/build echo -e " - \e[4mInstalling python module...\e[0m" $PYTHON -m pip install $DIR --install-option="--max_order $KENLM_MAX_ORDER" diff --git a/conda_build/meta.yaml b/conda_build/meta.yaml index 75da04a77..9a9382056 100644 --- a/conda_build/meta.yaml +++ b/conda_build/meta.yaml @@ -20,15 +20,15 @@ build: requirements: build: - - python - - pip - - setuptools + - git - make - cmake - gcc_linux-64 - gxx_linux-64 + - python + - pip + - setuptools - libboost - run: - python - libboost From fa9b0083c1cf6f27c44fd75521209ddb05435564 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristian=20Garc=C3=ADa=20Romero?= Date: Fri, 25 Feb 2022 14:16:03 +0100 Subject: [PATCH 03/10] Fix build path --- conda_build/bld.bat | 17 +++++++---------- conda_build/build.sh | 23 ++++++++++------------- conda_build/meta.yaml | 1 - 3 files changed, 17 insertions(+), 24 deletions(-) diff --git a/conda_build/bld.bat b/conda_build/bld.bat index 8d80b72ea..a7f9e8058 100644 --- a/conda_build/bld.bat +++ b/conda_build/bld.bat @@ -1,21 +1,18 @@ @echo off -set DIR="%RECIPE_DIR%/%RDIR%" +set BDIR="./build" -echo "DIR: %DIR%" -echo "KENLM_MAX_ORDER: %KENLM_MAX_ORDER%" - -if exist %DIR%/build ( rmdir /S /Q %DIR%/build ) -mkdir %DIR%/build +if exist %BDIR% ( rmdir /S /Q %BDIR% ) +mkdir %BDIR% echo " - Building..." -cd %DIR%/build +pushd %BDIR% cmake .. -DKENLM_MAX_ORDER=%KENLM_MAX_ORDER% -DCMAKE_INSTALL_PREFIX:PATH=%PREFIX% echo " - Installing..." make -j all install -cd %DIR% -rmdir /S /Q %DIR%/build +popd +rmdir /S /Q %BDIR% echo " - Installing python module..." -"%PYTHON%" -m pip install "%DIR%" --install-option="--max_order %KENLM_MAX_ORDER%" +"%PYTHON%" -m pip install . --install-option="--max_order %KENLM_MAX_ORDER%" diff --git a/conda_build/build.sh b/conda_build/build.sh index 706f73985..7e819376c 100644 --- a/conda_build/build.sh +++ b/conda_build/build.sh @@ -1,19 +1,16 @@ -DIR="${RECIPE_DIR}/${RDIR}" +BDIR="./build" -echo "DIR: $DIR" -echo "KENLM_MAX_ORDER: $KENLM_MAX_ORDER" +[[ -d $BDIR ]] && rm -rf $BDIR +mkdir $BDIR -[[ -d $DIR/build ]] && rm -rf $DIR/build -mkdir -p $DIR/build - -echo -e " - \e[4mBuilding...\e[0m" -cd $DIR/build +echo " - Building..." +pushd $BDIR cmake .. -DKENLM_MAX_ORDER=$KENLM_MAX_ORDER -DCMAKE_INSTALL_PREFIX:PATH=$PREFIX -echo -e " - \e[4mInstalling...\e[0m" +echo " - Installing..." make -j all install -cd $DIR -rm -rf $DIR/build +popd +rm -rf $BDIR -echo -e " - \e[4mInstalling python module...\e[0m" -$PYTHON -m pip install $DIR --install-option="--max_order $KENLM_MAX_ORDER" +echo " - Installing python module..." +$PYTHON -m pip install . --install-option="--max_order $KENLM_MAX_ORDER" diff --git a/conda_build/meta.yaml b/conda_build/meta.yaml index 9a9382056..a3eca7240 100644 --- a/conda_build/meta.yaml +++ b/conda_build/meta.yaml @@ -12,7 +12,6 @@ source: build: string: {{ environ.get('GIT_DESCRIBE_HASH') }} script_env: - - RDIR={{ rdir }} - KENLM_MAX_ORDER=7 - PIP_NO_INDEX=False # Allow requisites from PyPi - PIP_NO_DEPENDENCIES=False # Install dependencies from our defined dependencies From 08bd401ac2c1a93eb62709a0b0bf657e172a9841 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristian=20Garc=C3=ADa=20Romero?= Date: Mon, 28 Feb 2022 14:40:31 +0100 Subject: [PATCH 04/10] Update meta.yaml --- conda_build/meta.yaml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/conda_build/meta.yaml b/conda_build/meta.yaml index a3eca7240..60a943bda 100644 --- a/conda_build/meta.yaml +++ b/conda_build/meta.yaml @@ -19,14 +19,13 @@ build: requirements: build: - - git + - {{ compiler('cxx') }} - make - cmake - - gcc_linux-64 - - gxx_linux-64 - - python + host: - pip - setuptools + - python - libboost run: - python From 26f5ba1aeef12bd6fa7fba78a1c68cf79ac1635c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristian=20Garc=C3=ADa=20Romero?= Date: Mon, 28 Feb 2022 14:41:43 +0100 Subject: [PATCH 05/10] Create README.md --- conda_build/README.md | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 conda_build/README.md diff --git a/conda_build/README.md b/conda_build/README.md new file mode 100644 index 000000000..ac1868f5e --- /dev/null +++ b/conda_build/README.md @@ -0,0 +1,41 @@ +# Conda build + +Instructions in order to create, install and upload a conda package. kenlm is available on Windows, Ubuntu and Mac, so the package is it as well. + +You will need to [download](https://docs.conda.io/en/latest/miniconda.html) and [install](https://conda.io/projects/conda/en/latest/user-guide/install/index.html) Miniconda. + +## Create package + +First, you will need to install some dependencies: + +```bash +conda install -y -c conda-forge conda-build +# Mandatory for Windows, optional otherwise +conda install -y -c conda-forge git +``` + +Once the dependencies are installed, we can create the package: + +```bash +conda build --no-anaconda-upload -c conda-forge -c defaults ./conda_build +``` + +When the build finishes, the path to the package should be printed in the log. The path to the package should have the following structure: + +``` +${CONDA_PREFIX}/conda-bld/{target_arch}/kenlm-{build_date}-{commit}.tar.bz2 +``` + +## Upload package + +If you want to upload your package, install: + +```bash +conda install -y -c conda-forge anaconda-client +``` + +In order to upload the package, we just need to execute the following command and follow the instructions: + +```bash +anaconda upload /path/to/package +``` From 7e411ab9cbec58ccdb07ddab4c934fe55695f787 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristian=20Garc=C3=ADa=20Romero?= Date: Tue, 1 Mar 2022 12:47:36 +0100 Subject: [PATCH 06/10] Update README.md --- conda_build/README.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/conda_build/README.md b/conda_build/README.md index ac1868f5e..4b54ad74e 100644 --- a/conda_build/README.md +++ b/conda_build/README.md @@ -17,7 +17,7 @@ conda install -y -c conda-forge git Once the dependencies are installed, we can create the package: ```bash -conda build --no-anaconda-upload -c conda-forge -c defaults ./conda_build +conda build --build-only -c conda-forge ./conda_build ``` When the build finishes, the path to the package should be printed in the log. The path to the package should have the following structure: @@ -26,6 +26,15 @@ When the build finishes, the path to the package should be printed in the log. T ${CONDA_PREFIX}/conda-bld/{target_arch}/kenlm-{build_date}-{commit}.tar.bz2 ``` +If you install the generated package, the dependencies will not be installed. Run: + +```bash +# Install kenlm +conda install -y ${CONDA_PREFIX}/conda-bld/{target_arch}/kenlm-{build_date}-{commit}.tar.bz2 +# Install dependencies +conda update -y --only-deps -c conda-forge kenlm +``` + ## Upload package If you want to upload your package, install: From d54f124f5ca324d8e954c9482802f47062bd99db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristian=20Garc=C3=ADa=20Romero?= Date: Tue, 1 Mar 2022 16:19:14 +0100 Subject: [PATCH 07/10] Update requirements and README.md --- conda_build/README.md | 4 +++- conda_build/bld.bat | 6 +++--- conda_build/build.sh | 6 +++--- conda_build/meta.yaml | 12 ++++++++++-- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/conda_build/README.md b/conda_build/README.md index 4b54ad74e..b7245cbc5 100644 --- a/conda_build/README.md +++ b/conda_build/README.md @@ -14,10 +14,12 @@ conda install -y -c conda-forge conda-build conda install -y -c conda-forge git ``` +If you are building for Windows, you will need Visual Studio as well before proceeding. + Once the dependencies are installed, we can create the package: ```bash -conda build --build-only -c conda-forge ./conda_build +conda build --no-anaconda-upload --no-test -c conda-forge ./conda_build ``` When the build finishes, the path to the package should be printed in the log. The path to the package should have the following structure: diff --git a/conda_build/bld.bat b/conda_build/bld.bat index a7f9e8058..d8aa7b7c2 100644 --- a/conda_build/bld.bat +++ b/conda_build/bld.bat @@ -6,13 +6,13 @@ set BDIR="./build" if exist %BDIR% ( rmdir /S /Q %BDIR% ) mkdir %BDIR% -echo " - Building..." +:: Build pushd %BDIR% cmake .. -DKENLM_MAX_ORDER=%KENLM_MAX_ORDER% -DCMAKE_INSTALL_PREFIX:PATH=%PREFIX% -echo " - Installing..." +:: Install make -j all install popd rmdir /S /Q %BDIR% -echo " - Installing python module..." +:: Install python module "%PYTHON%" -m pip install . --install-option="--max_order %KENLM_MAX_ORDER%" diff --git a/conda_build/build.sh b/conda_build/build.sh index 7e819376c..481a50a4e 100644 --- a/conda_build/build.sh +++ b/conda_build/build.sh @@ -4,13 +4,13 @@ BDIR="./build" [[ -d $BDIR ]] && rm -rf $BDIR mkdir $BDIR -echo " - Building..." +# Build pushd $BDIR cmake .. -DKENLM_MAX_ORDER=$KENLM_MAX_ORDER -DCMAKE_INSTALL_PREFIX:PATH=$PREFIX -echo " - Installing..." +# Install make -j all install popd rm -rf $BDIR -echo " - Installing python module..." +# Install python module $PYTHON -m pip install . --install-option="--max_order $KENLM_MAX_ORDER" diff --git a/conda_build/meta.yaml b/conda_build/meta.yaml index 60a943bda..5026dd3b5 100644 --- a/conda_build/meta.yaml +++ b/conda_build/meta.yaml @@ -26,10 +26,18 @@ requirements: - pip - setuptools - python - - libboost + - libboost>=1.71.0 + - eigen + - zlib + - bzip2 + - xz run: - python - - libboost + - libboost>=1.71.0 + - eigen + - zlib + - bzip2 + - xz about: home: https://github.com/kpu/kenlm From dbe28abab7bf29942b5b3a13d3f448f54a965659 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristian=20Garc=C3=ADa=20Romero?= Date: Wed, 2 Mar 2022 09:32:06 +0100 Subject: [PATCH 08/10] Update conda build README.md --- conda_build/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conda_build/README.md b/conda_build/README.md index b7245cbc5..989f6f41f 100644 --- a/conda_build/README.md +++ b/conda_build/README.md @@ -28,10 +28,10 @@ When the build finishes, the path to the package should be printed in the log. T ${CONDA_PREFIX}/conda-bld/{target_arch}/kenlm-{build_date}-{commit}.tar.bz2 ``` -If you install the generated package, the dependencies will not be installed. Run: +If you install the generated package (i.e. local installation), the dependencies will not be installed. Be aware that, despite install the dependencies, the constraints might be ignored, what might lead to an inconsistent installation (this does not happen when the package is [uploaded](#upload-package) to the [anaconda repo](https://anaconda.org/anaconda/repo)). Run: ```bash -# Install kenlm +# Install kenlm (local package) conda install -y ${CONDA_PREFIX}/conda-bld/{target_arch}/kenlm-{build_date}-{commit}.tar.bz2 # Install dependencies conda update -y --only-deps -c conda-forge kenlm From c3e2eda60ea215146b4ba9cd6951c2b8041a9284 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristian=20Garc=C3=ADa=20Romero?= Date: Wed, 2 Mar 2022 10:03:56 +0100 Subject: [PATCH 09/10] Update conda build README.md --- conda_build/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conda_build/README.md b/conda_build/README.md index 989f6f41f..c78571c29 100644 --- a/conda_build/README.md +++ b/conda_build/README.md @@ -32,7 +32,7 @@ If you install the generated package (i.e. local installation), the dependencies ```bash # Install kenlm (local package) -conda install -y ${CONDA_PREFIX}/conda-bld/{target_arch}/kenlm-{build_date}-{commit}.tar.bz2 +conda install -y /path/to/package # Install dependencies conda update -y --only-deps -c conda-forge kenlm ``` From 9e98291a3fe3f08e693e7b5780c9019aa64b90da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristian=20Garc=C3=ADa=20Romero?= Date: Wed, 30 Mar 2022 14:24:34 +0200 Subject: [PATCH 10/10] Update conda build scripts and delete README.md --- conda_build/README.md | 52 --------------- conda_build/{ => kenlm}/bld.bat | 4 ++ conda_build/{ => kenlm}/build.sh | 4 ++ conda_build/{ => kenlm}/meta.yaml | 11 ++-- conda_build/make_build.sh | 101 ++++++++++++++++++++++++++++++ 5 files changed, 113 insertions(+), 59 deletions(-) delete mode 100644 conda_build/README.md rename conda_build/{ => kenlm}/bld.bat (79%) rename conda_build/{ => kenlm}/build.sh (59%) rename conda_build/{ => kenlm}/meta.yaml (64%) create mode 100755 conda_build/make_build.sh diff --git a/conda_build/README.md b/conda_build/README.md deleted file mode 100644 index c78571c29..000000000 --- a/conda_build/README.md +++ /dev/null @@ -1,52 +0,0 @@ -# Conda build - -Instructions in order to create, install and upload a conda package. kenlm is available on Windows, Ubuntu and Mac, so the package is it as well. - -You will need to [download](https://docs.conda.io/en/latest/miniconda.html) and [install](https://conda.io/projects/conda/en/latest/user-guide/install/index.html) Miniconda. - -## Create package - -First, you will need to install some dependencies: - -```bash -conda install -y -c conda-forge conda-build -# Mandatory for Windows, optional otherwise -conda install -y -c conda-forge git -``` - -If you are building for Windows, you will need Visual Studio as well before proceeding. - -Once the dependencies are installed, we can create the package: - -```bash -conda build --no-anaconda-upload --no-test -c conda-forge ./conda_build -``` - -When the build finishes, the path to the package should be printed in the log. The path to the package should have the following structure: - -``` -${CONDA_PREFIX}/conda-bld/{target_arch}/kenlm-{build_date}-{commit}.tar.bz2 -``` - -If you install the generated package (i.e. local installation), the dependencies will not be installed. Be aware that, despite install the dependencies, the constraints might be ignored, what might lead to an inconsistent installation (this does not happen when the package is [uploaded](#upload-package) to the [anaconda repo](https://anaconda.org/anaconda/repo)). Run: - -```bash -# Install kenlm (local package) -conda install -y /path/to/package -# Install dependencies -conda update -y --only-deps -c conda-forge kenlm -``` - -## Upload package - -If you want to upload your package, install: - -```bash -conda install -y -c conda-forge anaconda-client -``` - -In order to upload the package, we just need to execute the following command and follow the instructions: - -```bash -anaconda upload /path/to/package -``` diff --git a/conda_build/bld.bat b/conda_build/kenlm/bld.bat similarity index 79% rename from conda_build/bld.bat rename to conda_build/kenlm/bld.bat index d8aa7b7c2..bfd413338 100644 --- a/conda_build/bld.bat +++ b/conda_build/kenlm/bld.bat @@ -1,6 +1,10 @@ @echo off +set PIP_NO_INDEX="False" +set PIP_NO_DEPENDENCIES="False" +set PIP_IGNORE_INSTALLED="False" + set BDIR="./build" if exist %BDIR% ( rmdir /S /Q %BDIR% ) diff --git a/conda_build/build.sh b/conda_build/kenlm/build.sh similarity index 59% rename from conda_build/build.sh rename to conda_build/kenlm/build.sh index 481a50a4e..0dd5d3d26 100644 --- a/conda_build/build.sh +++ b/conda_build/kenlm/build.sh @@ -1,4 +1,8 @@ +PIP_NO_INDEX=False # Allow requisites from PyPi +PIP_NO_DEPENDENCIES=False # Install dependencies from our defined dependencies +PIP_IGNORE_INSTALLED=False # Take into account the current installed dependencies + BDIR="./build" [[ -d $BDIR ]] && rm -rf $BDIR diff --git a/conda_build/meta.yaml b/conda_build/kenlm/meta.yaml similarity index 64% rename from conda_build/meta.yaml rename to conda_build/kenlm/meta.yaml index 5026dd3b5..c720661d1 100644 --- a/conda_build/meta.yaml +++ b/conda_build/kenlm/meta.yaml @@ -1,5 +1,5 @@ -{% set rdir = ".." %} +{% set rdir = "../.." %} {% set data = load_setup_py_data(setup_file=''+rdir+'/setup.py', from_recipe_dir=True) %} package: @@ -10,12 +10,9 @@ source: path: {{ rdir }} build: - string: {{ environ.get('GIT_DESCRIBE_HASH') }} + string: "py{{ environ.get('CONDA_PY') }}_{{ environ.get('GIT_DESCRIBE_HASH') }}" script_env: - KENLM_MAX_ORDER=7 - - PIP_NO_INDEX=False # Allow requisites from PyPi - - PIP_NO_DEPENDENCIES=False # Install dependencies from our defined dependencies - - PIP_IGNORE_INSTALLED=False # Take into account the current installed dependencies requirements: build: @@ -25,14 +22,14 @@ requirements: host: - pip - setuptools - - python + - python {{ python }} - libboost>=1.71.0 - eigen - zlib - bzip2 - xz run: - - python + - python {{ python }} - libboost>=1.71.0 - eigen - zlib diff --git a/conda_build/make_build.sh b/conda_build/make_build.sh new file mode 100755 index 000000000..4c390383d --- /dev/null +++ b/conda_build/make_build.sh @@ -0,0 +1,101 @@ +#!/usr/bin/env bash + +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +PACKAGE_VERBOSE_NAME="KenLM" + +usage() +{ + echo "$(basename $0) [-h] [-e ] [-r] [-s] -n -p " + echo "" + echo "OPTIONS:" + echo " -h It displays this help message." + echo " -e Name of the conda environment which will be used to build" + echo " ${PACKAGE_VERBOSE_NAME}. 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 " -s Skip untracked files check." + echo " -n Conda package name in order to retrieve the pkg path" + echo " -p Python version to be used to build ${PACKAGE_VERBOSE_NAME}." +} + +CONDA_ENV_NAME="" +CONDA_PACKAGE_NAME="" +REMOVE_ENV_IF_EXISTS="" +CONDA_PYTHON_VERSION="" +SKIP_UNTRACKED_FILES_CHECK="" + +while getopts "e:n:p:rsh" options +do + case "${options}" in + h) usage + exit 0;; + e) CONDA_ENV_NAME=$OPTARG;; + r) REMOVE_ENV_IF_EXISTS="y";; + s) SKIP_UNTRACKED_FILES_CHECK="y";; + n) CONDA_PACKAGE_NAME=$OPTARG;; + p) CONDA_PYTHON_VERSION=$OPTARG;; + \?) usage 1>&2 + exit 1;; + esac +done + +# Info +echo "git describe --tags: $(git describe --tags || true)" +echo "git describe --always: $(git describe --always)" + +if [[ -z "$CONDA_PACKAGE_NAME" ]] || [[ -z "$CONDA_PYTHON_VERSION" ]]; then + >&2 echo "Error: not all mandatory parameters were provided" + >&2 echo "" + usage 1>&2 + exit 1 +fi + +if [[ -z "$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 + +BASE_PACKAGE_PATH="${SCRIPT_DIR}/.." +UNTRACKED_FILES=$(git ls-files "$BASE_PACKAGE_PATH" --ignored --exclude-standard --others | wc -l) +CHANGED_FILES=$(git diff --name-only | wc -l) + +if [[ "$UNTRACKED_FILES" -ne "0" ]]; then + if [[ -z "$SKIP_UNTRACKED_FILES_CHECK" ]]; then + >&2 echo "Error: there are $UNTRACKED_FILES untracked files in the repository" + exit 1 + else + >&2 echo "Warning: there are $UNTRACKED_FILES untracked files in the repository" + fi +fi + +if [[ "$CHANGED_FILES" -ne "0" ]]; then + >&2 echo "Warning: there are $CHANGED_FILES changed files in the repository" +fi + +source $(conda info --base)/etc/profile.d/conda.sh + +if [[ -n "$REMOVE_ENV_IF_EXISTS" ]]; then + conda remove -y -n $CONDA_ENV_NAME --all +fi + +if [[ -n "$(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 python=$CONDA_PYTHON_VERSION +conda activate $CONDA_ENV_NAME +conda update -y conda + +CONDA_CHANNELS="-c conda-forge -c bitextor" + +# Make build +conda-build --no-test --no-anaconda-upload $CONDA_CHANNELS $CONDA_PACKAGE_PATH --python=$CONDA_PYTHON_VERSION