From 1fa10d508a9fda8a511e3e5b68efa09f07489bc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C8=98tefan=20Istrate?= Date: Fri, 30 Jul 2021 13:41:10 +0100 Subject: [PATCH 1/8] Fix pip setup. --- setup.py | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/setup.py b/setup.py index 0f2ef92e4..36e7abb31 100644 --- a/setup.py +++ b/setup.py @@ -5,12 +5,7 @@ import subprocess import sys -from setuptools import find_packages, setup -from setuptools.extension import Extension - -import numpy -from Cython.Build import cythonize - +from setuptools import find_packages, setup, Extension # dirty but working __version__ = re.search( @@ -34,7 +29,8 @@ if sys.platform.startswith('darwin'): compile_args.append("-stdlib=libc++") sdk_path = subprocess.check_output(['xcrun', '--show-sdk-path']) - os.environ['CFLAGS'] = '-isysroot "{}"'.format(sdk_path.rstrip().decode("utf-8")) + os.environ['CFLAGS'] = '-isysroot "{}"'.format( + sdk_path.rstrip().decode("utf-8")) setup( name='POT', @@ -46,15 +42,18 @@ author_email='remi.flamary@gmail.com, ncourty@gmail.com', url='https://github.com/PythonOT/POT', packages=find_packages(), - ext_modules=cythonize(Extension( - name="ot.lp.emd_wrap", - sources=["ot/lp/emd_wrap.pyx", "ot/lp/EMD_wrapper.cpp"], # cython/c++ src files - language="c++", - include_dirs=[numpy.get_include(), os.path.join(ROOT, 'ot/lp')], - extra_compile_args=compile_args, - )), + ext_modules=[ + Extension( + name="ot.lp.emd_wrap", + sources=["ot/lp/emd_wrap.pyx", + "ot/lp/EMD_wrapper.cpp"], # cython/c++ src files + language="c++", + extra_compile_args=compile_args, + ) + ], platforms=['linux', 'macosx', 'windows'], - download_url='https://github.com/PythonOT/POT/archive/{}.tar.gz'.format(__version__), + download_url='https://github.com/PythonOT/POT/archive/{}.tar.gz'.format( + __version__), license='MIT', scripts=[], data_files=[], @@ -85,5 +84,4 @@ 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', - ] -) + ]) From 425979f8fc78c54ba4330bb9c5e2b0036cf477cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C8=98tefan=20Istrate?= Date: Fri, 30 Jul 2021 13:53:46 +0100 Subject: [PATCH 2/8] Add back numpy directory. --- setup.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/setup.py b/setup.py index 36e7abb31..8d9f0e85e 100644 --- a/setup.py +++ b/setup.py @@ -5,6 +5,7 @@ import subprocess import sys +from distutils.sysconfig import get_python_inc from setuptools import find_packages, setup, Extension # dirty but working @@ -48,6 +49,9 @@ sources=["ot/lp/emd_wrap.pyx", "ot/lp/EMD_wrapper.cpp"], # cython/c++ src files language="c++", + include_dirs=[ + os.path.join(get_python_inc(plat_specific=1), "numpy") + ], extra_compile_args=compile_args, ) ], From 6ab588725df210107a5a2eeb0a60de3babdfaf6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C8=98tefan=20Istrate?= Date: Fri, 30 Jul 2021 14:03:09 +0100 Subject: [PATCH 3/8] Fix numpy dir. --- setup.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index 8d9f0e85e..40336b119 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ import subprocess import sys -from distutils.sysconfig import get_python_inc +from distutils.sysconfig import get_python_lib from setuptools import find_packages, setup, Extension # dirty but working @@ -33,6 +33,9 @@ os.environ['CFLAGS'] = '-isysroot "{}"'.format( sdk_path.rstrip().decode("utf-8")) +numpy_include_dir = os.path.join(get_python_lib(plat_specific=True), "numpy", + "core", "include") + setup( name='POT', version=__version__, @@ -49,9 +52,7 @@ sources=["ot/lp/emd_wrap.pyx", "ot/lp/EMD_wrapper.cpp"], # cython/c++ src files language="c++", - include_dirs=[ - os.path.join(get_python_inc(plat_specific=1), "numpy") - ], + include_dirs=[numpy_include_dir], extra_compile_args=compile_args, ) ], From 19e67744c3e190d300e5d6c8fe828561cc79d887 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C8=98tefan=20Istrate?= Date: Fri, 30 Jul 2021 14:28:24 +0100 Subject: [PATCH 4/8] Update README --- README.md | 7 ------- 1 file changed, 7 deletions(-) diff --git a/README.md b/README.md index 20e060620..ad72a3c1f 100644 --- a/README.md +++ b/README.md @@ -82,13 +82,6 @@ The library has been tested on Linux, MacOSX and Windows. It requires a C++ comp #### Pip installation -Note that due to a limitation of pip, `cython` and `numpy` need to be installed -prior to installing POT. This can be done easily with - -```console -pip install numpy cython -``` - You can install the toolbox through PyPI with: ```console From a6b8939963941a3dbdbbcc0866cdfd3dc050e6d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C8=98tefan=20Istrate?= Date: Tue, 3 Aug 2021 08:22:05 +0100 Subject: [PATCH 5/8] Update CI setup. --- .circleci/config.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e4c71dde1..4002ea01f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -50,10 +50,9 @@ jobs: name: Get Python running command: | python -m pip install --user --upgrade --progress-bar off pip - python -m pip install --user --upgrade --progress-bar off -r requirements.txt + python -m pip install --user -e . python -m pip install --user --upgrade --progress-bar off -r docs/requirements.txt python -m pip install --user --upgrade --progress-bar off ipython "https://api.github.com/repos/sphinx-gallery/sphinx-gallery/zipball/master" memory_profiler - python -m pip install --user -e . - save_cache: key: pip-cache @@ -183,4 +182,4 @@ workflows: branches: ignore: /.*/ tags: - only: /[0-9]+(\.[0-9]+)*$/ \ No newline at end of file + only: /[0-9]+(\.[0-9]+)*$/ From 4a2d08c3e2bd8381876d87f89e66b5e5691ce9d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C8=98tefan=20Istrate?= Date: Tue, 3 Aug 2021 09:35:40 +0100 Subject: [PATCH 6/8] Fix setup requirements by adding pyproject.toml --- pyproject.toml | 2 ++ setup.py | 9 +++------ 2 files changed, 5 insertions(+), 6 deletions(-) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000..c20b50623 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,2 @@ +[build-system] +requires = ["setuptools", "wheel", "numpy>=1.16", "cython>=0.23"] diff --git a/setup.py b/setup.py index 40336b119..19caadf2c 100644 --- a/setup.py +++ b/setup.py @@ -5,9 +5,10 @@ import subprocess import sys -from distutils.sysconfig import get_python_lib from setuptools import find_packages, setup, Extension +import numpy + # dirty but working __version__ = re.search( r'__version__\s*=\s*[\'"]([^\'"]*)[\'"]', # It excludes inline comment too @@ -33,9 +34,6 @@ os.environ['CFLAGS'] = '-isysroot "{}"'.format( sdk_path.rstrip().decode("utf-8")) -numpy_include_dir = os.path.join(get_python_lib(plat_specific=True), "numpy", - "core", "include") - setup( name='POT', version=__version__, @@ -52,7 +50,7 @@ sources=["ot/lp/emd_wrap.pyx", "ot/lp/EMD_wrapper.cpp"], # cython/c++ src files language="c++", - include_dirs=[numpy_include_dir], + include_dirs=[numpy.get_include()], extra_compile_args=compile_args, ) ], @@ -62,7 +60,6 @@ license='MIT', scripts=[], data_files=[], - setup_requires=["numpy>=1.16", "cython>=0.23"], install_requires=["numpy>=1.16", "scipy>=1.0"], classifiers=[ 'Development Status :: 5 - Production/Stable', From d6f9b458981505ceecc2b4d1608f628a238d3070 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C8=98tefan=20Istrate?= Date: Tue, 3 Aug 2021 10:08:36 +0100 Subject: [PATCH 7/8] Add back requirements.txt installation to CircleCI. --- .circleci/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4002ea01f..c65127b5b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -51,6 +51,7 @@ jobs: command: | python -m pip install --user --upgrade --progress-bar off pip python -m pip install --user -e . + python -m pip install --user --upgrade --progress-bar off -r requirements.txt python -m pip install --user --upgrade --progress-bar off -r docs/requirements.txt python -m pip install --user --upgrade --progress-bar off ipython "https://api.github.com/repos/sphinx-gallery/sphinx-gallery/zipball/master" memory_profiler From ae3a423d82dfe5dd1122f7b92f30366db59c4d20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C8=98tefan=20Istrate?= Date: Sun, 8 Aug 2021 13:00:46 +0100 Subject: [PATCH 8/8] Add explicit build-backend setting. --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index c20b50623..bb61cd8d2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,2 +1,3 @@ [build-system] requires = ["setuptools", "wheel", "numpy>=1.16", "cython>=0.23"] +build-backend = "setuptools.build_meta"