From 251947f0a94543229996d28b4514fb1fa48f4a92 Mon Sep 17 00:00:00 2001 From: jajupmochi Date: Thu, 8 Feb 2024 16:08:30 +0100 Subject: [PATCH] [CI] Update setup.py for including GEDLIB for dist and wheel. --- README.md | 1 + requirements.txt | 2 +- requirements_pypi.txt | 2 +- setup.py | 66 ++++++++++++++++++++++++++++++++----------- 4 files changed, 52 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index bdc9ce416f..5b6a0599ba 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ A Python package for graph kernels, graph edit distances and graph pre-image pro * tqdm>=4.26.0 * control>=0.8.2 (for generalized random walk kernels only) * slycot>=0.3.3 (for generalized random walk kernels only, which requires a fortran compiler (e.g., `gfortran`) and BLAS/LAPACK (e.g. `liblapack-dev`)) +* Cython~=0.29.33 (for GEDLIB only) ## How to use? diff --git a/requirements.txt b/requirements.txt index 7cf649c4c6..d9050182c1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,7 +7,7 @@ tabulate>=0.8.2 tqdm>=4.26.0 control>=0.8.2 # for generalized random walk kernels only. slycot>=0.3.3 # for generalized random walk kernels only, which requires a fortran compiler (e.g., `gfortran`) and BLAS/LAPACK (e.g. `liblapack-dev`) -Cython>=0.29.33 # for GEDLIB. +Cython~=0.29.33 # for GEDLIB. cvxpy>=1.0.31 # for preimage. Does not work for "pip install graphkit-learn". # -e https://files.pythonhosted.org/packages/11/d0/d900870dc2d02ea74961b90c353666c6528a33ea61a10aa59a0d5574ae59/cvxpy-1.0.31.tar.gz # for preimage. cvxopt>=1.2.5 # for preimage. diff --git a/requirements_pypi.txt b/requirements_pypi.txt index 82d1e9026b..db791394a3 100644 --- a/requirements_pypi.txt +++ b/requirements_pypi.txt @@ -7,7 +7,7 @@ tabulate>=0.8.2 tqdm>=4.26.0 control>=0.8.2 # for generalized random walk kernels only. # slycot>=0.3.3 # for generalized random walk kernels only, which requires a fortran compiler (e.g., `gfortran`) and BLAS/LAPACK (e.g. `liblapack-dev`) -Cython>=0.29.33 # for GEDLIB. +Cython~=0.29.33 # for GEDLIB. # cvxpy>=1.0.31 # for preimage. Does not work for "pip install graphkit-learn". # -e https://files.pythonhosted.org/packages/11/d0/d900870dc2d02ea74961b90c353666c6528a33ea61a10aa59a0d5574ae59/cvxpy-1.0.31.tar.gz # for preimage. cvxopt>=1.2.5 # for preimage. diff --git a/setup.py b/setup.py index f2cc187958..cae57290ce 100644 --- a/setup.py +++ b/setup.py @@ -60,23 +60,52 @@ def parse_args(): args = parse_args() -if args.build_gedlibpy == 'true': - # Compile GEDLIBPY module: - import subprocess - - cur_python = sys.executable - subprocess.call([cur_python, '--version']) - subprocess.call(['which', cur_python]) - gedlib_dir = 'gklearn/gedlib/' - subprocess.call( - [ - cur_python, 'setup_simple.py', # 'setup.py', - # '--use-existing-gedlib', args.use_existing_gedlib, - # '--build-gedlib', args.build_gedlib, - # '--develop-mode', args.develop_mode, - 'build_ext', '--inplace' - ], cwd=gedlib_dir - ) +from setuptools.command.install import install + + +class CustomInstallCommand(install): + """Customized setuptools install command - prints a friendly greeting.""" + + + def run(self): + if args.build_gedlibpy == 'true': + # Compile GEDLIBPY module: + import subprocess + + cur_python = sys.executable + subprocess.call([cur_python, '--version']) + subprocess.call(['which', cur_python]) + gedlib_dir = 'gklearn/gedlib/' + subprocess.call( + [ + cur_python, 'setup_simple.py', # 'setup.py', + # '--use-existing-gedlib', args.use_existing_gedlib, + # '--build-gedlib', args.build_gedlib, + # '--develop-mode', args.develop_mode, + 'build_ext', '--inplace' + ], cwd=gedlib_dir + ) + + install.run(self) + + +# if args.build_gedlibpy == 'true': +# # Compile GEDLIBPY module: +# import subprocess +# +# cur_python = sys.executable +# subprocess.call([cur_python, '--version']) +# subprocess.call(['which', cur_python]) +# gedlib_dir = 'gklearn/gedlib/' +# subprocess.call( +# [ +# cur_python, 'setup_simple.py', # 'setup.py', +# # '--use-existing-gedlib', args.use_existing_gedlib, +# # '--build-gedlib', args.build_gedlib, +# # '--develop-mode', args.develop_mode, +# 'build_ext', '--inplace' +# ], cwd=gedlib_dir +# ) # Install graphkit-learn: with open("README.md", "r") as fh: @@ -109,6 +138,9 @@ def parse_args(): 'Intended Audience :: Developers', ], install_requires=install_requires, + cmdclass={ + 'install': CustomInstallCommand, + }, # package_dir={'': 'gklearn'}, # package_data={ # # '': ['README.md', 'requirements_pypi.txt', 'requirements.txt', 'LICENSE'],