lightfm icon indicating copy to clipboard operation
lightfm copied to clipboard

Refactor & Cleanup setup.py / setup.cfg

Open SimonCW opened this issue 2 years ago • 6 comments

Hi @maciejkula,

I changed a few things about the setup here:

  • In setup.cfg, description-file is deprecated in favor of description_file.
  • I removed the additional CFLAGS as we discussed here: https://github.com/lyst/lightfm/pull/623#issuecomment-1003448754. I think optional CLFAGS can still be provided via environment variables by the users but I haven't verified this.
  • Cython now demands a language_level setting, which I set to python3. However, I'm not 100% certain on this. But my local tests on linux/amd64 are working fine. https://stackoverflow.com/questions/54900723/what-does-language-level-in-setup-py-for-cython-do
  • I cythonized with the new settings and a new cython version (I think that was also holding us back in building for python3.10 on conda https://github.com/conda-forge/lightfm-feedstock/pull/16)

SimonCW avatar Mar 03 '22 08:03 SimonCW

Mh, currently it is hard for me to fix our builds and tests b/c they are spread over appveyor, travis, circleci . Some of these services don't provide very good convenience images (appveyor) and it is hard to find good examples of how to use this properly.

I think this would be solved by moving to github actions. Additionally, we could automate the build process for the docs.

Initial experiments with GH Actions here: https://github.com/lyst/lightfm/pull/636

SimonCW avatar Mar 04 '22 12:03 SimonCW

The tests for windows are failing but I don't know why (https://github.com/SimonCW/lightfm/runs/5440138903?check_suite_focus=true). I might try to debug with my other Windows Laptop later this week. I also quickly checked https://github.com/pypa/cibuildwheel/, which looks promising for creating windows and macOS wheels.

SimonCW avatar Mar 06 '22 18:03 SimonCW

The build wheel action is running successfully but the created wheel doesn't work for me. Installing the wheel from the artifacts here: https://github.com/SimonCW/lightfm/actions/runs/1983477030 and running

python -c "from lightfm import LightFM
from lightfm.datasets import fetch_movielens
from lightfm.evaluation import precision_at_k

# Load the MovieLens 100k dataset. Only five
# star ratings are treated as positive.
data = fetch_movielens(min_rating=5.0)

# Instantiate and train the model
model = LightFM(loss='warp')
model.fit(data['train'], epochs=30, num_threads=2)

# Evaluate the trained model
test_precision = precision_at_k(model, data['test'], k=5).mean(); print(test_precision)"

Gives this error:

/Users/simon.weiss/Repos/contrib/lightfm/lightfm/_lightfm_fast.py:9: UserWarning: LightFM was compiled without OpenMP support. Only a single thread will be used.
  warnings.warn(
Traceback (most recent call last):
  File "/Users/simon.weiss/Repos/contrib/lightfm/lightfm/__init__.py", line 2, in <module>
    __LIGHTFM_SETUP__
NameError: name '__LIGHTFM_SETUP__' is not defined

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/simon.weiss/Repos/contrib/lightfm/lightfm/_lightfm_fast.py", line 3, in <module>
    from ._lightfm_fast_openmp import *  # NOQA
ModuleNotFoundError: No module named 'lightfm._lightfm_fast_openmp'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/simon.weiss/Repos/contrib/lightfm/lightfm/__init__.py", line 4, in <module>
    from .lightfm import LightFM
  File "/Users/simon.weiss/Repos/contrib/lightfm/lightfm/lightfm.py", line 8, in <module>
    from ._lightfm_fast import (
  File "/Users/simon.weiss/Repos/contrib/lightfm/lightfm/_lightfm_fast.py", line 14, in <module>
    from ._lightfm_fast_no_openmp import *  # NOQA
ImportError: dlopen(/Users/simon.weiss/Repos/contrib/lightfm/lightfm/_lightfm_fast_no_openmp.cpython-38-darwin.so, 0x0002): tried: '/Users/simon.weiss/Repos/contrib/lightfm/lightfm/_lightfm_fast_no_openmp.cpython-38-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e'))

The cython parts still seem to be compiled to x86_64.

@maciejkula, do you have an M1 and could try to run this?

SimonCW avatar Mar 20 '22 18:03 SimonCW

@SimonCW, any progress on this? We are looking for a solution to install LightFM on Python 3.10. Updating C files fixes the issue.

dbalabka avatar Mar 08 '23 10:03 dbalabka

@SimonCW do you need any help?

dbalabka avatar Mar 08 '23 10:03 dbalabka

Hey @dbalabka, unfortunately, my current private and work situation doesn't leave any time for LightFM. You are very welcome to take over.

Edit: I'd be happy to give you context and/or test (I am on a M1 pro).

SimonCW avatar Mar 08 '23 11:03 SimonCW