ParticularMiner / sparse_dot_topn_for_blocks

It has the same interface as `sparse_dot_topn` but additionally allows an array to be passed which will be updated with the maximum number of nonzero elements of each row of the result matrix with values above the given lower bound. This is suitable for block-matrix multiplication. That's all!
Apache License 2.0
0 stars 9 forks source link

Fix imports that fail under Cython 3.0 in language_level=3 mode #5

Open pwschaedler opened 1 year ago

pwschaedler commented 1 year ago

The release of Cython 3.0 on July 27, 2023 broke the build for this package by introducing breaking changes. This PR addresses those changes and fixes a few imports that no longer work with Cython 3.0. These changes are also backwards compatible for people who decide to build this package using older versions of Cython. This is an alternative proposal to PR #4 which suggests bounding the Cython dependency.

This addresses issue #3 in this repository, as well as a few issues found in other repos that depend on this package. https://github.com/ing-bank/sparse_dot_topn/issues/84 https://github.com/Bergvca/string_grouper/issues/93

Short term workaround for people who need to build this package now:

pip install cython<3 numpy wheel
pip install sparse_dot_topn_for_blocks --no-build-isolation

EDIT Probably the easiest workaround until a maintainer comes back and merges a fix if you need this package or something that depends on it: just add the following to your requirements.txt.

sparse-dot-topn-for-blocks @ git+https://github.com/pwschaedler/sparse_dot_topn_for_blocks

This will pull the package with the same name from my fork. If one of your dependencies requires this package, adding that line will override the dependency and use my fork's version instead of the broken version.


Also just because I was curious, if you really didn't want to change the imports and wanted everything to go back to the way it was without pinning the version, you can configure Cython to go back to the old behavior. You have to add Cython to the build-system requires in pyproject.toml, add from Cython.Build import cythonize to setup.py, and then change line 95 to ext_modules=cythonize([array_wrappers_ext, original_ext, threaded_ext], language_level='2'),.

PyDataBlog commented 1 year ago

Any idea when this can go in?

JarekParal commented 1 year ago

Could please anyone from maintainers look at this PR? This is a blocking issue for many other projects. @ymwdalex @ParticularMiner

JarekParal commented 1 year ago

I found another workaround here:

echo "Cython==0.29.35" >> constraints.txt
export PIP_CONSTRAINT="$(pwd)/constraints.txt"

or you can add a link to constraints.txt to your requirements.txt:

--constraint constraints.txt
anyio==3.6.1
...

In both cases, the constraint is applied for dependent packages of packages used in requirements.txt

PyDataBlog commented 1 year ago

Can someone please look into this?

crc32 commented 1 year ago

Since this breaks a few things, and there's a pending update that would fix this issue, would this be ripe for a PEP-541 request?

audiomuze commented 1 month ago

It's obvious that @ParticularMiner has long since abandoned sparse_dot_topn_for_blocks. Would be useful if someone able to maintain it could fork it and publish a new version incorporating @pwschaedler's fix.