xhluca / bm25s

Fast lexical search implementing BM25 in Python using Numpy, Numba and Scipy
https://bm25s.github.io
MIT License
862 stars 35 forks source link

[`compat`] Allow for local install on Windows #3

Closed tomaarsen closed 4 months ago

tomaarsen commented 4 months ago

Hello!

Pull Request overview

Details

Currently, the open("README.md") in setup.py is complaining on Windows with:

UnicodeDecodeError: 'charmap' codec can't decode byte 0x8f in position 344: character maps to <undefined>

due to some unexpected character somewhere. Specifying the encoding as UTF-8 is a standard way to allow Windows users to open files safely.

Unrelated

Another thing, perhaps you can just do:

from bm25s.version import __version__ as version

rather than

version = {}
with open(f"{package_name}/version.py", encoding="utf8") as fp:
    exec(fp.read(), version)

...

version["__version__"]

Also because I don't like using exec, but it's personal preference.

xhluca commented 4 months ago

version = {} with open(f"{package_name}/version.py", encoding="utf8") as fp: exec(fp.read(), version) version["version"]

Thanks! You are right that exec is not great. I believe import would fail due to how setup.py is designed, but would need to look into it.