From cb172c1d0718ade26149500a1fcd8aea88d0aebb Mon Sep 17 00:00:00 2001 From: Maarten van Gompel Date: Tue, 17 Dec 2024 13:55:44 +0100 Subject: [PATCH 01/21] ci: wheel building --- .github/workflows/wheels.yml | 21 +++++++++++++++++++-- build-deps.sh | 8 ++++++-- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 9c9408c..6465d1e 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -10,10 +10,13 @@ jobs: matrix: buildplat: - { runs_on: ubuntu-20.04, sys: manylinux, arch: x86_64, benv: "" } + - { runs_on: ubuntu-20.04, sys: musllinux, arch: x86_64, benv: "" } + - { runs_on: macos-14, sys: macosx, arch: arm64, benv: "14.0" } python: - { cp: "cp310", rel: "3.10" } - { cp: "cp311", rel: "3.11" } - { cp: "cp312", rel: "3.12" } + - { cp: "cp313", rel: "3.13" } steps: - uses: actions/checkout@v4.1.1 @@ -26,8 +29,8 @@ jobs: - name: Install cibuildwheel run: python -m pip install cibuildwheel - - name: Build wheels (Linux) - if: ${{ runner.os != 'macOS' }} + - name: Build wheels (Linux glibc) + if: ${{ matrix.buildplat.sys == 'manylinux' }} run: python -m cibuildwheel --output-dir wheelhouse env: CIBW_BUILD: ${{ matrix.python.cp }}-${{ matrix.buildplat.sys }}* @@ -46,6 +49,20 @@ jobs: CIBW_MANYLINUX_X86_64_IMAGE: quay.io/pypa/manylinux2014_x86_64 CIBW_SKIP: "*-win* *-manylinux_i686 pp*" + - name: Build wheels (Linux musl) + if: ${{ matrix.buildplat.sys == 'musllinux' }} + run: python -m cibuildwheel --output-dir wheelhouse + env: + CIBW_BUILD: ${{ matrix.python.cp }}-${{ matrix.buildplat.sys }}* + CIBW_ARCHS_LINUX: "x86_64" + CIBW_BEFORE_ALL_LINUX: > + apk add build-base git autoconf-archive autoconf automake libtool bzip2-dev icu-dev libxml2-dev libexttextcat-dev libtool rsync && + mkdir -p /usr/local/share/aclocal/ && rsync -av --ignore-existing /usr/share/aclocal/*.m4 /usr/local/share/aclocal/ && + ./build-deps.sh + CIBW_MUSLLINUX_X86_64_IMAGE: quay.io/pypa/musllinux_1_1_x86_64 + CIBW_MUSLLINUX_AARCH64_IMAGE: quay.io/pypa/musllinux_1_1_aarch64 + CIBW_SKIP: "*-win* *-manylinux_i686 pp*" + - name: Build wheels (macOS) if: ${{ runner.os == 'macOS' }} run: python -m cibuildwheel --output-dir wheelhouse diff --git a/build-deps.sh b/build-deps.sh index cd8578d..2f2381a 100755 --- a/build-deps.sh +++ b/build-deps.sh @@ -7,6 +7,8 @@ set -e . /etc/os-release +echo "OS: $ID">&2 +echo "VERSION: $VERSION_ID">&2 get_latest_version() { #Finds the latest git tag or falls back to returning the git default branch (usually master or main) @@ -27,7 +29,8 @@ if [ "$ID" = "almalinux" ] || [ "$ID" = "centos" ] || [ "$ID" = "rhel" ]; then #needed for manylinux_2_28 container which ships custom autoconf, possibly others too? export ACLOCAL_PATH=/usr/share/aclocal fi - if [ "$VERSION_ID" = "7" ]; then + case $VERSION_ID in + 7*) if [ -d /opt/rh/devtoolset-10/root/usr/lib ]; then #we are running in the manylinux2014 image export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib:/opt/rh/devtoolset-10/root/usr/lib @@ -39,7 +42,8 @@ if [ "$ID" = "almalinux" ] || [ "$ID" = "centos" ] || [ "$ID" = "rhel" ]; then cd libxml2-2.9.14 && ./configure --prefix=$PREFIX --without-python && make && make install cd .. fi - fi + ;; + esac fi PWD="$(pwd)" From 243646f028b0152a65d0c5344503dad261eed802 Mon Sep 17 00:00:00 2001 From: Maarten van Gompel Date: Wed, 18 Dec 2024 12:06:04 +0100 Subject: [PATCH 02/21] expanded boost detection --- setup.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/setup.py b/setup.py index bac7905..3f65bf3 100755 --- a/setup.py +++ b/setup.py @@ -102,6 +102,11 @@ def findboost(self, libsearch, includesearch, pyversion): libsearch.insert(0,'/opt/homebrew/opt/boost-python3/lib') libsearch.insert(0,'/opt/homebrew/opt/boost/lib') includesearch.insert(0,'/opt/homebrew/opt/boost/include') + if os.path.exists('/opt/homebrew/opt/boost-python' + pyversion): + self.boostlib = "boost_python" + pyversion + libsearch.insert(0,f"/opt/homebrew/opt/boost-python{pyversion}/lib") + libsearch.insert(0,'/opt/homebrew/opt/boost/lib') + includesearch.insert(0,'/opt/homebrew/opt/boost/include') for d in libsearch: if os.path.exists(d + "/libboost_python-py"+pyversion+".so"): @@ -121,6 +126,10 @@ def findboost(self, libsearch, includesearch, pyversion): self.boost_library_dir = d self.boostlib = "boost_python" break + elif os.path.exists(d + "/libboost_python-py" + pyversion + ".dylib"): #Mac OS X + self.boost_library_dir = d + self.boostlib = "boost_python-py" + pyversion + break elif os.path.exists(d + "/libboost_python" + pyversion + ".dylib"): #Mac OS X self.boost_library_dir = d self.boostlib = "boost_python" + pyversion From 718d43cef7250e3b3090abf4147214237b0fff3b Mon Sep 17 00:00:00 2001 From: Maarten van Gompel Date: Wed, 18 Dec 2024 12:12:38 +0100 Subject: [PATCH 03/21] debug --- .github/workflows/wheels.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 6465d1e..270928b 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -73,7 +73,8 @@ jobs: CIBW_BEFORE_ALL_MACOS: > brew install boost boost-python3 && brew tap fbkarsdorp/homebrew-lamachine && - brew install timbl + brew install timbl && + du -ah /opt/homebrew - uses: actions/upload-artifact@v4 with: From e3e1fc3749ba42853209abf5d02fa55b9b241f1b Mon Sep 17 00:00:00 2001 From: Maarten van Gompel Date: Wed, 18 Dec 2024 12:25:53 +0100 Subject: [PATCH 04/21] ci: restrict mac wheels to python 3.12 only --- .github/workflows/wheels.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 270928b..8d8d8f4 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -64,7 +64,7 @@ jobs: CIBW_SKIP: "*-win* *-manylinux_i686 pp*" - name: Build wheels (macOS) - if: ${{ runner.os == 'macOS' }} + if: ${{ runner.os == 'macOS' && matrix.python.cp == 'cp312' }} run: python -m cibuildwheel --output-dir wheelhouse env: CIBW_BUILD: ${{ matrix.python.cp }}-${{ matrix.buildplat.sys }}* @@ -74,9 +74,10 @@ jobs: brew install boost boost-python3 && brew tap fbkarsdorp/homebrew-lamachine && brew install timbl && - du -ah /opt/homebrew + du -ah /opt/homebrew | grep boost_python - uses: actions/upload-artifact@v4 + if: ${{ ! (runner.os == 'macOS' && matrix.python.cp == 'cp312') }} with: name: ${{matrix.python.cp}}-${{matrix.buildplat.sys}}-${{matrix.buildplat.arch}} path: ./wheelhouse/*.whl From b1bdbfc7120ea09d9d07c22444031d48b99b44c0 Mon Sep 17 00:00:00 2001 From: Maarten van Gompel Date: Wed, 18 Dec 2024 12:31:14 +0100 Subject: [PATCH 05/21] version bump --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 3f65bf3..b234d8a 100755 --- a/setup.py +++ b/setup.py @@ -182,7 +182,7 @@ def build_extensions(self): setup( name="python3-timbl", - version="2024.10.29", + version="2024.12.18", description="Python 3 language binding for the Tilburg Memory-Based Learner", author="Sander Canisius, Maarten van Gompel", author_email="S.V.M.Canisius@uvt.nl, proycon@anaproy.nl", From 17f186ecfdb96eebc5b13c7f87b8cc92f9c0f963 Mon Sep 17 00:00:00 2001 From: Maarten van Gompel Date: Wed, 18 Dec 2024 12:36:27 +0100 Subject: [PATCH 06/21] README update --- README.rst | 43 +++++++++++++------------------------------ 1 file changed, 13 insertions(+), 30 deletions(-) diff --git a/README.rst b/README.rst index 4a0f448..b4c7039 100644 --- a/README.rst +++ b/README.rst @@ -38,47 +38,30 @@ TiMBL. Installation ============ -python-timbl is distributed as part of **LaMachine** -(https://proycon.github.io/LaMachine), which significantly simplifies -compilation and installation. The remainder of the instructions in this section -refer to manual compilation and installation. +In a Python virtual environment, run: + +``` +pip install python3-timbl +``` + +If no wheels (binary packages) are available for your system, then this will +attempt to compile from source. If that is the case, a number of dependencies +are required: python-timbl depends on two external packages, which must have been built and/or installed on your system in order to successfully build python-timbl. The first is TiMBL itself; download its tarball from TiMBL's homepage and -follow the installation instructions, recent Ubuntu/Debian users will find -timbl in their distribution's package repository. In the remainder of this -section, it is assumed that ``$TIMBL_HEADERS`` points to the directory that -contains ``timbl/TimblAPI.h``, and ``$TIMBL_LIBS`` the directory that has -contains the Timbl libraries. Note that Timbl itself depends on additional -dependencies. - -The second prerequisite is Boost.Python, a library that facilitates writing +follow the installation instructions. The second prerequisite is Boost.Python, a library that facilitates writing Python extension modules in C++. Many Linux distributions come with prebuilt packages of Boost.Python. If so, install this package; on Ubuntu/Debian this can be done as follows:: $ sudo apt-get install libboost-python libboost-python-dev -If not, refer to the `Boost installation instructions`_ to build and install -Boost.Python manually. In the remainder of this section, let ``$BOOST_HEADERS`` -refer to the directory that contains the Boost header files, and -``$BOOST_LIBS`` to the directory that contains the Boost library files. If you -installed Boost.Python with your distribution's package manager, these -directories are probably ``/usr/include`` and ``/usr/lib`` respectively. - -.. _Boost installation instructions: http://www.boost.org/more/getting_started.html - - -If both prerequisites have been installed on your system, python-timbl can be -obtained through github:: - - $ git clone git://github.com/proycon/python-timbl.git - $ cd python-timbl - -and can then be built and installed with the following command:: +Note that on macOS, wheel packages are currently only available for the Python +3.12, as this the the Python version Homebrew uses in linking libboost-python. +Make sure you use that version. - $ pip install . Usage ======= From 1d6c88ae81a4c1f7f5a56152fd24ac8fb82565a4 Mon Sep 17 00:00:00 2001 From: Maarten van Gompel Date: Wed, 18 Dec 2024 12:40:04 +0100 Subject: [PATCH 07/21] ci: musllinux fix --- .github/workflows/wheels.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 8d8d8f4..a756e07 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -41,9 +41,6 @@ jobs: elif command -v yum; then yum install -y git libicu-devel libxml2-devel libxslt-devel zlib-devel bzip2-devel libtool autoconf-archive autoconf automake m4 wget boost-devel #on CentOS 7 we also have libtar-devel which will be installed by build-deps.sh, on 8 they are missing and will be installed from source or otherwise - elif command -v apk; then - apk add build-base git autoconf-archive autoconf automake libtool bzip2-dev icu-dev libxml2-dev libexttextcat-dev libtool rsync boost-dev && - rsync -av --ignore-existing /usr/share/aclocal/*.m4 /usr/local/share/aclocal/ fi && ./build-deps.sh CIBW_MANYLINUX_X86_64_IMAGE: quay.io/pypa/manylinux2014_x86_64 @@ -56,7 +53,7 @@ jobs: CIBW_BUILD: ${{ matrix.python.cp }}-${{ matrix.buildplat.sys }}* CIBW_ARCHS_LINUX: "x86_64" CIBW_BEFORE_ALL_LINUX: > - apk add build-base git autoconf-archive autoconf automake libtool bzip2-dev icu-dev libxml2-dev libexttextcat-dev libtool rsync && + apk add build-base git autoconf-archive autoconf automake libtool bzip2-dev icu-dev libxml2-dev boost-dev boost1.84-python3 libtool rsync && mkdir -p /usr/local/share/aclocal/ && rsync -av --ignore-existing /usr/share/aclocal/*.m4 /usr/local/share/aclocal/ && ./build-deps.sh CIBW_MUSLLINUX_X86_64_IMAGE: quay.io/pypa/musllinux_1_1_x86_64 From 34da0f027e620828f99e8aeeedc7464d817045a0 Mon Sep 17 00:00:00 2001 From: Maarten van Gompel Date: Wed, 18 Dec 2024 12:43:00 +0100 Subject: [PATCH 08/21] fixup --- .github/workflows/wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index a756e07..eb73075 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -53,7 +53,7 @@ jobs: CIBW_BUILD: ${{ matrix.python.cp }}-${{ matrix.buildplat.sys }}* CIBW_ARCHS_LINUX: "x86_64" CIBW_BEFORE_ALL_LINUX: > - apk add build-base git autoconf-archive autoconf automake libtool bzip2-dev icu-dev libxml2-dev boost-dev boost1.84-python3 libtool rsync && + apk add build-base git autoconf-archive autoconf automake libtool bzip2-dev icu-dev libxml2-dev boost-dev boost-python3 libtool rsync && mkdir -p /usr/local/share/aclocal/ && rsync -av --ignore-existing /usr/share/aclocal/*.m4 /usr/local/share/aclocal/ && ./build-deps.sh CIBW_MUSLLINUX_X86_64_IMAGE: quay.io/pypa/musllinux_1_1_x86_64 From 4606fc6938ba08f574a42adf5d5fa46e4ff5692f Mon Sep 17 00:00:00 2001 From: Maarten van Gompel Date: Wed, 18 Dec 2024 12:50:09 +0100 Subject: [PATCH 09/21] ci: no musllinux for now --- .github/workflows/wheels.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index eb73075..50e25ae 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -10,7 +10,6 @@ jobs: matrix: buildplat: - { runs_on: ubuntu-20.04, sys: manylinux, arch: x86_64, benv: "" } - - { runs_on: ubuntu-20.04, sys: musllinux, arch: x86_64, benv: "" } - { runs_on: macos-14, sys: macosx, arch: arm64, benv: "14.0" } python: - { cp: "cp310", rel: "3.10" } From b193f1d8130bf1b4ac4d816fef25d00b1935b9f6 Mon Sep 17 00:00:00 2001 From: Maarten van Gompel Date: Wed, 18 Dec 2024 12:58:30 +0100 Subject: [PATCH 10/21] ci: update base container for manylinux --- .github/workflows/wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 50e25ae..5a1aa2b 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -42,7 +42,7 @@ jobs: #on CentOS 7 we also have libtar-devel which will be installed by build-deps.sh, on 8 they are missing and will be installed from source or otherwise fi && ./build-deps.sh - CIBW_MANYLINUX_X86_64_IMAGE: quay.io/pypa/manylinux2014_x86_64 + CIBW_MANYLINUX_X86_64_IMAGE: quay.io/pypa/manylinux2_28_x86_64 CIBW_SKIP: "*-win* *-manylinux_i686 pp*" - name: Build wheels (Linux musl) From b6da48fec68de790afb5b94eab350f49cd2d7fb1 Mon Sep 17 00:00:00 2001 From: Maarten van Gompel Date: Wed, 18 Dec 2024 13:00:22 +0100 Subject: [PATCH 11/21] fixup --- .github/workflows/wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 5a1aa2b..310b3c5 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -42,7 +42,7 @@ jobs: #on CentOS 7 we also have libtar-devel which will be installed by build-deps.sh, on 8 they are missing and will be installed from source or otherwise fi && ./build-deps.sh - CIBW_MANYLINUX_X86_64_IMAGE: quay.io/pypa/manylinux2_28_x86_64 + CIBW_MANYLINUX_X86_64_IMAGE: quay.io/pypa/manylinux_2_28_x86_64 CIBW_SKIP: "*-win* *-manylinux_i686 pp*" - name: Build wheels (Linux musl) From c60f36ac0322f08a3fca48ebce84a3f3521d4e29 Mon Sep 17 00:00:00 2001 From: Maarten van Gompel Date: Tue, 21 Jan 2025 23:44:57 +0100 Subject: [PATCH 12/21] attempted wheel fix, some wheels were linked against python 2.7 for some reason! --- .github/workflows/wheels.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 310b3c5..51c1630 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -38,8 +38,7 @@ jobs: if command -v apt-get; then apt-get -y git libicu-dev libxml2-dev libxslt1-dev libbz2-dev zlib1g-dev autoconf automake autoconf-archive libtool autotools-dev gcc g++ make libboost-dev elif command -v yum; then - yum install -y git libicu-devel libxml2-devel libxslt-devel zlib-devel bzip2-devel libtool autoconf-archive autoconf automake m4 wget boost-devel - #on CentOS 7 we also have libtar-devel which will be installed by build-deps.sh, on 8 they are missing and will be installed from source or otherwise + yum install -y git libicu-devel libxml2-devel libxslt-devel zlib-devel bzip2-devel libtool autoconf-archive autoconf automake m4 wget boost-devel boost-python3 boost-python3-devel fi && ./build-deps.sh CIBW_MANYLINUX_X86_64_IMAGE: quay.io/pypa/manylinux_2_28_x86_64 From b01646b6e5071eaedc23c55e2e441fe053abe40d Mon Sep 17 00:00:00 2001 From: Maarten van Gompel Date: Tue, 21 Jan 2025 23:53:37 +0100 Subject: [PATCH 13/21] ci: mac build now only compiles against 3.13 because homebrew's libboost links against that --- .github/workflows/wheels.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 51c1630..5a9e383 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -59,7 +59,7 @@ jobs: CIBW_SKIP: "*-win* *-manylinux_i686 pp*" - name: Build wheels (macOS) - if: ${{ runner.os == 'macOS' && matrix.python.cp == 'cp312' }} + if: ${{ runner.os == 'macOS' && matrix.python.cp == 'cp313' }} run: python -m cibuildwheel --output-dir wheelhouse env: CIBW_BUILD: ${{ matrix.python.cp }}-${{ matrix.buildplat.sys }}* @@ -72,7 +72,7 @@ jobs: du -ah /opt/homebrew | grep boost_python - uses: actions/upload-artifact@v4 - if: ${{ ! (runner.os == 'macOS' && matrix.python.cp == 'cp312') }} + if: ${{ ! (runner.os == 'macOS' && matrix.python.cp == 'cp313') }} with: name: ${{matrix.python.cp}}-${{matrix.buildplat.sys}}-${{matrix.buildplat.arch}} path: ./wheelhouse/*.whl From f5374d7402a69fe50e0034b73d0153f0d0ebc92c Mon Sep 17 00:00:00 2001 From: Maarten van Gompel Date: Wed, 22 Jan 2025 00:09:11 +0100 Subject: [PATCH 14/21] ci wheels: try building against glibc >= 2.34 (almalinux 9), otherwise boost-python3 is too old --- .github/workflows/wheels.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 5a9e383..ab2acbb 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -38,10 +38,10 @@ jobs: if command -v apt-get; then apt-get -y git libicu-dev libxml2-dev libxslt1-dev libbz2-dev zlib1g-dev autoconf automake autoconf-archive libtool autotools-dev gcc g++ make libboost-dev elif command -v yum; then - yum install -y git libicu-devel libxml2-devel libxslt-devel zlib-devel bzip2-devel libtool autoconf-archive autoconf automake m4 wget boost-devel boost-python3 boost-python3-devel + yum install -y git libicu-devel libxml2-devel libxslt-devel zlib-devel bzip2-devel libtool autoconf-archive autoconf automake m4 wget boost-devel fi && ./build-deps.sh - CIBW_MANYLINUX_X86_64_IMAGE: quay.io/pypa/manylinux_2_28_x86_64 + CIBW_MANYLINUX_X86_64_IMAGE: quay.io/pypa/manylinux_2_34_x86_64 CIBW_SKIP: "*-win* *-manylinux_i686 pp*" - name: Build wheels (Linux musl) From 71bbd5fbc6d51a1606b78da434b83762714c942c Mon Sep 17 00:00:00 2001 From: Maarten van Gompel Date: Wed, 22 Jan 2025 12:33:39 +0100 Subject: [PATCH 15/21] ci wheels: build boost-python from source --- .github/workflows/wheels.yml | 5 +++-- README.rst | 9 ++++----- build-boost-python.sh | 18 ++++++++++++++++++ 3 files changed, 25 insertions(+), 7 deletions(-) create mode 100755 build-boost-python.sh diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index ab2acbb..ca56e43 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -38,10 +38,11 @@ jobs: if command -v apt-get; then apt-get -y git libicu-dev libxml2-dev libxslt1-dev libbz2-dev zlib1g-dev autoconf automake autoconf-archive libtool autotools-dev gcc g++ make libboost-dev elif command -v yum; then - yum install -y git libicu-devel libxml2-devel libxslt-devel zlib-devel bzip2-devel libtool autoconf-archive autoconf automake m4 wget boost-devel + yum install -y git libicu-devel libxml2-devel libxslt-devel zlib-devel bzip2-devel libtool autoconf-archive autoconf automake m4 wget cmake fi && ./build-deps.sh - CIBW_MANYLINUX_X86_64_IMAGE: quay.io/pypa/manylinux_2_34_x86_64 + CIBW_BEFORE_BUILD: ./build-boost-python.sh + CIBW_MANYLINUX_X86_64_IMAGE: quay.io/pypa/manylinux_2_28_x86_64 CIBW_SKIP: "*-win* *-manylinux_i686 pp*" - name: Build wheels (Linux musl) diff --git a/README.rst b/README.rst index b4c7039..d1353b2 100644 --- a/README.rst +++ b/README.rst @@ -44,6 +44,9 @@ In a Python virtual environment, run: pip install python3-timbl ``` +Note that on macOS, wheel packages are currently only available for Python +3.13, as this the the Python version Homebrew uses in linking libboost-python. + If no wheels (binary packages) are available for your system, then this will attempt to compile from source. If that is the case, a number of dependencies are required: @@ -54,14 +57,10 @@ The first is TiMBL itself; download its tarball from TiMBL's homepage and follow the installation instructions. The second prerequisite is Boost.Python, a library that facilitates writing Python extension modules in C++. Many Linux distributions come with prebuilt packages of Boost.Python. If so, install this package; on Ubuntu/Debian this -can be done as follows:: +can be done as follows. $ sudo apt-get install libboost-python libboost-python-dev -Note that on macOS, wheel packages are currently only available for the Python -3.12, as this the the Python version Homebrew uses in linking libboost-python. -Make sure you use that version. - Usage ======= diff --git a/build-boost-python.sh b/build-boost-python.sh new file mode 100755 index 0000000..6bc6d4d --- /dev/null +++ b/build-boost-python.sh @@ -0,0 +1,18 @@ +#!/bin/sh + + +# build boost-python from source on AlmaLinux 8 in manylinux_2_28 container (do not use in other contexts) + +set -e + +#var gets set bu cibuildwheel, assign to PYTHON_HOME for boost +export PYTHON_HOME=$Python_ROOT_DIR + +cd /tmp/ +wget -q https://github.com/boostorg/boost/releases/download/boost-1.87.0/boost-1.87.0-cmake.tar.gz +tar -xzf boost-1.87.0-cmake.tar.gz +cd boost-1.87.0 +./bootstrap.sh +./b2 --clean +./b2 install --with-python --prefix=/usr +cd $PREVPWD From cb6b78e4d6797657cadff75f002279d1701c19fc Mon Sep 17 00:00:00 2001 From: Maarten van Gompel Date: Wed, 22 Jan 2025 14:51:44 +0100 Subject: [PATCH 16/21] version bump --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index b234d8a..3d8881a 100755 --- a/setup.py +++ b/setup.py @@ -182,7 +182,7 @@ def build_extensions(self): setup( name="python3-timbl", - version="2024.12.18", + version="2025.01.22", description="Python 3 language binding for the Tilburg Memory-Based Learner", author="Sander Canisius, Maarten van Gompel", author_email="S.V.M.Canisius@uvt.nl, proycon@anaproy.nl", From 5707c71c60c50d06cbb9ee1fb1da289a4c9be0ba Mon Sep 17 00:00:00 2001 From: Maarten van Gompel Date: Wed, 22 Jan 2025 14:52:54 +0100 Subject: [PATCH 17/21] ci: mac wheel is now python 3.13 only, adapt --- .github/workflows/wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index ca56e43..3bfdcff 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -73,7 +73,7 @@ jobs: du -ah /opt/homebrew | grep boost_python - uses: actions/upload-artifact@v4 - if: ${{ ! (runner.os == 'macOS' && matrix.python.cp == 'cp313') }} + if: ${{ ! (runner.os == 'macOS' && matrix.python.cp != 'cp313') }} with: name: ${{matrix.python.cp}}-${{matrix.buildplat.sys}}-${{matrix.buildplat.arch}} path: ./wheelhouse/*.whl From 65f2b399c158a81ffa75b15d409c337660ba4576 Mon Sep 17 00:00:00 2001 From: Maarten van Gompel Date: Fri, 2 May 2025 10:53:06 +0200 Subject: [PATCH 18/21] make bestNeighbours() method available in higher-level API --- example.py | 4 +++- setup.py | 2 +- timbl.py | 3 +++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/example.py b/example.py index cb3edaf..2bc6a0c 100755 --- a/example.py +++ b/example.py @@ -53,7 +53,8 @@ os.unlink("testfile") -classifier = timbl.TimblClassifier("wsd-bank", "-a 0 -k 1" ) + +classifier = timbl.TimblClassifier("wsd-bank", "-a 0 -k 1 +v n+di+k" ) #add some extra verbosity flags classifier.load() classifier.addinstance("testfile", (1,0,0),'financial' ) #addinstance can be used to add instances to external files (use append() for training) classifier.addinstance("testfile", (0,1,0),'furniture' ) @@ -63,6 +64,7 @@ classifier.test("testfile") print("Accuracy: ", classifier.getAccuracy()) +print("Best neighbours: ", classifier.bestNeighbours()) #this only works with the extra verbosity flags and only if python-timbl is compiled with gcc diff --git a/setup.py b/setup.py index 3d8881a..687de05 100755 --- a/setup.py +++ b/setup.py @@ -182,7 +182,7 @@ def build_extensions(self): setup( name="python3-timbl", - version="2025.01.22", + version="2025.05.02", description="Python 3 language binding for the Tilburg Memory-Based Learner", author="Sander Canisius, Maarten van Gompel", author_email="S.V.M.Canisius@uvt.nl, proycon@anaproy.nl", diff --git a/timbl.py b/timbl.py index 604b377..786f8d2 100644 --- a/timbl.py +++ b/timbl.py @@ -307,6 +307,9 @@ def readtestoutput(self): yield " ".join(segments[:endfvec - 2]).split(self.delimiter), segments[endfvec - 2], segments[endfvec - 1], distribution, distance f.close() + def bestNeighbours(self): + return self.api.bestNeighbours() + def _parsedistribution(self, instance, start=0, end =None): dist = {} i = start + 1 From 7550c2c25cf64ac796de1ae44e46e9849da20e69 Mon Sep 17 00:00:00 2001 From: Maarten van Gompel Date: Fri, 2 May 2025 10:55:07 +0200 Subject: [PATCH 19/21] README: removed badge --- README.rst | 3 --- 1 file changed, 3 deletions(-) diff --git a/README.rst b/README.rst index d1353b2..cd43574 100644 --- a/README.rst +++ b/README.rst @@ -1,6 +1,3 @@ -.. image:: http://applejack.science.ru.nl/lamabadge.php/python-timbl - :target: http://applejack.science.ru.nl/languagemachines/ - .. image:: https://www.repostatus.org/badges/latest/active.svg :alt: Project Status: Active – The project has reached a stable, usable state and is being actively developed. :target: https://www.repostatus.org/#active From c0c96e626b46636219cc18e78cd39fd68772f4de Mon Sep 17 00:00:00 2001 From: Maarten van Gompel Date: Fri, 2 May 2025 10:57:33 +0200 Subject: [PATCH 20/21] ci: upgrade ubuntu --- .github/workflows/wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 3bfdcff..9287a1d 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -9,7 +9,7 @@ jobs: strategy: matrix: buildplat: - - { runs_on: ubuntu-20.04, sys: manylinux, arch: x86_64, benv: "" } + - { runs_on: ubuntu-22.04, sys: manylinux, arch: x86_64, benv: "" } - { runs_on: macos-14, sys: macosx, arch: arm64, benv: "14.0" } python: - { cp: "cp310", rel: "3.10" } From 0ab2b55fc379304d3699b43d8429dad64613b4f4 Mon Sep 17 00:00:00 2001 From: Maarten van Gompel Date: Fri, 2 May 2025 11:24:16 +0200 Subject: [PATCH 21/21] also propagate settings() and options() to higher-level API --- timbl.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/timbl.py b/timbl.py index 786f8d2..5623d94 100644 --- a/timbl.py +++ b/timbl.py @@ -310,6 +310,15 @@ def readtestoutput(self): def bestNeighbours(self): return self.api.bestNeighbours() + def bestNeighbors(self): + return self.api.bestNeighbours() + + def settings(self): + return self.api.settings() + + def options(self): + return self.api.options() + def _parsedistribution(self, instance, start=0, end =None): dist = {} i = start + 1