From f8c979529e88f88628802bc08f9b00fa5bb10154 Mon Sep 17 00:00:00 2001 From: tqtg Date: Fri, 1 Dec 2023 18:33:40 +0000 Subject: [PATCH 1/4] add clean cmd --- setup.py | 43 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 5 deletions(-) diff --git a/setup.py b/setup.py index d81bc3d2f..2d04bad47 100644 --- a/setup.py +++ b/setup.py @@ -27,7 +27,8 @@ import os import sys import glob -from setuptools import Extension, setup, find_packages +import shutil +from setuptools import Extension, Command, setup, find_packages try: from Cython.Build import cythonize @@ -287,11 +288,43 @@ def extract_gcc_binaries(): ) ] -cmdclass = {} -# cythonize c++ modules -extensions = cythonize(extensions) -cmdclass.update({"build_ext": build_ext}) +class CleanCommand(Command): + description = "Remove build artifacts from the source tree" + + user_options = [] + + def initialize_options(self): + pass + + def finalize_options(self): + pass + + def run(self): + # Remove .cpp and .so files for a clean build + if os.path.exists("build"): + shutil.rmtree("build") + for dirpath, dirnames, filenames in os.walk("cornac"): + for filename in filenames: + root, extension = os.path.splitext(filename) + + if extension in [".so", ".pyd", ".dll", ".pyc"]: + os.unlink(os.path.join(dirpath, filename)) + + if extension in [".c", ".cpp"]: + pyx_file = str.replace(filename, extension, ".pyx") + if os.path.exists(os.path.join(dirpath, pyx_file)): + os.unlink(os.path.join(dirpath, filename)) + + for dirname in dirnames: + if dirname == "__pycache__": + shutil.rmtree(os.path.join(dirpath, dirname)) + + +cmdclass = { + "clean": CleanCommand, + "build_ext": build_ext, +} setup( name="cornac", From 6bb78c6cedd95074555b3ae6d1cb1a66a5a09d0d Mon Sep 17 00:00:00 2001 From: tqtg Date: Fri, 1 Dec 2023 11:16:59 -0800 Subject: [PATCH 2/4] add requirements.txt --- requirements.txt | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 000000000..de4ae4d02 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,5 @@ +numpy +scipy +Cython +tqdm +powerlaw \ No newline at end of file From 50f3bf53b49cb57b12f69d50209636d2afe015e9 Mon Sep 17 00:00:00 2001 From: tqtg Date: Fri, 1 Dec 2023 11:17:31 -0800 Subject: [PATCH 3/4] tqdm version removed --- setup.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 2d04bad47..f9aba9915 100644 --- a/setup.py +++ b/setup.py @@ -31,7 +31,6 @@ from setuptools import Extension, Command, setup, find_packages try: - from Cython.Build import cythonize from Cython.Distutils import build_ext import numpy as np import scipy @@ -96,8 +95,11 @@ def extract_gcc_binaries(): os.environ["CC"] = gcc os.environ["CXX"] = gcc else: + if not os.path.exists("/usr/bin/g++"): + print( + "No GCC available. Install gcc from Homebrew using brew install gcc." + ) USE_OPENMP = False - print("No GCC available. Install gcc from Homebrew using brew install gcc.") # required arguments for default gcc of OSX compile_args.extend(["-O2", "-stdlib=libc++", "-mmacosx-version-min=10.7"]) link_args.extend(["-O2", "-stdlib=libc++", "-mmacosx-version-min=10.7"]) @@ -341,7 +343,7 @@ def run(self): "recommendation", ], ext_modules=extensions, - install_requires=["numpy", "scipy", "tqdm>=4.19", "powerlaw"], + install_requires=["numpy", "scipy", "tqdm", "powerlaw"], extras_require={"tests": ["pytest", "pytest-pep8", "pytest-xdist", "pytest-cov"]}, cmdclass=cmdclass, packages=find_packages(), From f0f400b87dec6a9973d61f786eb37f7d40725a8d Mon Sep 17 00:00:00 2001 From: tqtg Date: Fri, 1 Dec 2023 11:18:51 -0800 Subject: [PATCH 4/4] update docs --- docs/source/api_ref/metrics.rst | 2 +- docs/source/developer/contributing.rst | 3 ++- docs/source/developer/gettingstarted.rst | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/source/api_ref/metrics.rst b/docs/source/api_ref/metrics.rst index 781d3b064..4ee93fdfc 100644 --- a/docs/source/api_ref/metrics.rst +++ b/docs/source/api_ref/metrics.rst @@ -32,7 +32,7 @@ Fmeasure (F1) .. autoclass:: FMeasure Hit Ratio (HitRatio) -------------------- +-------------------- .. autoclass:: HitRatio Mean Average Precision (MAP) diff --git a/docs/source/developer/contributing.rst b/docs/source/developer/contributing.rst index d4f8e27e6..4f8c65ae4 100644 --- a/docs/source/developer/contributing.rst +++ b/docs/source/developer/contributing.rst @@ -12,7 +12,7 @@ Clone your forked repository to your local machine using the following command: .. code-block:: bash - git clone https://github.com/PreferredAI/cornac.git + git clone https://github.com/your-github-id/cornac.git Create a New Branch ^^^^^^^^^^^^^^^^^^^ @@ -40,6 +40,7 @@ are working as expected. .. code-block:: bash + python3 setup.py clean python3 setup.py install diff --git a/docs/source/developer/gettingstarted.rst b/docs/source/developer/gettingstarted.rst index 9ba83192b..5784f3bd3 100644 --- a/docs/source/developer/gettingstarted.rst +++ b/docs/source/developer/gettingstarted.rst @@ -19,7 +19,7 @@ Setting Up Your Development Environment .. code-block:: bash - git clone https://github.com/PreferredAI/cornac.git + git clone https://github.com/your-github-id/cornac.git cd cornac python -m venv venv source venv/bin/activate # On Windows, use 'venv\Scripts\activate'