From 42f057b0db7e41d49e9598145dd13e83fd7ccf19 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Thu, 9 Jan 2025 10:00:17 +0100 Subject: [PATCH 1/4] Split setup.py into setup.py and pyproject.toml for modern packaging --- pyproject.toml | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++ setup.py | 45 ++-------------------------------------- 2 files changed, 58 insertions(+), 43 deletions(-) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..20ac6fd5 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,56 @@ +[build-system] +requires = [ + "setuptools>=42", + "wheel", + "Cython>=0.29.21", + "numpy<2.0.0", +] +build-backend = "setuptools.build_meta" + +[project] +name = "cornac" +version = "2.3.0" +description = "A Comparative Framework for Multimodal Recommender Systems" +readme = "README.md" +dependencies = [ + "numpy<2.0.0", + "scipy<=1.13.1", + "tqdm", + "powerlaw" +] +requires-python = ">=3.9" +license = { file = "LICENSE" } +keywords = [ + "recommender system", + "collaborative filtering", + "multimodal", + "preference learning", + "recommendation", +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Science/Research", + "Intended Audience :: Education", + "Intended Audience :: Developers", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "License :: OSI Approved :: Apache Software License", + "Topic :: Software Development", + "Topic :: Scientific/Engineering", +] + +[project.urls] +Homepage = "https://cornac.preferred.ai" + +[project.optional-dependencies] +tests = [ + "pytest", + "pytest-pep8", + "pytest-xdist", + "pytest-cov", + "Flask", +] diff --git a/setup.py b/setup.py index 18039e7d..222a708a 100644 --- a/setup.py +++ b/setup.py @@ -29,20 +29,8 @@ import glob import shutil from setuptools import Extension, Command, setup, find_packages - - -INSTALL_REQUIRES = ["numpy<2.0.0", "scipy<=1.13.1", "tqdm", "powerlaw"] - -try: - from Cython.Distutils import build_ext - import numpy as np - import scipy -except ImportError: - escape_dependency_version = lambda x: '"{}"'.format(x) if "<" in x or "=" in x or ">" in x else x - exit( - "We need some dependencies to build Cornac.\n" - + "Run: pip3 install Cython {}".format(" ".join([escape_dependency_version(x) for x in INSTALL_REQUIRES])) - ) +from setuptools.command.build_ext import build_ext +import numpy as np with open("README.md", "r") as fh: @@ -341,37 +329,8 @@ def run(self): } setup( - name="cornac", - version="2.3.0", - description="A Comparative Framework for Multimodal Recommender Systems", - long_description=long_description, - long_description_content_type="text/markdown", - url="https://cornac.preferred.ai", - keywords=[ - "recommender system", - "collaborative filtering", - "multimodal", - "preference learning", - "recommendation", - ], ext_modules=extensions, - install_requires=INSTALL_REQUIRES, extras_require={"tests": ["pytest", "pytest-pep8", "pytest-xdist", "pytest-cov", "Flask"]}, cmdclass=cmdclass, packages=find_packages(), - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Intended Audience :: Science/Research", - "Intended Audience :: Education", - "Intended Audience :: Developers", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "Programming Language :: Python :: 3.13", - "License :: OSI Approved :: Apache Software License", - "Topic :: Software Development", - "Topic :: Scientific/Engineering", - ], ) From 633bf0350282268c8af55f76304d7571cb982028 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Thu, 9 Jan 2025 10:09:11 +0100 Subject: [PATCH 2/4] doc: remove redundant pip install command --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 35fce97a..8ff9b8a1 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,6 @@ Currently, we are supporting Python 3. There are several ways to install Cornac: - **From the GitHub source (for latest updates):** ```bash - pip3 install Cython numpy scipy pip3 install git+https://github.com/PreferredAI/cornac.git ``` From 76d669e7640013aed8628c2e4fecee8a47047166 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Thu, 9 Jan 2025 10:56:34 +0100 Subject: [PATCH 3/4] fix: add scipy as build dependency --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 20ac6fd5..973da808 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,6 +4,7 @@ requires = [ "wheel", "Cython>=0.29.21", "numpy<2.0.0", + "scipy<=1.13.1", ] build-backend = "setuptools.build_meta" From cd2ce82905c88a7ebffad64bcbc54ae6397e7b0a Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Thu, 9 Jan 2025 10:56:58 +0100 Subject: [PATCH 4/4] Use Cython for building extensions --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 222a708a..988dda07 100644 --- a/setup.py +++ b/setup.py @@ -29,7 +29,7 @@ import glob import shutil from setuptools import Extension, Command, setup, find_packages -from setuptools.command.build_ext import build_ext +from Cython.Distutils import build_ext import numpy as np