Skip to content

Commit 0d227fe

Browse files
authored
Build wheels for python 3.13 and python 3.14 (#743)
* build wheels for python 3.13 and python 3.14 * drop support for python 3.6 and python 3.7 * Update github actions versions * Update pre-commit config * Various minor fixes to work with newer versions of dependencies
1 parent b33b809 commit 0d227fe

19 files changed

Lines changed: 57 additions & 69 deletions

.github/workflows/build.yml

Lines changed: 19 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ jobs:
1616
lint:
1717
runs-on: ubuntu-latest
1818
steps:
19-
- uses: actions/checkout@v3
19+
- uses: actions/checkout@v6
2020

2121
- name: Set up Python
22-
uses: actions/setup-python@v4
22+
uses: actions/setup-python@v6
2323
with:
2424
python-version: 3.9
2525

@@ -57,29 +57,13 @@ jobs:
5757
runs-on: ${{ matrix.os }}
5858
strategy:
5959
matrix:
60-
os: [macos-latest, ubuntu-latest, windows-latest]
61-
python-version: [36, 37, 38, 39, 310, 311, 312]
62-
cibw-arch: [auto, aarch64]
63-
exclude:
64-
- os: macos-latest
65-
cibw-arch: aarch64
66-
- os: windows-latest
67-
cibw-arch: aarch64
60+
os: [macos-latest, ubuntu-latest, windows-latest, ubuntu-24.04-arm]
6861

6962
steps:
70-
- uses: actions/checkout@v3
71-
72-
- name: Set up QEMU
73-
if: runner.os == 'Linux'
74-
uses: docker/setup-qemu-action@v3
75-
with:
76-
platforms: all
63+
- uses: actions/checkout@v6
7764

7865
- name: Build wheels
79-
uses: pypa/cibuildwheel@v2.16.2
80-
env:
81-
CIBW_BUILD: cp${{matrix.python-version}}-*
82-
CIBW_ARCHS_LINUX: ${{ matrix.cibw-arch }}
66+
uses: pypa/cibuildwheel@v3.4.1
8367

8468
- name: Build sdist
8569
run: |
@@ -93,42 +77,38 @@ jobs:
9377
if: runner.os == 'Linux'
9478

9579
- name: Upload Binaries
96-
uses: actions/upload-artifact@v3
80+
uses: actions/upload-artifact@v7
9781
with:
98-
name: wheels
99-
path: wheelhouse
82+
name: wheels-${{ matrix.os }}
83+
path: ./wheelhouse/*.whl
10084

10185
test-wheels:
10286
needs: [build-wheels]
10387
runs-on: ${{ matrix.os }}
10488
strategy:
10589
matrix:
106-
python-version: [3.7, 3.8, 3.9, '3.10', '3.11', '3.12']
107-
os: [macos-latest, ubuntu-latest, windows-latest]
90+
python-version: [3.8, 3.9, '3.10', '3.11', '3.12', '3.13', '3.14']
91+
os: [macos-latest, ubuntu-latest, windows-latest, ubuntu-24.04-arm]
10892

10993
steps:
110-
- uses: actions/checkout@v3
94+
- uses: actions/checkout@v6
11195
with:
11296
path: implicit_source
113-
- uses: actions/download-artifact@v3
97+
- uses: actions/download-artifact@v8
11498
with:
115-
name: wheels
99+
name: wheels-${{ matrix.os }}
116100
- name: Set up Python ${{ matrix.python-version }}
117-
uses: actions/setup-python@v4
101+
uses: actions/setup-python@v6
118102
with:
119103
python-version: ${{ matrix.python-version }}
120104
- name: Install dependencies
121105
run: |
122106
python -m pip install --upgrade pip
123107
pip install pytest
124108
pip install -r implicit_source/requirements.txt
125-
- name: Install h5py
126-
run: pip install h5py
127-
128109
- name: Install ANN Libraries
129110
run: pip install annoy nmslib
130-
if: ${{ matrix.python-version != '3.12' && matrix.python-version != '3.11' && runner.os == 'Linux' }}
131-
111+
if: ${{ matrix.python-version != '3.14' && runner.os == 'Linux' }}
132112
- name: Install wheel
133113
run: |
134114
pip install --force-reinstall --no-deps --no-index --find-links . implicit
@@ -142,15 +122,16 @@ jobs:
142122
if: "startsWith(github.ref, 'refs/tags/')"
143123
needs: [test-wheels]
144124
steps:
145-
- uses: actions/download-artifact@v3
125+
- uses: actions/download-artifact@v8
146126
with:
147-
name: wheels
127+
pattern: wheels-*
128+
merge-multiple: true
148129
- name: Create GitHub Release
149130
uses: fnkr/github-action-ghr@v1.3
150131
env:
151132
GHR_PATH: .
152133
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
153-
- uses: actions/setup-python@v2
134+
- uses: actions/setup-python@v6
154135
with:
155136
python-version: 3.9
156137
- name: Push to PyPi

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
repos:
22
- repo: https://github.com/timothycrosley/isort
3-
rev: 5.12.0
3+
rev: 8.0.1
44
hooks:
55
- id: isort
66
additional_dependencies: [toml]
77
- repo: https://github.com/python/black
8-
rev: 23.3.0
8+
rev: 26.1.0
99
hooks:
1010
- id: black
1111
- repo: https://github.com/pycqa/flake8
12-
rev: 6.0.0
12+
rev: 7.3.0
1313
hooks:
1414
- id: flake8
1515
- repo: https://github.com/pycqa/pylint
16-
rev: v2.17.4
16+
rev: v4.0.5
1717
hooks:
1818
- id: pylint
1919
- repo: https://github.com/codespell-project/codespell

.pylintrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,6 @@ disable=fixme,
4545
min-similarity-lines=64
4646
ignore-docstrings=yes
4747
ignore-imports=yes
48+
49+
[DESIGN]
50+
max-positional-arguments=12

benchmarks/benchmark_als.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
""" test script to verify the CG method works, and time it versus cholesky """
1+
"""test script to verify the CG method works, and time it versus cholesky"""
2+
23
import argparse
34
import json
45
import logging

examples/lastfm.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
""" An example of using this library to calculate related artists
1+
"""An example of using this library to calculate related artists
22
from the last.fm dataset. More details can be found
33
at http://www.benfrederickson.com/matrix-factorization/
44
55
This code will automatically download a HDF5 version of the dataset from
66
GitHub when it is first run. The original dataset can also be found at
77
http://ocelma.net/MusicRecommendationDataset/lastfm-360K.html
88
"""
9+
910
import argparse
10-
import codecs
1111
import logging
1212
import time
1313

@@ -102,7 +102,7 @@ def calculate_similar_artists(output_filename, model_name="als"):
102102
# write out as a TSV of artistid, otherartistid, score
103103
logging.debug("writing similar items")
104104
with tqdm.tqdm(total=len(to_generate)) as progress:
105-
with codecs.open(output_filename, "w", "utf8") as o:
105+
with open(output_filename, "w", encoding="utf8") as o:
106106
batch_size = 1000
107107
for startidx in range(0, len(to_generate), batch_size):
108108
batch = to_generate[startidx : startidx + batch_size]
@@ -146,7 +146,7 @@ def calculate_recommendations(output_filename, model_name="als"):
146146
# generate recommendations for each user and write out to a file
147147
start = time.time()
148148
with tqdm.tqdm(total=len(users)) as progress:
149-
with codecs.open(output_filename, "w", "utf8") as o:
149+
with open(output_filename, "w", encoding="utf8") as o:
150150
batch_size = 1000
151151
to_generate = np.arange(len(users))
152152
for startidx in range(0, len(to_generate), batch_size):

examples/movielens.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from __future__ import print_function
1414

1515
import argparse
16-
import codecs
1716
import logging
1817
import time
1918

@@ -87,7 +86,7 @@ def calculate_similar_movies(output_filename, model_name="als", min_rating=4.0,
8786

8887
log.debug("calculating similar movies")
8988
with tqdm.tqdm(total=len(to_generate)) as progress:
90-
with codecs.open(output_filename, "w", "utf8") as o:
89+
with open(output_filename, "w", encoding="utf8") as o:
9190
batch_size = 1000
9291
for startidx in range(0, len(to_generate), batch_size):
9392
batch = to_generate[startidx : startidx + batch_size]

examples/tutorial_lastfm.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@
293293
"# Use pandas to display the output in a table, pandas isn't a dependency of implicit otherwise\n",
294294
"import numpy as np\n",
295295
"import pandas as pd\n",
296-
"pd.DataFrame({\"artist\": artists[ids], \"score\": scores, \"already_liked\": np.in1d(ids, user_plays[userid].indices)})"
296+
"pd.DataFrame({\"artist\": artists[ids], \"score\": scores, \"already_liked\": np.isin(ids, user_plays[userid].indices)})"
297297
]
298298
},
299299
{

implicit/_nearest_neighbours.pyx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ from cython cimport floating, integral
1111
from cython.operator import dereference
1212
from cython.parallel import parallel, prange
1313

14+
from libc.stdint cimport int32_t
1415
from libcpp cimport bool
1516
from libcpp.algorithm cimport sort_heap
1617
from libcpp.utility cimport pair
@@ -131,8 +132,8 @@ def all_pairs_knn(users, unsigned int K=100, int num_threads=0, show_progress=Tr
131132

132133
# holds triples of output
133134
cdef double[:] values = np.zeros(item_count * K)
134-
cdef long[:] rows = np.zeros(item_count * K, dtype=int)
135-
cdef long[:] cols = np.zeros(item_count * K, dtype=int)
135+
cdef int32_t[:] rows = np.zeros(item_count * K, dtype="int32")
136+
cdef int32_t[:] cols = np.zeros(item_count * K, dtype="int32")
136137

137138
progress = tqdm(total=item_count, disable=not show_progress)
138139
with nogil, parallel(num_threads=num_threads):

implicit/ann/annoy.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313

1414
class AnnoyModel(RecommenderBase):
15-
1615
"""Speeds up inference calls to MatrixFactorization models by using an
1716
`Annoy <https://github.com/spotify/annoy>`_ index to calculate similar items and
1817
recommend items.

implicit/ann/nmslib.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313

1414
class NMSLibModel(RecommenderBase):
15-
1615
"""Speeds up inference calls to MatrixFactorization models by using
1716
`NMSLib <https://github.com/nmslib/nmslib>`_ to create approximate nearest neighbours
1817
indices of the latent factors.

0 commit comments

Comments
 (0)